I’m currently updating my nvim config and have encountered some indentation problems since I installed nvim-treesitter with a Fortran parser.
Does anyone have any experience with nvim and treesitter?
I only used fortrls (LSP) before, and it feels like I had fewer issues without tree-sitter.
Currently, for example, when I type do <enter> the indentation level is zero and messes everything up (no indentation at all) as long as I don’t have an end do.
! some code
! with indent level 1
do ! as soon as I type the 'o', indent is zero
! indentation is zero instead of +1
end do ! this magically gets indented correctly
! but the next line is indented ???
! but only one line, this is fine again
I’ve tried tree-sitter on Neovim and ended up disabling it in Fortran because there were a lot of errors, mostly with the more modern constructs. I assume it only handles FORTRAN77 and maybe some parts of Fortran90 and should be updated. In their GitHub (GitHub - nvim-treesitter/nvim-treesitter: Nvim Treesitter configurations and abstraction layer) they say that they support Fortran via the one that @freevryheid said Helix uses
I guess I will do the same and hope for more updates. Maybe if I find some time I will contribute to it, too.
Did you disable it for everything or just indentation?
Yes, I’m thinking on contributing at some time too (but never made up the time to see how Tree-Sitter works). I did disable it for everything because I had other problems that I don’t remember exactly right now, but they were related to syntax highlighting.
Right now I’m just using the indentation that Neovim provides, plus I run fprettify on my files fairly often to fix indentations and spaces (watch out to anyone that runs fprettify! Sometimes it can delete your whole file so always run fprettify --diff first)
lfortran fmt takes care of formatting, essentially a stand-in for fprettify
lfortran already uses a grammar file that I’m guessing is used by the compiler. Instead of re-inventing the wheel so to speak, why not just “convert” this asdl file to tree-sitter format.