.dotfiles/.config/nvim/lua/plugins/treesitter.lua
2026-02-26 01:45:57 +02:00

78 lines
1.5 KiB
Lua

vim.pack.add({ { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "master" } })
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = {
"bash",
"blade",
"c",
"comment",
"css",
"diff",
"dockerfile",
"fish",
"gitcommit",
"gitignore",
"go",
"gomod",
"gosum",
"gowork",
"html",
"ini",
"javascript",
"jsdoc",
"json",
"lua",
"luadoc",
"luap",
"make",
"markdown",
"markdown_inline",
"nginx",
"nix",
"proto",
"python",
"query",
"regex",
"rust",
"scss",
"sql",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"xml",
"yaml",
"zig",
},
auto_install = true,
sync_install = true,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<CR>",
scope_incremental = "<CR>",
node_incremental = "<TAB>",
node_decremental = "<S-TAB>",
},
},
})
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" then
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,
})