Trouble with treesitter indentation and any kind of formatting. #750
-
I've patterned my config after the example config provided by NotAShelf.
I think that because I enabled indenting in the treesitter options, it is then applied to all languages that are enabled in the languages section. Anyway, when I have treesitter indentation enabled, indentation is badly broken. It kind of amplifies indentation, if that makes sense. So if the indentation should be 0, because I'm editing top level stuff, indentation works as it should. However, when I expect indentation to be at two spaces, creating a new line with either Then there's the second problem. None of formatting options I've tried work. As you can see above, I have formatOnSave enabled. I've also tried enabling conform, both with and without formatOnSave enabled, and I couldn't get anything to work. I don't know if these problems are connected. I'm too inexperienced to know if treesitter is really working at all. But I can say LSPs are working. Anyway, this is all complex, and might not be a problem with my config, NVF, or Nix, but the result of upstream problems. Thanks in advance for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I have not had a non-nix Neovim setup since 0.9, but I suspect that this is from the default indentation of Neovim. With 0.10 Neovim gained Editorconfig support, and I encourage you to use it (or per-buffer indentation settings) to ensure that languages perform as expected. There is also the possibility that this is a bug/"feature" in one of the grammars that you are using. I only noticed the indentation issue in Nix, but it was resolved by telling Neovim to set shiftwidth/tabwidth. Let me know if this fixes your issue, otherwise I can look at shipping a native solution. |
Beta Was this translation helpful? Give feedback.
-
I face this issue too, Hack - use
I need both of them to be setup (that is |
Beta Was this translation helpful? Give feedback.
I face this issue too,
treesitter.indent.enable = true
seems to be adding more indentation than what is needed. I was able to get a hack that fixes indentation issues for me.Hack - use
guess-indent-nvim
withtreesitter.indent.enable = true
I need both of them to be setup (that is
guess-indent-nvim
+treesitter.indent.enable = true
), without any of this, my indentation is literally unusable :(