Language Servers#

toe uses gopls for Go language features. Other language servers can be selected and configured in languages.toml; each server must be installed on your PATH.

Configuring a Language Server#

Add a [language-server.<name>] section and reference it from the language:

# $XDG_CONFIG_HOME/toe/languages.toml

[language-server.gopls]
command = "gopls"
args = ["-remote=auto"]          # optional
environment = { GOFLAGS = "-mod=mod" }  # optional
timeout = 30                     # optional, seconds

[[language]]
name = "go"
language-servers = ["gopls"]

Workspace Config#

Language server config in .toe/languages.toml is merged on top of user config, letting you override per-project without touching global settings.

Available Language Server Features#

FeatureKeyCommand
Go to definitiongdgoto-definition
Go to declarationgDgoto-declaration
Go to type definitiongygoto-type-definition
Go to implementationgigoto-implementation
Go to referencesgrgoto-reference
Select all referencesSpace+hselect-references-to-symbol-under-cursor
Hover docsSpace+khover
Rename symbolSpace+rrename-symbol
Code actionsSpace+acode-action
Format selection=format-selections
Format document:formatformat
Signature help(auto in Insert)signature-help
CompletionCtrl+x (or auto)completion
Document symbolsSpace+ssymbol-picker
Workspace symbolsSpace+Sworkspace-symbol-picker

Workspace symbol searches query every running language server, not only the server for the focused document.

Completion is requested three ways: Ctrl+x at any time, automatically after a trigger character the language server advertises (. for most servers), and automatically once typing pauses, see Completion for the delay and trigger length.

Diagnostics (errors and warnings) appear as underlines in the document, markers in the gutter, counts in the status bar, and a popup when the cursor rests on a diagnostic.

Completion Kinds#

The completion popup marks each candidate with its kind, colored by the theme scope in the last column. Terminals without a Nerd Font show the short label instead:

IconKindPlainTheme scope
textTxtstring
functionFunfunction
methodMthfunction
constructorCtrfunction
fieldFldvariable.other.member
variableVarvariable.parameter
classClstype
interfaceIfctype
moduleModnamespace
propertyPrpvariable.other.member
unitUnttype
valueValconstant
enumEnmconstant
keywordKwdkeyword
snippetSnpstring
colorClrstring
fileFilstring
referenceRefvariable.other.member
folderDirstring
constantCstconstant
structScttype
eventEvtstring
operatorOproperator
type paramTpmtype
enum memberEmbconstant

Restarting Servers#

:lsp-restart             restart all servers for the current document
:lsp-restart gopls       restart a specific server
:lsp-stop                stop all servers

Formatter#

You can also configure a standalone formatter (runs when auto-format = true or when you invoke =):

[[language]]
name = "go"
auto-format = true
formatter = { command = "gofmt" }

If a language server and formatter are both configured, the language server’s formatting is used.