mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-14 19:34:36 +02:00
perf(treesitter): dont let nvim-treesitter-textobjects stall loading treesitter
This commit is contained in:
parent
39901c1f00
commit
8301096c31
1 changed files with 30 additions and 27 deletions
|
@ -16,33 +16,6 @@ return {
|
|||
require("lazy.core.loader").add_to_rtp(plugin)
|
||||
require("nvim-treesitter.query_predicates")
|
||||
end,
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
config = function()
|
||||
-- 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,
|
||||
},
|
||||
},
|
||||
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
|
||||
keys = {
|
||||
{ "<c-space>", desc = "Increment Selection" },
|
||||
|
@ -111,6 +84,36 @@ return {
|
|||
end, opts.ensure_installed)
|
||||
end
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
vim.schedule(function()
|
||||
require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } })
|
||||
end)
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
lazy = true,
|
||||
config = function()
|
||||
-- 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,
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue