What's the best way to tell Vim (well, Neovim) that a certain form should be indented like a macro? (I believe I'm using clojure.vim, though I can't determine where it's installed.)
what does "like a macro" mean?
A constant 2-space indent, for example:
(let [x 1]
(+ x 1)) ;; 2 space indenton master, you can use g:clojure_special_indent_words : https://github.com/clojure-vim/clojure.vim?tab=readme-ov-file#gclojure_special_indent_words
if you're on the "rewrite indention code" branch (https://github.com/clojure-vim/clojure.vim/pull/31), you can use g:clojure_indent_rules (there's no docs for it yet, you gotta read the code vimscript lol)
on master, you can also use lispwords i think
I'm currently using lispwords applied only to Clojure files, but the implementation feels rather clunky, so I was wondering if there's a more optimal "recommended" way of doing it.
no. you could connect to clojure-lsp and use its formatting functionality, which i think allows for selecting a single form (not just a whole file)
Lsp works with gq, yep
Why does lisp words feel clunky
So currently I have an autocmd that adds to the local lispwords when Clojure is being used:
(vim.api.nvim_create_autocmd
["FileType"]
{:pattern "clojure"
:callback (fn []
(vim.opt_local.lispwords:append
["register-effect!"
"register-action!"
"register-placeholder!"]))})
(I'm using Fennel for the configuration.)
This feels a little inelegant to me.Oh I think you're looking for ftplugin!
I'd probably just use vimscript for this because I'm weird like that:
ftplugin/clojure.vim
Would contain:
setlocal lispwords+=register-effect!,register-action!
I think using Fennel is by far the weirder choice! Thanks for the hint, I'll look into ftplugin.
I think ftplugin/*.lua is sourced now, but I won't swear to it.
https://github.com/neovim/neovim/issues/12670 looking positive
I use lua with after/ftplugin/clojure.lua and it works very nicely (although not for formating but settingnkey mallings) https://github.com/practicalli/nvim-astro5/blob/main/after%2Fftplugin%2Fclojure.lua