Vim-racket: improved indentexpr

Been working on an improved indentexpr for vim-racket; if anyone is interesting in helping me dogfood it, please LMK and I'll clean it up and push a branch. Vim 9+ required.

Current improvements: handles {} and #<<herestrings correctly; indents (foo\nbar) correctly (b under f instead of under o ). Current issues: speed when reindenting whole files (small functions have been fine so far). I've one last "trick" to port from the C source for get_lisp_indent to try to speed things up which effectively uses the buffer contents like a cache; this should solve the speed problems.


Are there any plans regarding Neovim support?

For me personally, it's not very important. I'm set with the plugin version I currently have, but it wouldn't be nice if I updated and the whole plugin stopped working.

I don't plan on doing anything special for NeoVim (like using Lua), but I should be able to add a guard to only use the vim9 indentexpr if vim9script is available (so you can keep updating).

1 Like

Yes, that would be fine with me. Thanks! :slight_smile:

Hm. I've fallen off a bit on this. Adding to my todo list so I don't forget.

This is available experimentally as GitHub - benknoble/vim-racket at indentexpr and is only enabled when vim9script is available.

  • There are some slight issues with cond and match that I haven't figured out yet (I need test cases first…).
  • Indenting extremely large blocks correctly is slow, so there are 2 hacks to help. One limits the "context" of the indent to about 100 lines when looking for the outer brackets of an expression; if that ends up merging, I'll make it user configurable and document it. The other tries to use the previous line for indent if possible, but IIRC it's subject to the 100-line limit first.
  • Still, it's a marked improvement over lispindent, which fails to get for/fold, {}, and some other Racket-specific syntax right.
1 Like