Skip to main content

Code Intelligence

Rune's code intelligence is cross-language. The same lsp command drives go to definition, find references, diagnostics, hover docs, rename, formatting, and completion for every first-class language. The keys and workflow below are identical no matter which language server is running underneath.

Each language layers its own dedicated command on top for language-specific refactors and tooling. This page covers the shared lsp command; the per-language guides cover the rest.

Code intelligence: the lsp command

lsp is the cross-language entry point for code intelligence. Run it as lsp <subcommand>. Most subcommands act on the symbol under the cursor; the navigation commands also accept an explicit symbol name as an argument.

CommandArgumentWhat it doesDefault key
lsp hover[<symbol>]Show docs, types, and signatures for the symbol<alt-t>
lsp definition[<symbol>]Jump to where the symbol is defined<alt-d>
lsp declaration[<symbol>]Jump to the symbol's declaration
lsp type-definition[<symbol>]Jump to the symbol's type definition
lsp implementation[<symbol>]List implementations of the symbol<alt-i>
lsp references[<symbol>]List every use of the symbol<alt-r>
lsp completeShow completions at the cursor<ctrl-space>
lsp signature-helpShow the signature of the call at the cursor
lsp renameRename the symbol at the cursor everywhere<meta-f>
lsp formatFormat the file, or the selection if text is selected<alt-b>
lsp diagnosticsOpen a picker with every diagnostic in the file<alt-shift-e>

Go to definition

The everyday flow is to query whatever is under the cursor. Put the cursor on a symbol and press <alt-d> to jump to where it is defined; no argument, no typing. The same cursor-driven shortcut exists for each navigation query:

KeyCommandJumps to
<alt-d>lsp definitionWhere the symbol is defined
<alt-t>lsp hoverIts docs, type, and signature
<alt-i>lsp implementationWhat implements it (or what it implements)
<alt-r>lsp referencesEvery use of it

For hover, definition, declaration, type-definition, implementation, and references, leaving the argument off always targets the symbol you are sitting on. When you know the symbol's name but not where it lives, use the by-name variant below instead.

Query any symbol by name

This is one of the most powerful ways to move around a codebase. You can query a symbol (a function, type, variable, struct, interface, or method) by name, without first having to find where it lives. If you remember what something is called but not where it is defined, press <alt-shift-d>, type the name, and jump straight to its definition:

lsp definition NewServer

The default config binds a shifted variant for each query that pre-fills the prompt with the command and leaves it open for you to type a name: <alt-shift-t> (hover), <alt-shift-d> (definition), <alt-shift-r> (references), and <alt-shift-i> (implementation). So <alt-shift-r> lists every reference to a name, <alt-shift-i> finds what implements it, and <alt-shift-t> reads its docs and signature, all by name, from anywhere in the project. This is the counterpart to Go to definition above: the plain keys act on the cursor, the shifted keys act on a name.

Diagnostics

lsp diagnostics (<alt-shift-e>) opens a location picker listing every diagnostic the language server reports for the file. To step through them without the picker, the default config binds:

KeyAction
<alt-j>Jump to the next diagnostic
<alt-k>Jump to the previous diagnostic

These are aliases for jumptolocation next lsp-diagnostics and jumptolocation previous lsp-diagnostics.

Highlighting occurrences

There is no command for this: Rune automatically highlights other occurrences of the symbol under the cursor shortly after the cursor settles. Move off the symbol and the highlight clears.

Default key bindings

The default editor config binds the most common code-intelligence actions. See Key syntax for how the bindings are written.

KeyCommandTarget
<alt-t>lsp hoverSymbol under the cursor
<alt-shift-t>lsp hoverSymbol you fuzzy-search by name
<alt-d>lsp definitionSymbol under the cursor
<alt-shift-d>lsp definitionSymbol you fuzzy-search by name
<alt-r>lsp referencesSymbol under the cursor
<alt-shift-r>lsp referencesSymbol you fuzzy-search by name
<alt-i>lsp implementationSymbol under the cursor
<alt-shift-i>lsp implementationSymbol you fuzzy-search by name
<meta-f>lsp renameSymbol under the cursor
<alt-b>lsp formatThe file, or the selection
<alt-shift-e>lsp diagnosticsThe whole file
<alt-j>Next diagnosticThe whole file
<alt-k>Previous diagnosticThe whole file
<ctrl-space>lsp completeThe cursor position
note

On macOS, <ctrl-space> is reserved for input source switching. To use it for completion, go to System Settings → Keyboard → Keyboard Shortcuts → Input Sources and uncheck both entries.

Everything bound to a key is also available from the command prompt, so you can run any lsp subcommand by name even when it has no binding.

Ask Rune Agent