59 lines
1.6 KiB
Lua
59 lines
1.6 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",
|
|
})
|
|
|
|
-- 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",
|
|
}
|
|
|
|
-- 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
|
|
|
|
-- Enable Treesitter-based indenting (natively supported by Neovim)
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = "*",
|
|
callback = function()
|
|
if vim.bo.buftype == "" and vim.bo.filetype ~= "" then
|
|
vim.bo.indentexpr = "v:lua.vim.treesitter.indentexpr()"
|
|
end
|
|
end,
|
|
desc = "Enable Treesitter indenting",
|
|
})
|
|
end,
|
|
}
|