diff options
| author | Chimrod <> | 2025-08-01 15:25:03 +0200 |
|---|---|---|
| committer | Chimrod <> | 2025-08-04 14:00:40 +0200 |
| commit | c3982131f3075689a15512daef67e254f27371ea (patch) | |
| tree | d770c07493959a7899ac3c4ad50cadcca7e44f51 /bin/lsp_diagnostic.ml | |
| parent | 3046fb0d0c1ceac2c6a6ca9456e9e05671e0cef9 (diff) | |
Added a lsp server
Diffstat (limited to 'bin/lsp_diagnostic.ml')
| -rw-r--r-- | bin/lsp_diagnostic.ml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/lsp_diagnostic.ml b/bin/lsp_diagnostic.ml new file mode 100644 index 0000000..7f697f8 --- /dev/null +++ b/bin/lsp_diagnostic.ml @@ -0,0 +1,24 @@ +module Types = Linol_lsp.Types +(** Generate a diagnostic from the report *) + +let position : Lexing.position -> Types.Position.t = + fun pos -> + { + character = pos.Lexing.pos_cnum - pos.Lexing.pos_bol; + line = pos.Lexing.pos_lnum - 1; + } + +let build : Qsp_syntax.Report.t -> Types.Diagnostic.t = + fun { level; loc; message } -> + let severity = + match level with + | Error -> Types.DiagnosticSeverity.Error + | Warn -> Types.DiagnosticSeverity.Warning + | Debug -> Types.DiagnosticSeverity.Hint + in + + let start = position (fst loc) and end_ = position (snd loc) in + let range = Types.Range.{ start; end_ } in + + let message = `String message in + Types.Diagnostic.create ~range ~message ~severity () |
