NeoVimConfiguration/lua/plugins/treesitter.lua
2026-03-03 13:59:31 +00:00

27 lines
918 B
Lua

return {
'nvim-treesitter/nvim-treesitter',
lazy = false,
build = ':TSUpdate',
config = function()
-- Auto launch tree-sitter
local ts = require('nvim-treesitter')
vim.api.nvim_create_autocmd('FileType', {
pattern = ts.get_available(),
callback = function(event)
-- Auto install languages
if event.match ~= ts.get_installed() then
ts.install({ event.match }):wait(30000) -- 30 sec timeout
end
-- syntax highlighting, provided by Neovim
vim.treesitter.start()
-- Use regex highlighting as well as tree-sitter
vim.bo.syntax = event.match
-- folds, provided by Neovim
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.wo.foldmethod = 'expr'
-- indentation, provided by nvim-treesitter
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
end
}