77 lines
2.7 KiB
Lua
77 lines
2.7 KiB
Lua
-- Treesitter
|
|
-- NOTE: After updating, wipe old plugin cache then reinstall:
|
|
-- rm -rf ~/.local/share/nvim/lazy/nvim-treesitter
|
|
-- rm -rf ~/.local/share/nvim/lazy/nvim-treesitter-textobjects
|
|
-- Then open Neovim and run :Lazy restore
|
|
return {
|
|
{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
branch = "main",
|
|
lazy = false,
|
|
build = ":TSUpdate",
|
|
enabled = true,
|
|
config = function()
|
|
require("nvim-treesitter")
|
|
.install({
|
|
"lua",
|
|
"comment", -- used for TODO:, FIXME:, XXX: and NOTE:
|
|
"vim",
|
|
"vimdoc",
|
|
"bash",
|
|
"diff",
|
|
"make",
|
|
"gitignore",
|
|
"gitcommit",
|
|
"markdown",
|
|
"markdown_inline",
|
|
"rst",
|
|
"latex",
|
|
"elixir",
|
|
"eex",
|
|
"heex",
|
|
"yaml",
|
|
"html",
|
|
"css",
|
|
"javascript",
|
|
"dockerfile",
|
|
"query",
|
|
"hcl",
|
|
"terraform",
|
|
"bicep",
|
|
"csv",
|
|
"properties",
|
|
"ini",
|
|
"python",
|
|
"regex",
|
|
"json",
|
|
"go",
|
|
"gomod",
|
|
"gosum",
|
|
"editorconfig",
|
|
"http",
|
|
"toml",
|
|
"sql",
|
|
"promql",
|
|
"nginx",
|
|
"powershell",
|
|
})
|
|
:wait(300000) -- wait max. 5 min
|
|
|
|
-- Highlight & indent are built into Neovim 0.11+
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
callback = function()
|
|
if pcall(vim.treesitter.start) then
|
|
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
|
end
|
|
end,
|
|
})
|
|
|
|
-- Incremental node selection (Neovim 0.12+, see :help v_an v_in)
|
|
-- Built-in: an = expand to parent, in = shrink to child
|
|
-- mini.ai's `an`/`in` next/last mappings must be disabled (see mini.lua)
|
|
vim.keymap.set("n", "<C-s>", "van", { desc = "Treesitter: init selection", remap = true })
|
|
vim.keymap.set("v", "<C-s>", "an", { desc = "Treesitter: expand selection", remap = true })
|
|
vim.keymap.set("v", "<bs>", "in", { desc = "Treesitter: shrink selection", remap = true })
|
|
end,
|
|
},
|
|
}
|