60 lines
1.4 KiB
Lua
60 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",
|
|
"typst",
|
|
"regex",
|
|
},
|
|
}
|
|
|
|
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 },
|
|
}
|