Repository navigation
feat: add file navigation mappings to jump to file under cursor from terminal - #676
Open
franckspike wants to merge 1 commit into
Open
franckspike wants to merge 1 commit into
franckspike wants to merge 1 commit into
Conversation
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.
Description :
Problem
When running compilers, tests, linters, or scripts in ToggleTerm, terminal output frequently displays stack traces and error locations with file paths, line numbers, and column numbers (e.g.,
src/main.rs:42:10orFile "app.py", line 42).Navigating back to the exact file and line in the editor currently requires closing the terminal, manually editing the file path, and jumping to the line.
Solution
This PR adds an opt-in
navigationconfiguration that provides smart file-jumping directly from terminal buffers in normal mode:path/to/file:line:col(e.g.,src/main.rs:42:15)path/to/file:line(e.g.,src/main.rs:42)path/to/fileFile "app.py", line 42)a/orb/prefixes if the stripped file exists)s1n7ax/nvim-window-pickerif installed to pick the destination window.wincmd p).split_direction = "vertical"(default) or"horizontal".close_terminal = true).navigation.enabled = falseby default for 100% backward compatibility.Configuration
──────
Commands & Lua API
• User commands:
• :ToggleTermOpenFile : open file under cursor in target window.
• :ToggleTermOpenFileSplit [vertical|horizontal] : open file in a split (direction can be overridden via argument).
• Lua API:
• require("toggleterm").open_file(opts)
• require("toggleterm.navigation").get_file_under_cursor(line, col)
──────
Checks
[✓] Tested locally with unit tests (tests/navigation_spec.lua).
[✓] All 58 Plenary tests passing (make test).
[✓] Options and usage documented in README.md.