Back to Ponyc

pony-lsp - the Pony Language Server

tools/pony-lsp/README.md

0.63.46.6 KB
Original Source

pony-lsp - the Pony Language Server

pony-lsp implements the Language Server Protocol for Pony. It communicates with editors via stdout/stdin, and is built and distributed alongside ponyc via ponyup.

For user documentation — installation and editor configuration — see the pony-lsp documentation on the Ponylang website.

Feature Support

FeatureDescription
Diagnostics (push, pull, refresh and change notifications)Ponyc errors and related information is reported as LSP diagnostics.
HoverAdditional information is shown for: entities, methods, fields, local variables and references.
Signature HelpParameter hints are shown when the cursor is inside a call expression, with the active parameter highlighted. Includes the method's docstring when present. Requires the file to be saved — signature help is not available while the file has unsaved edits.
Go To DefinitionFor most language constructs, you can go from a reference to its definition.
Go To DeclarationNavigate from a reference to the declaration site of a symbol.
Go To Type DefinitionNavigate to the type definition of the symbol under the cursor.
Document Symbolspony-lsp provides a list of available symbols for each opened document.
Workspace SymbolsFuzzy search over all symbols across the entire workspace.
Document HighlightAll occurrences of the symbol under the cursor are highlighted simultaneously across the document.
Inlay HintsThree kinds of hints are shown inline. For let, var, and field declarations with no type annotation, the full inferred type appears after the variable name. For annotated types where the capability is omitted — in variable and field declarations, function parameter types, generic type arguments, and union and tuple members — the missing capability keyword appears after the type name. For fun declarations, the implicit receiver capability appears before the function name and the implicit return type appears after the closing parenthesis.
Find ReferencesAll references to the symbol under the cursor are returned, with optional inclusion of the declaration site.
RenameRename a symbol and all its references across the workspace.
Folding RangeCode folding ranges are provided for blocks, methods, classes, and other structured constructs.
Selection RangeSmart expand/shrink selection based on the AST structure of the document.

New features are actively being added. Contributions are welcome — we are happy to provide help and guidance.

Settings

pony-lsp supports settings via the workspace/configuration request and workspace/didChangeConfiguration notification.

SettingTypeExampleDescription
definesArray[String]["FOO", "BAR"]Defines active during compilation, equivalent to the -D flag in ponyc
ponypathArray[String]["/path/to/pony/package"]Additional package search paths

Example settings in JSON:

json
{
  "defines": ["FOO", "BAR"],
  "ponypath": ["/path/to/pony/package", "/another/path"]
}

Building from source

First, follow the ponyc build documentation and make sure you have everything to build ponyc. Then building pony-lsp is as easy as:

bash
make pony-lsp

Reporting Issues

If pony-lsp is not working as expected, please open an issue. Include a minimal Pony program that reproduces the problem, the pony-lsp version, and the LSP client/editor you are using.