fml-lsp
Language server for the FHIR Mapping Language.
It works on the same syntax tree and type checker as fml check, so what the editor shows is what
the checker reports.
- Diagnostics as you type: syntax, compile and type problems. Type problems wait until the syntax errors are fixed.
- Completion:
- elements after
., from the variable's type followed through the path, also in groups without parameter types and in rules that are not finished yet; - FHIRPath functions inside expressions;
- variables in scope;
- groups after
then, with their parameters as placeholders; - transforms after
=; - after
:, the types of a choice element and theusesaliases; - keywords.
- elements after
- Hover:
- the type of a variable or element (
Patient.name : HumanName [0..*]); - a group's signature;
- a transform's signature and description, from the IG.
- the type of a variable or element (
- Go to definition, find references and rename for variables and groups. A type
annotation goes to its
usesalias. - Signature help for transforms and group calls.
- Outline:
uses, constants, ConceptMaps, and groups with their parameters and rules. - Formatting with the
fml fmtformatter. - Semantic tokens: variables, parameters, elements, groups, transforms and types each get a colour of their own. Declarations and constants are marked.
Running it
fml lsp runs the server over standard input and output. It takes the same --fhir and
--package options as fml check:
Point any LSP client at that command, for files ending in .fml or .map.
As a library
Server does no I/O. It takes a JSON-RPC message and returns what to send back: the response,
and notifications such as diagnostics. A host can carry the messages over any transport, such as
a WebSocket in a web console:
use Arc;
use Server;
let mut server = new; // any fml_check::Definitions
for reply in server.handle
run and run_stdio carry the messages over a reader and a writer instead.
Server::set_definitions swaps the definitions (when packages change) and checks the open
documents again.
With the fhirschema feature, Server::with_release serves the core definitions of FHIR R4,
R4B, R5 or R6.
Part of fml-rs. Licensed under MIT or Apache-2.0.