dotfiles/nvim/.config/nvim/lua/plugins/treesitter.lua
Marty Oehme c45d85922b
nvim: Fix wrong lazy.nvim plugin spec options
Some options were left over from old plugin managers, some were just
used wrong.
2024-06-17 13:34:00 +02:00

103 lines
2.8 KiB
Lua

return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
-- show current cursor context at top of buffer
-- improves commenting plugin above by using ts
dependencies = {
{ "romgrk/nvim-treesitter-context", config = true },
"JoosepAlviste/nvim-ts-context-commentstring",
"RRethy/nvim-treesitter-textsubjects",
"windwp/nvim-ts-autotag",
"RRethy/nvim-treesitter-endwise",
-- rainbow brackets using treesitter
{
"HiPhish/rainbow-delimiters.nvim",
config = function()
require("rainbow-delimiters.setup").setup({})
end,
},
},
config = function()
require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all",
auto_install = true,
highlight = {
enable = true,
language_tree = true,
disable = function(_, bufnr)
if
vim.api.nvim_buf_line_count(bufnr) > 1000
or vim.fn.strwidth(vim.fn.getline(".")) > 300
or vim.fn.getfsize(vim.fn.expand("%")) > 1024 * 1024
then
return true
end
return false
end,
additional_vim_regex_highlighting = false,
},
incremental_selection = { enable = true },
textobjects = { enable = true },
indent = { enable = true },
autotag = { enable = true },
-- allows using . and ; to target treesitter branches
textsubjects = {
enable = true,
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
},
},
endwise = {
enable = true,
},
})
-- for improved commentstrings, needs corresponding plugin
require("ts_context_commentstring").setup({
enable = true,
enable_autocmd = false, -- since we run it as a hook from the mini.comment plugin
languages = {
nu = "# %s",
},
})
-- treesitter parser for nushell. To fully get e.g. syntax highlight
-- working you need a highlight file too. For now I installed manually, see:
-- https://github.com/nushell/tree-sitter-nu/blob/main/installation/neovim.md
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.nu = {
install_info = {
url = "https://github.com/nushell/tree-sitter-nu",
files = { "src/parser.c" },
branch = "main",
},
filetype = "nu",
}
end,
event = { "VeryLazy" },
cmd = {
"TSBufDisable",
"TSBufEnable",
"TSBufToggle",
"TSDisable",
"TSEnable",
"TSToggle",
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSModuleInfo",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
},
keys = {
{ "<leader>si", "<cmd>Inspect<cr>", desc = "treesitter element", silent = true },
{ "<leader>sI", "<cmd>InspectTree<cr>", desc = "treesitter tree", silent = true },
},
},
}