Closed wagensveld closed 2 years ago
That would not be a problem! However for neovim I want to recommend https://github.com/nvim-treesitter/nvim-treesitter. It should work for filetype terraform
( https://github.com/nvim-treesitter/nvim-treesitter/blob/678a7857911f20cc9445aa13d28c454ae72483f5/lua/nvim-treesitter/parsers.lua#L432 )
Would using nvim-treesitter work for you instead? Otherwise we can also add terraform as supported filetype.
Thanks for that!
I have nvim treesitter installed and the hcl parser installed, when I open a tf file it defaults syntax to terraform
Setting the syntax to tf
works though
Do you know if there is any additional config required to get neovim to pick up the correct syntax? Thanks
Ok it should work with nvim-treesitter, so thats a problem. I strongly suspect the nvim-treesitter setup, could you reopen this issue there (with a reproducer if possible, that would greatly help)? I'll have a look at the weekend.
One further observation: the highlighting looks kind of wrong when the filetype is tf
the template expressions "${var.name_prefix}"
etc should not be highlighted as string ( kind of depends on your colorscheme, but for most its not ), also the comments should be highlighted differently.
For reference: my local nvim-treesitter config
local ts = require'nvim-treesitter.configs'
ts.setup {
highlight = {
enable = true
},
indent = {
enable = true
},
playground = {
enable = true,
disable = {},
updatetime = 25,
persist_queries = false,
keybindings = {
toggle_query_editor = 'o',
toggle_hl_groups = 'i',
toggle_injected_languages = 't',
toggle_anonymous_nodes = 'a',
toggle_language_display = 'I',
focus_language = 'f',
unfocus_language = 'F',
update = 'R',
goto_node = '<cr>',
show_help = '?',
},
}
}
you can safely ignore the playground option, it just helps with debugging parsing issues once in a while.
Ahh that was it!
I didn't have highlight
defined.
Thank you so much!
Is your feature request related to a problem? Please describe. I've noticed recently neovim opens tf files as
filetype=terraform
, I'm not sure when this change was made. As a result tree-sitter doesn't pick up this parser unless Iset syntax=tf
.Describe the solution you'd like Would it be possible to add
terraform
as a supported filetype in package.json?