Files
nvim/lua/plugins/treesitter.lua
T
johannes 9b0446c5f6 feat: initial commit
- basic config according to spec
2026-11-05 15:04:29 +01:00

58 lines
1.4 KiB
Lua

-- nvim-treesitter (main branch) only installs parsers. Highlighting, folds and
-- indent are started natively per buffer.
local parsers = {
slim = { "lua", "nix", "bash", "yaml", "json", "markdown" },
full = {
"lua",
"vim",
"vimdoc",
"query",
"nix",
"bash",
"yaml",
"json",
"toml",
"markdown",
"markdown_inline",
"rust",
"go",
"gomod",
"typescript",
"tsx",
"javascript",
"python",
"php",
"html",
"css",
"dockerfile",
"gitcommit",
"diff",
},
}
return {
{
"nvim-treesitter/nvim-treesitter",
branch = "main",
lazy = false, -- main branch does not support lazy loading
build = ":TSUpdate",
config = function()
require("nvim-treesitter").install(parsers[vim.g.profile])
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("plugins.treesitter", { clear = true }),
callback = function(ev)
if vim.b[ev.buf].bigfile or not pcall(vim.treesitter.start, ev.buf) then
return
end
vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end,
})
end,
},
-- Supplies @function/@class queries; mini.ai builds the text objects.
{ "nvim-treesitter/nvim-treesitter-textobjects", branch = "main", lazy = true },
}