mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-29 20:14:36 +02:00
fix(treesitter): refactored treesitter code and fixed nvim-treesitter-textobjects
This commit is contained in:
parent
4bc9389bb5
commit
fe552853f5
1 changed files with 9 additions and 13 deletions
|
@ -74,27 +74,23 @@ return {
|
||||||
---@param opts TSConfig
|
---@param opts TSConfig
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
if type(opts.ensure_installed) == "table" then
|
if type(opts.ensure_installed) == "table" then
|
||||||
---@type table<string, boolean>
|
opts.ensure_installed = LazyVim.dedup(opts.ensure_installed)
|
||||||
local added = {}
|
|
||||||
opts.ensure_installed = vim.tbl_filter(function(lang)
|
|
||||||
if added[lang] then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
added[lang] = true
|
|
||||||
return true
|
|
||||||
end, opts.ensure_installed)
|
|
||||||
end
|
end
|
||||||
require("nvim-treesitter.configs").setup(opts)
|
require("nvim-treesitter.configs").setup(opts)
|
||||||
vim.schedule(function()
|
|
||||||
require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } })
|
|
||||||
end)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
lazy = true,
|
event = "VeryLazy",
|
||||||
|
enabled = true,
|
||||||
config = function()
|
config = function()
|
||||||
|
-- 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
|
-- When in diff mode, we want to use the default
|
||||||
-- vim text objects c & C instead of the treesitter ones.
|
-- vim text objects c & C instead of the treesitter ones.
|
||||||
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue