112 lines
3.1 KiB
Lua
112 lines
3.1 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 = {
|
|
-- nice context on top of buffer
|
|
{ "nvim-treesitter/nvim-treesitter-context", opts = { max_lines = 3 } },
|
|
"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,
|
|
},
|
|
{ "nushell/tree-sitter-nu", version = false },
|
|
},
|
|
version = false, -- TODO: Can be set to versioned if new version after 2024-12-12 is released
|
|
config = function()
|
|
---@diagnostic disable-next-line: missing-fields (seems an issue in the diagnostic)
|
|
require("nvim-treesitter.configs").setup({
|
|
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
|
ensure_installed = "all",
|
|
ignore_install = {},
|
|
sync_install = false,
|
|
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,
|
|
-- TODO: CHECK IF ANY CONFLICTING WITH MINI AI!!
|
|
-- supported in other languages as well
|
|
["aF"] = "@function.outer",
|
|
["iF"] = "@function.inner",
|
|
["aL"] = "@loop.outer",
|
|
["iL"] = "@loop.inner",
|
|
["aC"] = "@conditional.outer",
|
|
["iC"] = "@conditional.inner",
|
|
["iS"] = "@statement.inner",
|
|
["aS"] = "@statement.outer",
|
|
|
|
-- Nushell only
|
|
["aP"] = "@pipeline.outer",
|
|
["iP"] = "@pipeline.inner",
|
|
},
|
|
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",
|
|
},
|
|
})
|
|
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 },
|
|
},
|
|
},
|
|
}
|