Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't auto-indent target #19

Closed
machinemob opened this issue Oct 24, 2022 · 15 comments · Fixed by #95
Closed

Doesn't auto-indent target #19

machinemob opened this issue Oct 24, 2022 · 15 comments · Fixed by #95
Labels
enhancement New feature or request indent

Comments

@machinemob
Copy link

machinemob commented Oct 24, 2022

Hi, I'm not sure if this is an issue or not-a-feature...

target:
    do something <-- "make" syntax automatically indents this, vim-just does not

NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@iMac-Pro

@NoahTheDuke
Copy link
Owner

Thanks! Yeah, this is definitely a space I struggle with. I don't know anything about vim indentation rules. If it's frustrating you too, I can take a crack at it.

@NoahTheDuke NoahTheDuke self-assigned this Oct 24, 2022
@machinemob
Copy link
Author

I copied /usr/share/vim/vim82/indent/make.vim to ~/.config/nvim/after/indent/justfile.vim and it it seems to work (ie. I get an indent and the world didn't explode). It would be better for this to be implemented properly tbh. Again, I don't know if this an expected feature of vim-just but regular makefile authors might wonder why it's missing. Thanks for reading.

MacOS Catalina

@NoahTheDuke
Copy link
Owner

It's expected that there's no indentation because I didn't add any vimscript to handle it. So far, no one's been bothered enough to do the work (myself included), but your solution seems like a reasonable starting off point. Thanks for letting me know.

stefanvanburen added a commit to stefanvanburen/dotfiles that referenced this issue Mar 4, 2023
This reverts commit 3fbbfe7.

vim-just doesn't handle indentation[1], which is fairly annoying. Remove
it for now and use `make` as the filetype.

[1]: NoahTheDuke/vim-just#19
@laniakea64 laniakea64 added the help wanted Extra attention is needed label Mar 21, 2023
@sandersantema
Copy link

I copied /usr/share/vim/vim82/indent/make.vim to ~/.config/nvim/after/indent/justfile.vim and it it seems to work (ie. I get an indent and the world didn't explode). It would be better for this to be implemented properly tbh. Again, I don't know if this an expected feature of vim-just but regular makefile authors might wonder why it's missing. Thanks for reading.

MacOS Catalina

Instead of copying the file another alternative is to do the following:

vim.cmd.source('$VIMRUNTIME/indent/make.vim')

vim.api.nvim_create_autocmd(
  'InsertEnter',
  { buffer = 0, command = 'setlocal indentexpr=GetMakeIndent()', once = true }
)

I've used an autocmd here as I was otherwise only able to set the indentexpr globally (i.e. vim.o, vim.opt, vim.cmd.set but not their local variants).

@wookayin
Copy link

wookayin commented Jan 10, 2024

Using the idea of @sandersantema using make's GetMakeIndent(), one can write a ftplugin ~/.config/nvim/after/ftplugin/just.vim (or more in principle, indent/just.lua, if excluding the ts sts sw expandtab config) as follows:

setlocal ts=2 sts=2 sw=2
setlocal expandtab

source $VIMRUNTIME/indent/make.vim
silent unlet! b:undo_indent
setlocal indentexpr=GetMakeIndent()

Or lua version (ftplugin/just.lua):

vim.opt_local.ts = 2
vim.opt_local.sts = 2
vim.opt_local.sw = 2
vim.opt_local.expandtab = true

vim.cmd.source "$VIMRUNTIME/indent/make.vim"
vim.b.undo_indent = nil
vim.opt_local.indentexpr = 'GetMakeIndent()'

BTW, the plugin should have a own indentexpr for just.

@laniakea64 laniakea64 assigned laniakea64 and unassigned NoahTheDuke Jan 19, 2024
@laniakea64
Copy link
Collaborator

BTW, the plugin should have a own indentexpr for just.

I don't actually know what I'm doing in Vim indentation rules, but had another go at this and maybe got somewhere this time? - https://github.com/NoahTheDuke/vim-just/tree/indent

Please test this branch and let us know how this indentexpr works for you. I don't use auto-indent myself, so whether this is suitable for merge to main depends on your feedback. Thanks 🙂

@laniakea64 laniakea64 removed their assignment Apr 8, 2024
@laniakea64 laniakea64 added the enhancement New feature or request label Apr 8, 2024
@laniakea64
Copy link
Collaborator

https://github.com/NoahTheDuke/vim-just/tree/indent

Please test this branch and let us know how this indentexpr works for you. I don't use auto-indent myself, so whether this is suitable for merge to main depends on your feedback. Thanks 🙂

This seems to be going stale. Is there still interest in having and testing this feature?

In case switching to the indent test branch is too cumbersome, an equivalent alternative would be to download indent/just.vim from that branch and place it in ~/.vim/indent/just.vim or ~/.config/nvim/indent/just.vim for testing.

@NoahTheDuke
Copy link
Owner

Maybe just merge it and let's debug in prod. Better to have something that mostly works and iterate?

@laniakea64
Copy link
Collaborator

Sounds good if it actually does mostly work? Was hoping for confirmation of that before merging, since it's hard to be sure without dogfooding.

@laniakea64 laniakea64 added the stale Unresolved, but no longer applicable or interest seems lost label Apr 19, 2024
@laniakea64
Copy link
Collaborator

Just now noticing that while we have been interpreting this issue as requesting indent support, the original question was only "is auto-indenting of recipe bodies a feature of vim-just". And the issue author's wording appears to be going out of their way to not make a feature request. Maybe this is why no one is giving any testing feedback here.

If no one is trying the draft indent support enough to be able to say whether it seems to at least "mostly work", maybe we should just close this and not take on maintaining something that neither the community cares about nor would we use ourselves. We can still leave the indent branch as-is in case interest in auto-indent support comes up later - it's unlikely to get merge conflicts since it only touches one file that doesn't exist on main.

@laniakea64
Copy link
Collaborator

https://github.com/NoahTheDuke/vim-just/tree/indent
Please test this branch and let us know how this indentexpr works for you. I don't use auto-indent myself, so whether this is suitable for merge to main depends on your feedback. Thanks 🙂

This seems to be going stale. Is there still interest in having and testing this feature?

No responses and the branch has become stale, closing due to apparent lack of interest. This will be reopened when/if people become interested enough in having auto-indent support to test the draft indent file and provide feedback per #19 (comment) .

@laniakea64 laniakea64 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@machinemob
Copy link
Author

https://github.com/NoahTheDuke/vim-just/tree/indent
Please test this branch and let us know how this indentexpr works for you. I don't use auto-indent myself, so whether this is suitable for merge to main depends on your feedback. Thanks 🙂

This seems to be going stale. Is there still interest in having and testing this feature?

In case switching to the indent test branch is too cumbersome, an equivalent alternative would be to download indent/just.vim from that branch and place it in ~/.vim/indent/just.vim or ~/.config/nvim/indent/just.vim for testing.

My sincere apologies for allowing this lapse - mea culpa. I 100% respect a decision to keep this closed. Thank you for addressing.

I am able to successfully indent by pointing packer to the "indent" branch via:
use {'NoahTheDuke/vim-just', branch='indent'}

@laniakea64 laniakea64 removed help wanted Extra attention is needed stale Unresolved, but no longer applicable or interest seems lost labels Jun 11, 2024
@laniakea64
Copy link
Collaborator

I am able to successfully indent by pointing packer to the "indent" branch via: use {'NoahTheDuke/vim-just', branch='indent'}

Thanks @machinemob for testing! Sounds like the indent support in that branch is good enough to bring onto main, and there is interest in the feature. Re-opening

@laniakea64
Copy link
Collaborator

Initial indent support is merged!

@machinemob
Copy link
Author

Initial indent support is merged!

I updated via Packer and am able to indent. No apparent issues. Thank you!

(NVIM v0.10.0, Packer, MacOS 14.4.1 (23E224), Wezterm 20240203-110809-5046fc22)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request indent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants