Skip to main content

Crate nifty_lsp

Crate nifty_lsp 

Source
Expand description

A language server for Nifty: diagnostics, completion, signature help, semantic highlighting, the document outline, go to definition, find references and highlighting the name under the cursor. Every file of a project folder is analysed together, so names resolve across files.

Modulesยง

context ๐Ÿ”’
What kind of code the cursor is in, worked out from the tokens before it. Code being typed rarely parses, so this reads tokens rather than the syntax tree: it only needs to know which blocks, calls and brackets are open and what came last.
document ๐Ÿ”’
One source file of a project: its text, its syntax tree, and conversion between byte offsets and LSP positions.
features ๐Ÿ”’
One module per LSP feature. Each turns a Document into protocol types and knows nothing about the connection.
index ๐Ÿ”’
Every name in a projectโ€™s files, each tied to the declaration it refers to when one exists in the project. Built-in elements, built-in types, fields reached through a value and implicit members have no declaration until the type checker exists, so they stay unresolved.
project ๐Ÿ”’
The files of one program, analysed together: a project folderโ€™s .nf files, or a single file outside any project. A name declared in one file resolves in all of them.
server ๐Ÿ”’
The message loop: keeps open documents up to date and answers requests about them.
signature ๐Ÿ”’
The parameters of whatever a call names: a built-in element or function, or a function, view or struct declared in any file of the project.
workspace ๐Ÿ”’
The open documents and the projects they belong to. A document inside a project folder is analysed with every other .nf file of that project, open or not; a document outside one is a project of its own. Open documentsโ€™ text wins over what is saved on disk.

Constantsยง

SERVER_NAME ๐Ÿ”’

Functionsยง

capabilities ๐Ÿ”’
run
Serves the language server protocol over stdin and stdout until the client exits.
serve ๐Ÿ”’

Type Aliasesยง

Error
Result