Neovim/lua/plugins/treesitter.lua

35 lines
1.3 KiB
Lua

return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = {
"VeryLazy"
},
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,
opts = {
auto_install = true,
highlight = {
enable = true,
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,
}
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end
}
}