69 lines
1.7 KiB
Lua
69 lines
1.7 KiB
Lua
return {
|
|
"nvim-treesitter/nvim-treesitter",
|
|
build = ":TSUpdate",
|
|
event = { "BufReadPost", "BufNewFile" },
|
|
config = function()
|
|
-- In the latest nvim-treesitter (post-refactor), the plugin only handles
|
|
-- parser installation. Highlighting, folding, and indenting are handled
|
|
-- by native Neovim Treesitter integration.
|
|
|
|
-- CRITICAL: Add nvim-treesitter/runtime to runtimepath so queries are found
|
|
local ts_runtime = vim.fn.stdpath("data") .. "/lazy/nvim-treesitter/runtime"
|
|
vim.opt.runtimepath:prepend(ts_runtime)
|
|
|
|
-- Setup nvim-treesitter (minimal config for parser installation)
|
|
require("nvim-treesitter").setup({
|
|
-- Parser installation directory (default: stdpath('data')/site)
|
|
install_dir = vim.fn.stdpath("data") .. "/site",
|
|
})
|
|
|
|
-- Enable Treesitter-based indenting (selective)
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "*",
|
|
callback = function()
|
|
local exclude = { "python" }
|
|
for _, lang in ipairs(exclude) do
|
|
if vim.bo.filetype == lang then
|
|
return
|
|
end
|
|
end
|
|
|
|
if vim.bo.buftype == "" and vim.bo.filetype ~= "" then
|
|
pcall(function()
|
|
vim.bo.indentexpr = "v:lua.vim.treesitter.indentexpr()"
|
|
end)
|
|
end
|
|
end,
|
|
desc = "Enable Treesitter indenting (selective)",
|
|
})
|
|
|
|
-- Auto-install parsers for these languages when opening a file
|
|
local ensure_installed = {
|
|
"python",
|
|
"lua",
|
|
"json",
|
|
"yaml",
|
|
"javascript",
|
|
"typescript",
|
|
"tsx",
|
|
"vue",
|
|
"html",
|
|
"css",
|
|
"bash",
|
|
"markdown",
|
|
"markdown_inline",
|
|
"rust",
|
|
}
|
|
|
|
-- Install parsers
|
|
local ok, install = pcall(require, "nvim-treesitter.install")
|
|
if ok then
|
|
for _, lang in ipairs(ensure_installed) do
|
|
vim.schedule(function()
|
|
install.install({ lang })
|
|
end)
|
|
end
|
|
end
|
|
end,
|
|
}
|