Skip to content

[audit] ]c/[c class-jump keymaps shadow vimdiff's built-in diff-hunk navigation #116

Description

@stanfish06

What

lua/config/plugin_config.lua lines 222–226 bind ]c and [c to treesitter-textobjects class navigation:

vim.keymap.set({ "n", "x", "o" }, "]c", function()
    move.goto_next_start("@class.outer", "textobjects")
end, { desc = "Next class start" })
vim.keymap.set({ "n", "x", "o" }, "[c", function()
    move.goto_previous_start("@class.outer", "textobjects")
end, { desc = "Prev class start" })

Where

lua/config/plugin_config.lua, lines 222–226.

Why it matters

:help ]c]c / [c are Neovim/Vim built-in normal-mode keymaps for jumping to the next/previous diff hunk in a vimdiff or diff buffer. These mappings apply globally in normal mode, so after the textobjects plugin loads, pressing ]c / [c in a diff buffer navigates classes instead of diff hunks — making vimdiff navigation broken.

Important side-effect on the existing ]g workaround: plugin_config.lua lines 191–204 route ]gnormal! ]c when vim.wo.diff is true. That normal! bypasses user maps, so it still hits the built-in correctly. However, anyone pressing ]c directly (muscle-memory from years of vimdiff use) gets class navigation, not diff navigation — with no warning.

Recommended action

Rename the class-jump bindings to keys that don't conflict with diff navigation. Common alternatives:

Current Suggested Meaning
]c / [c ]t / [t type/class
]c / [c ]k / [k arbitrary free keys

Or guard the binding so it only activates outside diff mode:

vim.keymap.set("n", "]c", function()
    if vim.wo.diff then
        vim.cmd("normal! ]c")
    else
        move.goto_next_start("@class.outer", "textobjects")
    end
end, { desc = "Next class start (or diff hunk in diff mode)" })

The guard approach keeps muscle memory for both workflows at the cost of a small runtime check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions