Plugin for VSCode like navigation in Neovim
- Navigate with Alt + -/+, when a navigation action is recorded (like VSCode).
- Going to definitions records the source and destination.
- Going to references:
- Records the source and chosen destination from the quickfix buffer.
- Also records when another destination is selected from already open quickfix.
- Records the source and destination, when using
:LineNumbernavigation.
| Function | Description |
|---|---|
navigation.back() |
Navigates backward through your cursor history. |
navigation.forward() |
Navigates forward through your cursor history. |
navigation.record() |
Records the current cursor position and the destination after a jump. This is essential for building the navigation history. |
navigation.toggle() |
Toggles the navigation.nvim plugin on or off. |
use {"Shresth72/navigation.nvim", tag = "*" } -- stable version
use {"Shresth72/navigation.nvim"}With junegunn/vim-plug
Plug "Shresth72/navigation.nvim", { "tag": "*" } -- stable version
Plug "Shresth72/navigation.nvim"With folke/lazy.nvim
When you provide an opts table, lazy.nvim automatically calls require("navigation").setup(opts). This is the simplest way to configure the plugin.
require("lazy").setup({
{
"Shresth72/navigation.nvim",
lazy = false,
},
})| Function | Keybinding | Description |
|---|---|---|
| Back | <M--> |
Navigates backward through your cursor history. |
| Forward | <M-=> |
Navigates forward through your cursor history. |
| Go To Definition | gd |
Goes to the Definition of the term, and records the action. |
| Go To References | gr |
Goes to the References of the term, and records the action. |
| Command | Description |
|---|---|
:NavigationToggle |
Toggle navigation.nvim on or off. |
:NavigationEnable |
Enable navigation.nvim. |
:NavigationDisable |
Disable navigation.nvim. |
:NavigationBack |
Navigate backward through your cursor history. |
:NavigationForward |
Navigate forward through your cursor history. |
:NavigationDefinition |
Go to definition and record the navigation. |
:NavigationReferences |
Go to references and record the navigation. |
:NavigationLine {number} |
Navigate to a line and record the navigation. |
If you want to add custom keymaps, override defaults, or integrate navigation.record() with other navigation commands, you should provide a config function. When you use a config function, you must call setup(opts) yourself.
require("lazy").setup({
{
"Shresth72/navigation.nvim",
lazy = false,
opts = {
enable = true,
debug = false,
keymaps = {
back = "<C-o>",
forward = "<C-i>",
goToDefinition = "gd",
goToReferences = "gr",
}
},
},
-- other plugins
})