fixed folding -- again

This commit is contained in:
Mathias Schneider
2026-04-15 18:28:02 +02:00
parent 814860ca63
commit 392f1b7861
3 changed files with 92 additions and 37 deletions
+48 -28
View File
@@ -3,36 +3,56 @@ return {
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
config = function()
-- Ensure nvim-treesitter queries are preferred over runtime queries
-- This fixes the "except*" syntax error with updated parsers
vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/lazy/nvim-treesitter")
-- In the latest nvim-treesitter (post-refactor), the plugin only handles
-- parser installation. Highlighting, folding, and indenting are handled
-- by native Neovim Treesitter integration.
local ok, configs = pcall(require, "nvim-treesitter.configs")
-- 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
configs.setup({
auto_install = true,
ensure_installed = {
"python",
"lua",
"json",
"yaml",
"javascript",
"typescript",
"tsx",
"vue",
"html",
"css",
"bash",
"markdown",
"markdown_inline",
},
highlight = {
enable = true,
-- Disable additional_vim_regex_highlighting to avoid conflicts
additional_vim_regex_highlighting = false,
},
indent = { enable = true },
})
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,
}