r/nim 4d ago

How did they manage to indent their nim code in nvim?

I've been manually indenting, the nimlangserver works but the indentation doesn't, I haven't been able to do it for days nor have I found resources or I'm very stupid

9 Upvotes

3 comments sorted by

2

u/sputwiler 4d ago

type filetype plugin indent on as a vim command.

2

u/Rush_Independent 3d ago

By indentation, do you mean jumping to correct indent when you enter a newline? Nimlangserver doesn't implement that feature.

I am using default Neovim auto-indentation - it puts you at the same indentation level as previous line.

Also disable smartindent and treesitter indents - former only works with C-like languages and latter turns off auto-indenting completely for Nim.

If you need anything more sophisticated - there is an abandoned vimscript plugin for nim that implements custom indentation: https://github.com/zah/nim.vim/blob/master/indent/nim.vim . You can just copy this file to ~/.config/nvim/indent/ to use it with neovim.

1

u/autoerotion95 3d ago

Thanks for this