tree-sitter-grammars / tree-sitter-hcl

HCL grammar for tree-sitter
https://tree-sitter-grammars.github.io/tree-sitter-hcl/
Apache License 2.0
91 stars 20 forks source link

Auto indent outside blocks #15

Closed wcarlsen closed 2 years ago

wcarlsen commented 2 years ago

Describe the bug When adding new line auto indent works great when inside a block, but when outside of a block it also auto indent when new line is added.

To Reproduce Steps to reproduce the behavior:

  1. I stock use AstroVim with :TSInstall hcl
  2. Write any Terraform block and try inserting a new line after that block. And see it auto indent.

Expected behavior I expect auto indent not to happen out side Terraform blocks.

Screenshots Hard to show on screenshots. But here is an attempt. See it on line 5. image

Additional context Also disabling indent makes it work outside Terraform blocks, but breaks indentation inside blocks.

MichaHoffmann commented 2 years ago

Hey @wcarlsen ,

i suppose its related to the queries in nvim treesitter ( https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/hcl/indents.scm for reference ). Ill have a look if the queries fit the syntax tree in the evening. A block_end should have triggered the indentation level to decrease i suppose in this case! ( but the block_end was highlighted correctly! so it could be a nvim-treesitter issue intuitively. )

MichaHoffmann commented 2 years ago

Hey,

Ill have to defer to the weekend have no time to update my nvim-treesitter setup to play with the queries. Its most certainly an issue with the queries for hcl there. Would you mind opening the issue there again?

wcarlsen commented 2 years ago

Sure I will try that.

MichaHoffmann commented 2 years ago

Are you fine with closing this here since it is handled by nvim-treesitter? If something in this repo prevents the work in nvim-treesitter we can reopen of course

wcarlsen commented 2 years ago

Sure thing!