init.lua/lua/plugins/treesitter.lua

25 lines
1 KiB
Lua

vim.pack.add({
{ src = "https://github.com/nvim-treesitter/nvim-treesitter" },
})
---@diagnostic disable: missing-fields
require 'nvim-treesitter'.setup {}
require 'nvim-treesitter'.install { 'go', 'nix', 'lua', 'json', 'html', 'markdown_inline', 'python', 'bash', 'zsh', 'just', 'yaml' }
-- run tsupdate when updating nvim-treesitter
vim.api.nvim_create_autocmd('PackChanged', {
desc = 'Handle nvim-treesitter updates',
group = vim.api.nvim_create_augroup('nvim-treesitter-pack-changed-update-handler', { clear = true }),
callback = function(event)
if event.data.kind == 'update' and event.data.spec.name == 'nvim-treesitter' then
vim.notify('nvim-treesitter updated, running TSUpdate...', vim.log.levels.INFO)
---@diagnostic disable-next-line: param-type-mismatch
local ok = pcall(vim.cmd, 'TSUpdate')
if ok then
vim.notify('TSUpdate completed successfully!', vim.log.levels.INFO)
else
vim.notify('TSUpdate command not available yet, skipping', vim.log.levels.WARN)
end
end
end,
})