Feat(tree): add the ability to fold and unfold (recursively) tree nodes.#293
Merged
esmuellert merged 10 commits intoesmuellert:mainfrom Mar 5, 2026
Merged
Feat(tree): add the ability to fold and unfold (recursively) tree nodes.#293esmuellert merged 10 commits intoesmuellert:mainfrom
esmuellert merged 10 commits intoesmuellert:mainfrom
Conversation
Deduplicate fold actions (open/close/toggle + recursive + all variants), update_tree_view, fold_bindings table, and keymap registration loop that were nearly identical in explorer/actions.lua and history/keymaps.lua. Also adds fold keymaps to config defaults, keymap help, and Node methods (is_foldable, expand/collapse_recursively) to the tree library. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Vim-style fold/unfold keymaps to the explorer and history tree views, backed by a reusable fold utility and small tree node API extensions to support recursive expand/collapse.
Changes:
- Introduce
tree-utilshelper to set up fold keymaps (zo,zO,zc,zC,za,zA,zR,zM) for tree buffers. - Extend tree node API with
is_foldable,expand_recursively, andcollapse_recursively. - Expose fold keymaps in config defaults and display them in the keymap help UI.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/codediff/ui/lib/tree.lua | Adds foldability detection and recursive expand/collapse methods on tree nodes. |
| lua/codediff/ui/lib/tree-utils.lua | New shared utility to find foldable nodes and register fold keymaps for tree panels. |
| lua/codediff/ui/explorer/keymaps.lua | Wires fold keymap setup into explorer panel keymaps. |
| lua/codediff/ui/history/keymaps.lua | Wires fold keymap setup into history panel keymaps. |
| lua/codediff/config.lua | Adds configurable fold key defaults for explorer and history. |
| lua/codediff/ui/keymap_help.lua | Displays the new fold keymaps in the help window. |
| CLAUDE.md | Adds repo guidance for Claude Code usage and common dev commands. |
Contributor
Author
|
@esmuellert I also need to remove Claude.md |
- Rename tree-utils.lua to tree_utils.lua (snake_case convention) - Update all require() calls in explorer and history keymaps - Add nil guards in find_foldable_node() and get_root_node() - Retrieve winid dynamically via vim.fn.bufwinid() instead of passing it - Fix set_expanded_recursively() logic (was skipping foldable nodes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CLAUDE.md is a local-only file for Claude Code guidance. Remove it from git tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover is_foldable() for all node types (group, directory, commit, title, file, and untyped). Cover expand_recursively() and collapse_recursively() propagation rules, including the history scenario where commit nodes are non-foldable. Cover interaction with render() to verify buffer output reflects fold state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document fold keymaps (zo/zO/zc/zC/za/zA/zR/zM) for explorer and history panels, history refresh keymap (R), and conflict accept-all shortcuts (cT/cO/cB/cX). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a warning notification with source location when a fold binding key is missing from the keymaps config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract keymaps[binding.key] into a local variable and check for nil specifically, so that false can be used to intentionally disable a fold keymap without triggering a warning. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove vim.notify warning when a fold keymap is nil/disabled. This matches the existing codebase convention where missing keymaps are silently skipped (e.g. explorer/history keymap setup). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add fold keymap entries (zo/zO/zc/zC/za/zA/zR/zM) to explorer and history sections in codediff.txt vimdoc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds Vim-style fold keymaps for tree views in both the explorer and history panels, making it easier to expand and collapse directory and group nodes. It introduces a reusable utility for fold operations, updates configuration and help documentation, and extends the tree node API to support recursive folding.
Fold keymap support and tree utilities
lua/codediff/ui/lib/tree_utils.luathat provides functions to set up fold keymaps (zo,zO,zc,zC,za,zA,zR,zM) and helpers to find foldable nodes and operate on tree roots. This module is now used in both explorer and history keymap setup.lua/codediff/ui/explorer/keymaps.lua,lua/codediff/ui/history/keymaps.lua) to calltree_utils.setup_fold_keymaps, enabling fold operations in both panels. [1] [2] [3] [4]Tree node API enhancements
lua/codediff/ui/lib/tree.lua) with new methods:is_foldable,expand_recursively, andcollapse_recursively, allowing recursive expand/collapse for group and directory nodes. [1] [2]Configuration and documentation updates
lua/codediff/config.lua) under bothexplorerandhistorykeymap tables, making them customizable.lua/codediff/ui/keymap_help.lua) to display descriptions for all new fold keymaps in explorer and history panels. [1] [2]Fix: #278
(automatically generated by Github)