Closed machinemob closed 4 months ago
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.
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
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.
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).
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
.
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 :slightly_smiling_face:
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.
Maybe just merge it and let's debug in prod. Better to have something that mostly works and iterate?
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.
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
.
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 https://github.com/NoahTheDuke/vim-just/issues/19#issuecomment-2043854661 .
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 downloadindent/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'}
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
Initial indent support is merged!
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)
Hi, I'm not sure if this is an issue or not-a-feature...
NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@iMac-Pro