ds lsp#
Server#
Command#
ds lsp [-L DIR]...
ds lsp is a language server on stdin and stdout, for an editor.
-L DIR, or --search-path DIR, adds a library directory to every compile, after the document’s own and any the editor gives. Accumulates. -h prints the usage.
The exit status is 0 after shutdown, and 1 if exit or the end of input comes without one.
(Source: tools/dsdb/lib/cli/main.js, tools/dsdb/lib/lsp/server.js)
Transport#
Messages are framed by a Content-Length header, with a body of at most 64 MiB and a header of at most 8 KiB. Bytes past either limit, or a header with no Content-Length, end the session.
Requests are answered one at a time, in order. Document sync is full.
(Source: tools/dsdb/lib/lsp/framing.js, tools/dsdb/lib/lsp/server.js)
Errors#
Code |
When |
|---|---|
|
a message that is not JSON |
|
a message that is neither request nor notification, or a request after |
|
a request the server does not answer |
|
a request before |
|
a |
|
a failure while answering |
(Source: tools/dsdb/lib/lsp/server.js)
Lifecycle#
initialize#
initialize
initialize gives the server’s capabilities.
The position encoding is utf-32 where general.positionEncodings offers it, else utf-16.
|
Value |
|---|---|
|
library directories for every compile; a relative one is the root’s |
|
where the rendered documentation is, a URL or a path; a relative path is the root’s |
(Source: tools/dsdb/lib/lsp/server.js, tools/dsdb/lib/lsp/positions.js)
shutdown#
shutdown
shutdown answers null, and every later request is refused with -32600.
(Source: tools/dsdb/lib/lsp/server.js)
exit#
exit
exit ends the server.
(Source: tools/dsdb/lib/lsp/server.js)
Documents#
textDocument/didOpen#
textDocument/didOpen
This holds the document and analyses it at once.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/didChange#
textDocument/didChange
This replaces the text, and analyses it once 200 ms pass with no later change.
Any request but completion and signature help first analyses what is waiting. Until a source parses again, the last tree that parsed answers.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/didSave#
textDocument/didSave
This analyses the document at once.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/didClose#
textDocument/didClose
This drops the document and clears its diagnostics.
(Source: tools/dsdb/lib/lsp/server.js)
workspace/didChangeWatchedFiles#
workspace/didChangeWatchedFiles
This analyses every open document, on the same wait as a change.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/publishDiagnostics#
textDocument/publishDiagnostics
The server sends the compiler’s diagnostics after each analysis, each with severity error, its code, source ds lsp, and a hint in its message.
An empty span is widened to one character. The codes are the diagnostic catalogue.
(Source: tools/dsdb/lib/lsp/server.js)
Requests#
textDocument/hover#
textDocument/hover
This gives Markdown for the name the program declares at the position, or for a builtin where it is called.
A builtin’s hover gives each overload’s signature, its summary and the clauses that define it, linked under docs where given.
(Source: tools/dsdb/lib/lsp/server.js, tools/dsdb/lib/lsp/builtins.js)
textDocument/definition#
textDocument/definition
This gives the declaration of the name at the position, in the same document.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/references#
textDocument/references
This gives every site of the name at the position, in the program rooted at the document and every library it imports.
context.includeDeclaration false leaves the declaration out. An open library is read from the editor’s text.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/rename#
textDocument/rename
This gives a workspace edit of every site of the name at the position.
It is refused for a name that is not a DS name, a reserved word, a position that names nothing the program declares, or a site outside the workspace folders.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/completion#
textDocument/completion
This gives completions at the position, from the last tree that parsed and the line’s text.
The trigger characters are . and :.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/signatureHelp#
textDocument/signatureHelp
This gives the signature of the call at the position, from the last tree that parsed and the line’s text.
The trigger characters are ( and ,.
(Source: tools/dsdb/lib/lsp/server.js)
textDocument/documentSymbol#
textDocument/documentSymbol
This gives the document’s outline.
(Source: tools/dsdb/lib/lsp/server.js)
workspace/symbol#
workspace/symbol
This gives the matching symbols of every file an open document’s program reaches.
A name matches when it holds the query’s characters in order, in any case. An empty query matches every name.
(Source: tools/dsdb/lib/lsp/server.js, tools/dsdb/lib/lsp/symbols.js)
textDocument/semanticTokens/full#
textDocument/semanticTokens/full
This gives the document’s tokens, one per line. A document that has not parsed still has its reserved words, literals and comments coloured.
Legend |
Values |
|---|---|
|
|
|
|
(Source: tools/dsdb/lib/lsp/semantic.js, tools/dsdb/lib/lsp/server.js)