Skip to content

Commit 803de03

Browse files
committed
fix(treesitter_userconfig): update parser and filetype lists for treesitter installation and folding
Added additional parsers to ensure_installed and introduced a separate vim_filetypes list for accurate FileType autocmd pattern matching. This improves folding and syntax support for more filetypes.
1 parent bd21a57 commit 803de03

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

after/plugin/treesitter_userconfig.lua

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,45 @@ local ensure_installed = {
2626
'markdown',
2727
'markdown_inline',
2828
'python',
29+
'sh',
2930
'sql',
3031
'terraform',
3132
'toml',
33+
'tsx',
3234
'typescript',
3335
'vim',
3436
'yaml',
3537
'zsh',
3638
}
37-
treesitter.install({ ensure_installed })
39+
treesitter.install(ensure_installed)
40+
-- this is not always the same as treesitter parser names
41+
local vim_filetypes = {
42+
'css',
43+
'diff',
44+
'fish',
45+
'go',
46+
'graphql',
47+
'html',
48+
'ini',
49+
'javascript',
50+
'javascriptreact',
51+
'json',
52+
'lua',
53+
'make',
54+
'markdown',
55+
'python',
56+
'sh', -- treesitter parser 'bash', but filetype is 'sh'
57+
'sql',
58+
'terraform',
59+
'toml',
60+
'typescript',
61+
'typescriptreact',
62+
'vim',
63+
'yaml',
64+
'zsh',
65+
}
3866
vim.api.nvim_create_autocmd('FileType', {
39-
pattern = ensure_installed,
67+
pattern = vim_filetypes,
4068
callback = function()
4169
vim.opt.foldmethod = 'expr'
4270
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'

0 commit comments

Comments
 (0)