User guide / Language support

Language features

Development reference · View source

KeyAction
Space l hShow documentation for the symbol under the cursor
Space l s / Space l SDocument / workspace symbols
Space l dDiagnostics
Space l r / Space l aRename symbol / apply a code action
Space l cAsk for completions (Ctrl-x in Insert mode)
Space l f / Space l R / Space l ?Format / restart language servers / report language-server state
Space l g d/D/y/r/iDefinition / declaration / type definition / references / implementation
gd / gDGo to definition / declaration
gy / giGo to type definition / implementation
grGo to references
:formatFormat the buffer (typed equivalent of Space l f)
TabCode actions for the selection

Hover documentation stays anchored to its source.

  • A short document is a peek: it closes and passes the next key on.
  • With more than twelve lines, the title says how much was left out, and Enter opens the full text in a retained read-only [documentation] buffer.

Goto and pickers. One result moves the selection to it; several open a picker. Every picker filters as you type, moves with the arrows or Ctrl-n/Ctrl-p, opens with Enter, and closes with Escape.

Undo. A completion that needs an import applies both edits as one undo step, and so does a rename across a file. Everything typed between entering Insert mode and returning to Normal is one undo step too; undo and redo map the caret through the inverse edit rather than leaving it at a stale offset.

Completion

Three sources share one popup:

SourceAppearsNeeds
Language serverAfter one of the server’s trigger characters, on Ctrl-x, or with Space l cA server
PathWhen the text before the caret is a valid directory followed by part of a nameNothing
WordWhen a typed prefix reaches editor.word_completion_minimum characters (3)Nothing
KeyEffect
TabAccept
EscapeDismiss
EnterAlways inserts a newline and dismisses the popup

Why Enter never accepts. A popup can open on its own, after a trigger character or any three-character word prefix, so Enter always keeps its usual meaning rather than risking an unwanted candidate on a keystroke meant to end a line.

Escape dismisses the popup and returns to Normal mode in one press for automatic word completion, and in an editable explorer, where a row’s / can open path completion unasked.

Language-server completion:

  • An explicit Ctrl-x includes the identifier already before the caret, uses the server’s filterText and sortText when present, and stays the active source until space, newline, acceptance, or dismissal.
  • Typing punctuation does not hand the session to word or path completion. A trigger character refreshes the candidates for the new context.
  • If the prefix has no matches, the popup hides without ending the session, so Backspace can bring matches back. Backspace and Delete keep the session; moving the caret or another editing command ends it.
  • Ctrl-x replaces a word popup as soon as the request is sent.

Path completion:

  • It opens on any keystroke that leaves a valid directory plus a name fragment before the caret, not only on /, so editing an existing path shows hints just like typing a new one.
  • Relative paths resolve against both the active file’s parent and the project root, so dir/, files/, ./files/, and ../files/ work from whichever makes them valid.
  • Directories keep a trailing /; accepting one offers its children.
  • A large directory shows its first few hundred names, but typing more narrows against the whole directory, so every existing name is reachable.
  • A path in progress takes over from word completion as soon as / is typed, unless an explicit LSP session is active.
  • Command palette path arguments work the same way.

Word completion offers words from every open buffer in the workspace, including the one being edited.

  • Every open buffer contributes, including explorers, whose entries are file names.
  • It appears in file buffers, the scratch buffer, and the commit message.
  • A word is Unicode letters and numbers. A hyphen stays inside only when it joins characters on both sides, so up-to-date stays whole. Other punctuation is a boundary and never included.
  • Words from the current buffer come first, ordered by how often they occur there, then words from every other buffer in the same order. The word being typed is never offered to complete itself.
  • A background index keeps the list, so a candidate can be one keystroke stale, but typing never waits for it.
  • It never overrides Ctrl-x or a path in progress.
  • Turn it off, or change the trigger length, with editor.word_completion and editor.word_completion_minimum in Space o o.