Capabilities
go-lsp auto-detects feature support and lets you enrich capabilities with option metadata.
Auto Detection
If your handler implements HoverHandler, go-lsp advertises hover support. If it implements CompletionResolveHandler, completion resolve support is included.
Capability Options
Use server options when editors need more detail than an interface can express.
srv := server.NewServer(h,
server.WithCompletionOptions(lsp.CompletionOptions{
TriggerCharacters: []string{".", ":"},
}),
server.WithSignatureHelpOptions(lsp.SignatureHelpOptions{
TriggerCharacters: []string{"("},
RetriggerCharacters: []string{","},
}),
server.WithCodeActionOptions(lsp.CodeActionOptions{
CodeActionKinds: []lsp.CodeActionKind{lsp.CodeActionQuickFix},
}),
)
Commands
Advertise command IDs for workspace/executeCommand. This pairs well with extension actions such as generating a debug bundle.
srv := server.NewServer(h,
server.WithExecuteCommandOptions(lsp.ExecuteCommandOptions{
Commands: []string{"mylang.generateDebugBundle"},
}),
)
Semantic Tokens
Semantic tokens need a legend so clients can decode token type and modifier indexes.
srv := server.NewServer(h,
server.WithSemanticTokensOptions(lsp.SemanticTokensOptions{
Legend: lsp.SemanticTokensLegend{
TokenTypes: []string{"type", "function", "variable"},
TokenModifiers: []string{"declaration", "readonly"},
},
}),
)
File Operation Filters
srv := server.NewServer(h,
server.WithFileOperationFilters([]lsp.FileOperationFilter{
{Pattern: lsp.FileOperationPattern{Glob: "**/*.mylang"}},
}),
)
Position Encoding
LSP defaults to UTF-16 positions. If your server deliberately uses another LSP 3.17 position encoding, advertise it explicitly.
srv := server.NewServer(h,
server.WithPositionEncoding(lsp.PositionEncodingUTF8),
)
Capability options only advertise features your handler implements. Explicit capabilities returned from
Initialize still take precedence.