From c3982131f3075689a15512daef67e254f27371ea Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Fri, 1 Aug 2025 15:25:03 +0200 Subject: Added a lsp server --- bin/lsp_diagnostic.ml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bin/lsp_diagnostic.ml (limited to 'bin/lsp_diagnostic.ml') 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 () -- cgit v1.2.3