2023-11-17 11:24:21 +00:00
|
|
|
return {
|
|
|
|
{
|
|
|
|
"nvim-treesitter/nvim-treesitter",
|
|
|
|
build = ":TSUpdate",
|
2024-02-23 18:23:02 +00:00
|
|
|
event = {
|
|
|
|
"VeryLazy"
|
2023-11-17 11:24:21 +00:00
|
|
|
},
|
2024-02-25 17:12:48 +00:00
|
|
|
dependencies = {
|
|
|
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
|
|
|
},
|
2024-02-23 18:23:02 +00:00
|
|
|
init = function(plugin)
|
|
|
|
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
|
|
|
|
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
|
|
|
|
-- no longer trigger the **nvim-treeitter** module to be loaded in time.
|
|
|
|
-- Luckily, the only thins that those plugins need are the custom queries, which we make available
|
|
|
|
-- during startup.
|
|
|
|
require("lazy.core.loader").add_to_rtp(plugin)
|
|
|
|
require("nvim-treesitter.query_predicates")
|
|
|
|
end,
|
2023-11-17 11:24:21 +00:00
|
|
|
opts = {
|
2024-02-23 18:23:02 +00:00
|
|
|
auto_install = true,
|
2023-11-17 11:24:21 +00:00
|
|
|
highlight = {
|
|
|
|
enable = true,
|
2024-02-23 18:23:02 +00:00
|
|
|
disable = function(_, buf)
|
|
|
|
local max_filesize = 1000 * 1024 -- 1 MB
|
|
|
|
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
|
|
|
if ok and stats and stats.size > max_filesize then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
2024-02-25 17:12:48 +00:00
|
|
|
},
|
|
|
|
indent = {
|
|
|
|
enable = true
|
|
|
|
},
|
|
|
|
autotag = {
|
|
|
|
enable = true
|
|
|
|
},
|
|
|
|
textobjects = {
|
|
|
|
move = {
|
|
|
|
enable = true,
|
|
|
|
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
|
|
|
|
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
|
|
|
|
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
|
|
|
|
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
|
|
|
|
},
|
|
|
|
},
|
2023-11-17 11:24:21 +00:00
|
|
|
},
|
|
|
|
config = function(_, opts)
|
|
|
|
require("nvim-treesitter.configs").setup(opts)
|
2024-02-23 18:23:02 +00:00
|
|
|
end
|
2023-11-17 11:24:21 +00:00
|
|
|
}
|
|
|
|
}
|