feat(#2994): add visual selection operations#3268
Open
v3ceban wants to merge 2 commits intonvim-tree:masterfrom
Open
feat(#2994): add visual selection operations#3268v3ceban wants to merge 2 commits intonvim-tree:masterfrom
v3ceban wants to merge 2 commits intonvim-tree:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds first-class visual selection support to nvim-tree, allowing users to use V + motion to select a range of nodes and operate on them with a single keypress. The implementation includes support for toggle bookmark, copy, cut, delete, and trash operations on visually selected nodes.
Changes:
- Added visual mode keybindings (
m,c,x,d,D) for operating on visual selections - Implemented
Explorer:get_nodes_in_range()to retrieve all nodes within a visual selection - Created bulk operation functions
bulk_delete_nodes()andbulk_trash_nodes()with single confirmation prompts - Added descendant filtering to prevent errors when both a directory and its children are selected
- Updated help system to display visual mode keymaps with
[v]prefix
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/nvim-tree/marks/init.lua | Adds filter_descendant_nodes, bulk_delete_nodes, and bulk_trash_nodes functions for visual selection operations |
| lua/nvim-tree/explorer/init.lua | Implements get_nodes_in_range method to retrieve nodes within a line range |
| lua/nvim-tree/api/impl/post.lua | Adds wrap_visual_range and wrap_visual_bulk wrapper functions and wires up visual API endpoints |
| lua/nvim-tree/keymap.lua | Defines default visual mode keymaps (x mode) for visual operations |
| lua/nvim-tree/help.lua | Prefixes visual mode keymaps with [v] in help window |
| lua/nvim-tree/_meta/api/marks.lua | Adds type annotation for toggle_visual function |
| lua/nvim-tree/_meta/api/fs.lua | Adds type annotations for visual, cut_visual, remove_visual, and trash_visual functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use utils.path_separator for cross-platform path handling in descendant node filtering - Filter out ".." parent directory entries to prevent unsafe deletions/trashes of parent directories - Respect ui.confirm.default_yes configuration in bulk delete and trash operations for consistency with single-node behavior
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.
Add visual selection operations
Closes #2994
See also: #2993
Summary
Adds first-class visual selection support to nvim-tree. Users can now
V+ motion to select a range of nodes and operate on them with a single keypress -- matching standard Vim visual mode behavior.Supported operations:
m)c)x)d) -- single confirmation prompt for the entire selectionD) -- single confirmation prompt for the entire selectionNew API
api.marks.toggle_visualapi.fs.copy.visualapi.fs.cut_visualapi.fs.remove_visualapi.fs.trash_visualDesign
vim.fn.line("v")/vim.fn.line(".")while inxmode, avoiding<Esc>+'</'>marks.Explorer:get_nodes_in_range()reuses the existingget_nodes_by_line()infrastructure.nvim_feedkeyswith"nx"flags) before any operation executes.g?help window prefixes visual mode keymaps with[v]to distinguish them from normal mode.Files Changed
explorer/init.lua--Explorer:get_nodes_in_range(start_line, end_line)marks/init.lua--filter_descendant_nodes(),bulk_delete_nodes(),bulk_trash_nodes()api/impl/post.lua--wrap_visual_range(),wrap_visual_bulk(), API wiring_meta/api/fs.lua,_meta/api/marks.lua-- type annotationskeymap.lua-- default visual mode keymaps inon_attach_defaulthelp.lua--[v]prefix for visual mode keymaps