From 16713e6e1200eb90ad4b4a394bb7254fb5612484 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:11:09 +0200 Subject: [PATCH] fix(treesitter): fix `]c` textobject mappings when in diff mode (#6911) ## Description It seems that after https://github.com/LazyVim/LazyVim/commit/5985ca0cf1a0c1ddee8b2b718c730f988cec7001 the default `]c` Neovim mapping in diff mode broke. This is an attempt to fix that. ## Related Issue(s) None, rather discussion #6910. ## Screenshots ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- lua/lazyvim/plugins/treesitter.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index eb3ebf61..6de91b30 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -180,15 +180,16 @@ return { local desc = table.concat(parts, " or ") desc = (key:sub(1, 1) == "[" and "Prev " or "Next ") .. desc desc = desc .. (key:sub(2, 2) == key:sub(2, 2):upper() and " End" or " Start") - if not (vim.wo.diff and key:find("[cC]")) then - vim.keymap.set({ "n", "x", "o" }, key, function() - require("nvim-treesitter-textobjects.move")[method](query, "textobjects") - end, { - buffer = buf, - desc = desc, - silent = true, - }) - end + vim.keymap.set({ "n", "x", "o" }, key, function() + if vim.wo.diff and key:find("[cC]") then + return vim.cmd("normal! " .. key) + end + require("nvim-treesitter-textobjects.move")[method](query, "textobjects") + end, { + buffer = buf, + desc = desc, + silent = true, + }) end end end