use treesitter main

This commit is contained in:
OneOfOne 2025-07-14 15:21:54 -05:00
parent 25abbf546d
commit 821739677d
No known key found for this signature in database
GPG key ID: A3A69A4098CA8173

View file

@ -25,7 +25,6 @@ return {
-- Luckily, the only things that those plugins need are the custom queries, which we make available -- Luckily, the only things that those plugins need are the custom queries, which we make available
-- during startup. -- during startup.
require("lazy.core.loader").add_to_rtp(plugin) require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end, end,
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
keys = { keys = {
@ -88,40 +87,18 @@ return {
if type(opts.ensure_installed) == "table" then if type(opts.ensure_installed) == "table" then
opts.ensure_installed = LazyVim.dedup(opts.ensure_installed) opts.ensure_installed = LazyVim.dedup(opts.ensure_installed)
end end
require("nvim-treesitter.configs").setup(opts) require("nvim-treesitter").install(opts.ensure_installed)
end, -- register and start parsers for filetypes
}, for _, parser in ipairs(opts.ensure_installed) do
local filetypes = parser -- In this case, parser is the filetype/language name
vim.treesitter.language.register(parser, filetypes)
{ vim.api.nvim_create_autocmd({ "FileType" }, {
"nvim-treesitter/nvim-treesitter-textobjects", pattern = filetypes,
event = "VeryLazy", callback = function(event)
enabled = true, vim.treesitter.start(event.buf, parser)
config = function() end,
-- If treesitter is already loaded, we need to run config again for textobjects })
if LazyVim.is_loaded("nvim-treesitter") then
local opts = LazyVim.opts("nvim-treesitter")
require("nvim-treesitter.configs").setup({ textobjects = opts.textobjects })
end
-- When in diff mode, we want to use the default
-- vim text objects c & C instead of the treesitter ones.
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end
return fn(q, ...)
end
end
end end
end, end,
}, },