37 lines
1.1 KiB
Lua
37 lines
1.1 KiB
Lua
-- Highlight, edit, and navigate code
|
|
return {
|
|
'nvim-treesitter/nvim-treesitter',
|
|
lazy = false,
|
|
build = ':TSUpdate',
|
|
branch = 'main',
|
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
|
|
config = function()
|
|
require('nvim-treesitter').install(Langs.treesitter)
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
callback = function(args)
|
|
local buf, filetype = args.buf, args.match
|
|
|
|
local language = vim.treesitter.language.get_lang(filetype)
|
|
if not language then
|
|
return
|
|
end
|
|
|
|
-- check if parser exists and load it
|
|
if not vim.treesitter.language.add(language) then
|
|
return
|
|
end
|
|
-- enables syntax highlighting and other treesitter features
|
|
vim.treesitter.start(buf, language)
|
|
|
|
-- enables treesitter based folds
|
|
-- for more info on folds see `:help folds`
|
|
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
|
-- vim.wo.foldmethod = 'expr'
|
|
|
|
-- enables treesitter based indentation
|
|
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
|
end,
|
|
})
|
|
end,
|
|
}
|