Skip to content

Commit

Permalink
Merge branch 'add_syntax_doc' of github.com:PizieDust/ocaml-lsp into …
Browse files Browse the repository at this point in the history
…add_syntax_doc
  • Loading branch information
PizieDust committed Mar 14, 2024
2 parents c5f37c9 + 04cb70c commit d7401c4
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 17 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
- Introduce a configuration option to control dune diagnostics. The option is
called `duneDiganostics` and it may be set to `{ enable: false }` to disable
diagnostics. (#1221)

- Includes a new optional/configurable option to toggle syntax documentation. If
toggled on, allows display of sytax documentation on hover tooltips. Can be
controlled via environment variables and by GUI for VS code. (#1218)
- Support folding of `ifthenelse` expressions (#1031)

- Includes a new optional/configurable option to toggle syntax documentation. If
Expand Down
107 changes: 91 additions & 16 deletions ocaml-lsp-server/src/config_data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,80 @@ module SyntaxDocumentation = struct
[@@@end]
end

module SyntaxDocumentation = struct
type t = { enable : bool [@default false] }
[@@deriving_inline yojson] [@@yojson.allow_extra_fields]

let _ = fun (_ : t) -> ()

let t_of_yojson =
(let _tp_loc =
"ocaml-lsp-server/src/config_data.ml.SyntaxDocumentation.t"
in
function
| `Assoc field_yojsons as yojson -> (
let enable_field = ref Ppx_yojson_conv_lib.Option.None
and duplicates = ref []
and extra = ref [] in
let rec iter = function
| (field_name, _field_yojson) :: tail ->
(match field_name with
| "enable" -> (
match Ppx_yojson_conv_lib.( ! ) enable_field with
| Ppx_yojson_conv_lib.Option.None ->
let fvalue = bool_of_yojson _field_yojson in
enable_field := Ppx_yojson_conv_lib.Option.Some fvalue
| Ppx_yojson_conv_lib.Option.Some _ ->
duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates)
| _ -> ());
iter tail
| [] -> ()
in
iter field_yojsons;
match Ppx_yojson_conv_lib.( ! ) duplicates with
| _ :: _ ->
Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields
_tp_loc
(Ppx_yojson_conv_lib.( ! ) duplicates)
yojson
| [] -> (
match Ppx_yojson_conv_lib.( ! ) extra with
| _ :: _ ->
Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields
_tp_loc
(Ppx_yojson_conv_lib.( ! ) extra)
yojson
| [] ->
let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in
{ enable =
(match enable_value with
| Ppx_yojson_conv_lib.Option.None -> false
| Ppx_yojson_conv_lib.Option.Some v -> v)
}))
| _ as yojson ->
Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom
_tp_loc
yojson
: Ppx_yojson_conv_lib.Yojson.Safe.t -> t)

let _ = t_of_yojson

let yojson_of_t =
(function
| { enable = v_enable } ->
let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in
let bnds =
let arg = yojson_of_bool v_enable in
("enable", arg) :: bnds
in
`Assoc bnds
: t -> Ppx_yojson_conv_lib.Yojson.Safe.t)

let _ = yojson_of_t

[@@@end]
end

type t =
{ codelens : Lens.t Json.Nullable_option.t
[@default None] [@yojson_drop_default ( = )]
Expand Down Expand Up @@ -495,13 +569,14 @@ let t_of_yojson =
| [] ->
let ( codelens_value
, extended_hover_value
, inlay_hints_value
, dune_diagnostics_value
, syntax_documentation_value ) =
( Ppx_yojson_conv_lib.( ! ) codelens_field
, Ppx_yojson_conv_lib.( ! ) extended_hover_field
, Ppx_yojson_conv_lib.( ! ) syntax_documentation_field
, Ppx_yojson_conv_lib.( ! ) inlay_hints_field
, Ppx_yojson_conv_lib.( ! ) dune_diagnostics_field )
, Ppx_yojson_conv_lib.( ! ) dune_diagnostics_field
, Ppx_yojson_conv_lib.( ! ) syntax_documentation_field )
in
{ codelens =
(match codelens_value with
Expand All @@ -511,10 +586,6 @@ let t_of_yojson =
(match extended_hover_value with
| Ppx_yojson_conv_lib.Option.None -> None
| Ppx_yojson_conv_lib.Option.Some v -> v)
; syntax_documentation =
(match syntax_documentation_value with
| Ppx_yojson_conv_lib.Option.None -> None
| Ppx_yojson_conv_lib.Option.Some v -> v)
; inlay_hints =
(match inlay_hints_value with
| Ppx_yojson_conv_lib.Option.None -> None
Expand All @@ -523,6 +594,10 @@ let t_of_yojson =
(match dune_diagnostics_value with
| Ppx_yojson_conv_lib.Option.None -> None
| Ppx_yojson_conv_lib.Option.Some v -> v)
; syntax_documentation =
(match syntax_documentation_value with
| Ppx_yojson_conv_lib.Option.None -> None
| Ppx_yojson_conv_lib.Option.Some v -> v)
}))
| _ as yojson ->
Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom
Expand All @@ -541,6 +616,16 @@ let yojson_of_t =
; syntax_documentation =
v_syntax_documentation } ->
let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in
let bnds =
if None = v_syntax_documentation then bnds
else
let arg =
(Json.Nullable_option.yojson_of_t SyntaxDocumentation.yojson_of_t)
v_syntax_documentation
in
let bnd = ("syntaxDocumentation", arg) in
bnd :: bnds
in
let bnds =
if None = v_dune_diagnostics then bnds
else
Expand All @@ -561,16 +646,6 @@ let yojson_of_t =
let bnd = ("inlayHints", arg) in
bnd :: bnds
in
let bnds =
if None = v_syntax_documentation then bnds
else
let arg =
(Json.Nullable_option.yojson_of_t SyntaxDocumentation.yojson_of_t)
v_syntax_documentation
in
let bnd = ("syntaxDocumentation", arg) in
bnd :: bnds
in
let bnds =
if None = v_extended_hover then bnds
else
Expand Down

0 comments on commit d7401c4

Please sign in to comment.