Neovim LSP Shortcuts

0.10

Language Server Protocol keybindings for Neovim

Official docs →

Neovim has had built-in LSP support since version 0.5, and it's one of the things that turned it from "that terminal editor" into a legitimate IDE competitor. The Language Server Protocol lets Neovim talk to language servers — the same ones that power VS Code's intellisense — giving you go-to-definition, autocompletion, diagnostics, rename refactoring, and more, all without leaving your terminal.

One important caveat: LSP keybindings depend on your configuration. Neovim doesn't ship with LSP keymaps out of the box — they're set up by your config, typically through vim.lsp.buf mappings or a plugin like nvim-lspconfig. The bindings on this page reflect the most common conventions you'll see across popular configs (LazyVim, kickstart.nvim, NvChad, etc.), but yours might be different. When in doubt, run :map to see what's actually bound, or check your lspconfig setup.

For the general overview, see the main Neovim cheatsheet.

Go-To Navigation

The bread and butter of LSP — jump to where things are defined, declared, or used. These are the bindings that make navigating a codebase feel effortless.

Jump to Definition & References
gd
Go to definition of the symbol under cursor
gD
Go to declaration (useful in C/C++ for header declarations)
gi
Go to implementation (for interfaces/abstract methods)
gr
Show all references to the symbol under cursor
gy
Go to type definition (jump to the type of the symbol)
Ctrl-o
Jump back after a go-to (your "back button")
Ctrl-i
Jump forward in the jump list

gd followed by Ctrl-o is probably the navigation pattern you'll use a hundred times a day. Jump to a definition to understand what something does, then Ctrl-o to bounce right back to where you were. It works across files, and Neovim remembers your full jump history, so you can chain multiple Ctrl-o presses to retrace your steps through a long investigation.

Hover & Signature Help

Quick information without leaving your current position. Hover docs show you what a symbol is, and signature help reminds you what arguments a function takes while you're typing.

Documentation & Signatures
K
Show hover documentation for symbol under cursor
Ctrl-k
Show signature help (in Insert mode — shows function parameters)
K K
Press K twice to enter the hover float (scroll and yank from it)

K is mapped to hover docs by default in most LSP configs, but it's also Neovim's built-in "keyword lookup" key. If you're in a file without an LSP attached (say, a plain text file), K will fall back to looking up the word under the cursor in man pages or keywordprg. This means K is always useful — it just gets smarter when an LSP is running.

Rename & Code Actions

These are the refactoring commands — the ones that modify your code intelligently across the project.

Refactoring
<leader>rn
Rename symbol under cursor (updates all references across files)
<leader>ca
Show available code actions (quick fixes, refactors, extractions)
<leader>ca (visual)
Code actions for the selected range
Common Code Actions You Will See
Extract function
Pull selected code into a new function
Extract variable
Pull an expression into a named variable
Add missing import
Auto-import a symbol that is used but not imported
Remove unused import
Clean up imports that are no longer needed
Organize imports
Sort and group imports according to convention
Fix all
Apply all auto-fixable diagnostics at once

<leader>rn (rename) is one of the most satisfying LSP features. It doesn't just find-and-replace a string — it understands scope. Renaming a local variable won't touch a global with the same name. Renaming a method updates every call site, import, and re-export across your entire project. It's the kind of refactoring you used to need an IDE for.

Diagnostics

Diagnostics are the errors, warnings, and hints that the language server surfaces. These bindings let you navigate through them and inspect the details.

Navigating Diagnostics
]d
Jump to next diagnostic in the buffer
[d
Jump to previous diagnostic in the buffer
]e
Jump to next error (skip warnings/hints)
[e
Jump to previous error
]w
Jump to next warning
[w
Jump to previous warning
Viewing Diagnostics
<leader>e
Show diagnostic detail in a floating window
<leader>q
Send all buffer diagnostics to the location list
:lua vim.diagnostic.setqflist()
Send all workspace diagnostics to the quickfix list
:lua vim.diagnostic.enable(false)
Disable diagnostics (hide all squiggles)
:lua vim.diagnostic.enable(true)
Re-enable diagnostics

Formatting

Auto-format your code according to the language server's rules, or a dedicated formatter if configured.

Formatting
<leader>f
Format the entire buffer
gq{motion}
Format the range covered by the motion (uses LSP if available)
gq (visual)
Format the selected range
:lua vim.lsp.buf.format({ async = true })
Format buffer explicitly via Lua API

Workspace Symbols & Call Hierarchy

These go beyond single-file navigation. Workspace symbols search across your entire project, and the call hierarchy shows you who calls what.

Workspace & Symbols
<leader>ds
List document symbols (functions, classes, variables in current file)
<leader>ws
Search workspace symbols across the entire project
:lua vim.lsp.buf.incoming_calls()
Show functions that call the symbol under cursor
:lua vim.lsp.buf.outgoing_calls()
Show functions called by the symbol under cursor
Workspace Folders
<leader>wa
Add a workspace folder
<leader>wr
Remove a workspace folder
<leader>wl
List current workspace folders

LSP Server Management

Sometimes you need to check on or restart the language server itself.

Server Management
:LspInfo
Show attached LSP clients and their status
:LspRestart
Restart the LSP server for the current buffer
:LspStop
Stop the LSP server
:LspStart
Start the LSP server (if it was stopped)
:LspLog
Open the LSP log file for debugging
:checkhealth lsp
Run health checks on LSP configuration

When your LSP feels off — completions stop working, diagnostics disappear, or go-to-definition suddenly fails — try :LspRestart before you start debugging your config. Language servers are long-running processes and they occasionally get into a bad state. A quick restart usually fixes it. If it doesn't, :LspLog will show you what the server is actually saying.

Pair LSP navigation with Telescope for a much better experience. Many configs map gr to Telescope lsp_references instead of the built-in quickfix list, giving you a fuzzy-searchable, previewed list of references. Similarly, <leader>ds often maps to Telescope lsp_document_symbols. If you're setting up your own config, these Telescope integrations are worth the five minutes of configuration.

Related Tools