diff --git a/src/hack_forked/utils/lsp/lsp.ml b/src/hack_forked/utils/lsp/lsp.ml index 112151b2f2f..944246f4004 100644 --- a/src/hack_forked/utils/lsp/lsp.ml +++ b/src/hack_forked/utils/lsp/lsp.ml @@ -568,7 +568,10 @@ module Initialize = struct | Messages | Verbose - and initializationOptions = { liveSyntaxErrors: bool } + and initializationOptions = { + liveSyntaxErrors: bool; + detailedErrorRendering: bool option; + } and client_capabilities = { workspace: workspaceClientCapabilities; diff --git a/src/hack_forked/utils/lsp/lsp.mli b/src/hack_forked/utils/lsp/lsp.mli index 895fef97e04..f7c48924c85 100644 --- a/src/hack_forked/utils/lsp/lsp.mli +++ b/src/hack_forked/utils/lsp/lsp.mli @@ -422,7 +422,10 @@ module Initialize : sig | Messages | Verbose - and initializationOptions = { liveSyntaxErrors: bool } + and initializationOptions = { + liveSyntaxErrors: bool; + detailedErrorRendering: bool option; + } and client_capabilities = { workspace: workspaceClientCapabilities; diff --git a/src/hack_forked/utils/lsp/lsp_fmt.ml b/src/hack_forked/utils/lsp/lsp_fmt.ml index dee8ad6cc1d..1612223d380 100644 --- a/src/hack_forked/utils/lsp/lsp_fmt.ml +++ b/src/hack_forked/utils/lsp/lsp_fmt.ml @@ -1375,7 +1375,17 @@ let parse_initialize (params : json option) : Initialize.params = | Some "verbose" -> Verbose | _ -> Off and parse_initializationOptions json = - { liveSyntaxErrors = Jget.bool_d json "liveSyntaxErrors" ~default:true } + { + liveSyntaxErrors = Jget.bool_d json "liveSyntaxErrors" ~default:true; + detailedErrorRendering = + (match Jget.bool_opt json "detailedErrorRendering" with + | Some b -> Some b + | None -> + (match Jget.string_opt json "detailedErrorRendering" with + | Some "true" -> Some true + | Some "false" -> Some false + | _ -> None)); + } and parse_capabilities json = { workspace = Jget.obj_opt json "workspace" |> parse_workspace; diff --git a/src/server/command_handler/commandHandler.ml b/src/server/command_handler/commandHandler.ml index c912dce728e..9603f97f12b 100644 --- a/src/server/command_handler/commandHandler.ml +++ b/src/server/command_handler/commandHandler.ml @@ -1191,9 +1191,13 @@ let linked_editing_range ~options ~env ~profiling ~params ~client = ) let vscode_detailed_diagnostics ~options client = + let client_config = Persistent_connection.client_config client in + let lsp_initialize_params = Persistent_connection.lsp_initialize_params client in Persistent_connection.Client_config.detailed_error_rendering_merge_with_options ~flowconfig_enabled:(Options.vscode_detailed_diagnostics options) - (Persistent_connection.client_config client) + ~client_init_options_enabled: + Lsp.Initialize.(lsp_initialize_params.initializationOptions.detailedErrorRendering) + client_config let rank_autoimports_by_usage ~options client = let client_config = Persistent_connection.client_config client in diff --git a/src/server/persistent_connection/persistent_connection.ml b/src/server/persistent_connection/persistent_connection.ml index 5bc06dbfb0a..6ccc74f759f 100644 --- a/src/server/persistent_connection/persistent_connection.ml +++ b/src/server/persistent_connection/persistent_connection.ml @@ -23,9 +23,9 @@ module Client_config = struct let detailed_error_rendering { detailed_error_rendering; _ } = detailed_error_rendering let detailed_error_rendering_merge_with_options - ~flowconfig_enabled { detailed_error_rendering; _ } = + ~flowconfig_enabled ~client_init_options_enabled { detailed_error_rendering; _ } = match detailed_error_rendering with - | Default -> flowconfig_enabled + | Default -> Base.Option.value client_init_options_enabled ~default:flowconfig_enabled | True -> true | False -> false @@ -116,6 +116,8 @@ let send_errors = let vscode_detailed_diagnostics = Client_config.detailed_error_rendering_merge_with_options ~flowconfig_enabled:flowconfig_vscode_detailed_diagnostics + ~client_init_options_enabled: + Lsp.Initialize.(client.lsp_initialize_params.initializationOptions.detailedErrorRendering) client.client_config in let diagnostics = diff --git a/src/server/persistent_connection/persistent_connection.mli b/src/server/persistent_connection/persistent_connection.mli index b9cc9f724fd..ac9236ad6ca 100644 --- a/src/server/persistent_connection/persistent_connection.mli +++ b/src/server/persistent_connection/persistent_connection.mli @@ -25,7 +25,8 @@ module Client_config : sig val detailed_error_rendering : t -> client_toggle - val detailed_error_rendering_merge_with_options : flowconfig_enabled:bool -> t -> bool + val detailed_error_rendering_merge_with_options : + flowconfig_enabled:bool -> client_init_options_enabled:bool option -> t -> bool val rank_autoimports_by_usage : t -> client_toggle