Skip to main content

fml_lsp/
lib.rs

1//! Language server for the [FHIR Mapping Language](https://build.fhir.org/ig/HL7/mapping-language-ig/).
2//!
3//! - diagnostics: syntax, compile and type problems as you type;
4//! - completion: elements after `.` (from the type of the variable, followed through the path),
5//!   variables in scope, groups after `then`, transforms after `=`, types after `:`, keywords;
6//! - hover: the type of a variable or an element, a group's signature, a transform's description;
7//! - go to definition, find references and rename for variables and groups;
8//! - signature help for transforms and group calls;
9//! - the outline (document symbols), formatting, and semantic tokens for colouring.
10//!
11//! [`Server`] does no I/O: it takes JSON-RPC messages and returns what to send back, so a host
12//! can run it over standard input and output ([`run_stdio`]) or over a WebSocket.
13//!
14//! ```
15//! # #[cfg(feature = "fhirschema")] {
16//! use fml_lsp::Server;
17//! use serde_json::json;
18//!
19//! let mut server = Server::with_release(fml_check::Release::R5);
20//! server.handle(&json!({"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"capabilities": {}}}));
21//! let replies = server.handle(&json!({
22//!     "jsonrpc": "2.0",
23//!     "method": "textDocument/didOpen",
24//!     "params": {"textDocument": {"uri": "file:///map.fml", "languageId": "fml", "version": 1, "text": "group G(source src : Patient) {\n  src.nmae -> src.name;\n}\n"}}
25//! }));
26//! assert_eq!(replies[0]["method"], "textDocument/publishDiagnostics");
27//! # }
28//! ```
29
30mod completion;
31mod document;
32mod hover;
33mod navigate;
34mod reference;
35mod semantic;
36mod server;
37mod signature;
38mod stdio;
39mod symbols;
40
41pub use lsp_types;
42pub use server::{Server, SharedDefinitions};
43pub use stdio::{run, run_stdio};