Skip to content

Jump to next/previous LSP reference for item under cursor with ]r/[r

License

Notifications You must be signed in to change notification settings

mawkler/refjump.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Refjump

Jump to next/previous LSP reference in the current buffer for the item under the cursor with ]r/[r.

If you have demicolon.nvim installed you can also repeat jumps with ;/,. See the Demicolon section for more information.

refjump.mp4

Installation

With lazy.nvim:

{
  'mawkler/refjump.nvim',
  -- keys = { ']r', '[r' }, -- Uncomment to lazy load
  opts = {}
}

Usage

  • Press ]r or [r to jump to the next/previous reference for the item under the cursor.
  • Press ;/, to keep jumping forward/backward between those references (requires demicolon.nvim)

You can also prefix any jump with a count. For example, you can do 3]r to jump to the third next reference. This also works for ;/,.

Configuration

The following is the default configuration:

opts = {
  keymaps = {
    enable = true,
    next = ']r', -- Keymap to jump to next LSP reference
    prev = '[r', -- Keymap to jump to previous LSP reference
  },
  highlights = {
    enable = true, -- Highlight the LSP references on jump
    auto_clear = true, -- Automatically clear highlights when cursor moves
  },
  integrations = {
    demicolon = {
      enable = true, -- Make `]r`/`[r` repeatable with `;`/`,` using demicolon.nvim
    },
  },
  verbose = true, -- Print message if no reference is found
}

Highlights

Refjump highlights the references by default. It uses the highlight group RefjumpReferences. To change the highlight, see :help nvim_set_hl().

Integrations

Demicolon

This plugin integrates with demicolon.nvim. Demicolon lets you repeat ]r/[r jumps with ;/, (you can also still repeat t/f/T/F like you would expect). Refjump will cache the list of LSP references which gives you super responsive jump repetitions.

This integration is automatically set up if demicolon.nvim is detected and the option integrations.demicolon.enable is true.

About

Jump to next/previous LSP reference for item under cursor with ]r/[r

Topics

Resources

License

Stars

Watchers

Forks

Languages