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.
| Command | Argument | What it does | Default 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 complete | Show completions at the cursor | <ctrl-space> | |
lsp signature-help | Show the signature of the call at the cursor | ||
lsp rename | Rename the symbol at the cursor everywhere | <meta-f> | |
lsp format | Format the file, or the selection if text is selected | <alt-b> | |
lsp diagnostics | Open 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:
| Key | Command | Jumps to |
|---|---|---|
<alt-d> | lsp definition | Where the symbol is defined |
<alt-t> | lsp hover | Its docs, type, and signature |
<alt-i> | lsp implementation | What implements it (or what it implements) |
<alt-r> | lsp references | Every 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:
| Key | Action |
|---|---|
<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.
| Key | Command | Target |
|---|---|---|
<alt-t> | lsp hover | Symbol under the cursor |
<alt-shift-t> | lsp hover | Symbol you fuzzy-search by name |
<alt-d> | lsp definition | Symbol under the cursor |
<alt-shift-d> | lsp definition | Symbol you fuzzy-search by name |
<alt-r> | lsp references | Symbol under the cursor |
<alt-shift-r> | lsp references | Symbol you fuzzy-search by name |
<alt-i> | lsp implementation | Symbol under the cursor |
<alt-shift-i> | lsp implementation | Symbol you fuzzy-search by name |
<meta-f> | lsp rename | Symbol under the cursor |
<alt-b> | lsp format | The file, or the selection |
<alt-shift-e> | lsp diagnostics | The whole file |
<alt-j> | Next diagnostic | The whole file |
<alt-k> | Previous diagnostic | The whole file |
<ctrl-space> | lsp complete | The cursor position |
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.