treesitter cleanup

This commit is contained in:
Tiago Sousa 2024-02-15 14:26:53 +00:00
parent 83ae9b72b7
commit 53fa827fd9

View file

@ -12,34 +12,7 @@ return {
require("lazy.core.loader").add_to_rtp(plugin) require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates") require("nvim-treesitter.query_predicates")
end, end,
dependencies = { dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" },
{
"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,
},
},
opts = { opts = {
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
@ -94,11 +67,10 @@ return {
"romgrk/nvim-treesitter-context", "romgrk/nvim-treesitter-context",
config = function() config = function()
require("treesitter-context").setup({ require("treesitter-context").setup({
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
throttle = true, -- Throttles plugin updates (may improve performance) throttle = true, -- Throttles plugin updates (may improve performance)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
show_all_context = false, show_all_context = false,
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
-- For all filetypes -- For all filetypes
-- Note that setting an entry here replaces all other patterns for this entry. -- Note that setting an entry here replaces all other patterns for this entry.
-- By setting the 'default' entry below, you can control which nodes you want to -- By setting the 'default' entry below, you can control which nodes you want to