mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-28 19:50:09 +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
|
||||
config = function(_, opts)
|
||||
if type(opts.ensure_installed) == "table" then
|
||||
---@type table<string, boolean>
|
||||
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)
|
||||
opts.ensure_installed = LazyVim.dedup(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,
|
||||
event = "VeryLazy",
|
||||
enabled = true,
|
||||
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
|
||||
-- vim text objects c & C instead of the treesitter ones.
|
||||
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue