Files
dotfiles/.config/nvim/lua/jirr02/plugins/treesitter.lua
T
2026-11-07 19:46:22 +01:00

56 lines
1.3 KiB
Lua

return {
{
"romus204/tree-sitter-manager.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local tsm = require("tree-sitter-manager")
-- 1. Manage Parser Files
tsm.setup({
ensure_installed = {
"python",
"cpp",
"lua",
"markdown",
"markdown_inline",
"html",
"css",
"bash",
"zsh",
"latex",
"r",
},
})
-- 2. Enable Native Highlighting Engine
vim.api.nvim_create_autocmd("FileType", {
callback = function(args)
local bufnr = args.buf
local ft = vim.bo[bufnr].filetype
-- Filter out common "non-code" or problematic filetypes
local ignore_ft = { "noice", "prompt", "TelescopePrompt", "notify" }
for _, v in ipairs(ignore_ft) do
if ft == v then
return
end
end
-- Try to get the language for the filetype
local lang = vim.treesitter.language.get_lang(ft)
-- ONLY start if we have a valid language AND the parser is actually installed
if lang then
-- pcall (protected call) prevents the "Parser could not be created" error
-- from popping up in your face if the parser is missing/corrupted.
local ok, _ = pcall(vim.treesitter.start, bufnr, lang)
if ok then
vim.opt_local.indentexpr = "v:lua.vim.treesitter.indentexpr()"
end
end
end,
})
end,
},
}