diff --git a/src/hack_forked/utils/lsp/lsp.ml b/src/hack_forked/utils/lsp/lsp.ml index 8835ed06af0..07e9bd3b52b 100644 --- a/src/hack_forked/utils/lsp/lsp.ml +++ b/src/hack_forked/utils/lsp/lsp.ml @@ -444,7 +444,7 @@ module Initialize = struct (* ie. document outline *) workspaceSymbolProvider: bool; (* ie. find-symbol-in-project *) - codeActionProvider: bool; + codeActionProvider: codeActionOptions; codeLensProvider: codeLensOptions option; documentFormattingProvider: bool; documentRangeFormattingProvider: bool; @@ -468,6 +468,10 @@ module Initialize = struct sighelp_triggerCharacters: string list; (* wire "triggerCharacters" *) } + and codeActionOptions = + | CodeActionBool of bool + | CodeActionOptions of { codeActionKinds: CodeActionKind.t list } + and codeLensOptions = { codelens_resolveProvider: bool (* wire "resolveProvider" *) } and documentOnTypeFormattingOptions = { diff --git a/src/hack_forked/utils/lsp/lsp.mli b/src/hack_forked/utils/lsp/lsp.mli index 7f4595a779a..ce3d4a95f19 100644 --- a/src/hack_forked/utils/lsp/lsp.mli +++ b/src/hack_forked/utils/lsp/lsp.mli @@ -281,7 +281,7 @@ module Initialize : sig documentHighlightProvider: bool; documentSymbolProvider: bool; workspaceSymbolProvider: bool; - codeActionProvider: bool; + codeActionProvider: codeActionOptions; codeLensProvider: codeLensOptions option; documentFormattingProvider: bool; documentRangeFormattingProvider: bool; @@ -301,6 +301,10 @@ module Initialize : sig and signatureHelpOptions = { sighelp_triggerCharacters: string list } + and codeActionOptions = + | CodeActionBool of bool + | CodeActionOptions of { codeActionKinds: CodeActionKind.t list } + and codeLensOptions = { codelens_resolveProvider: bool } and documentOnTypeFormattingOptions = { diff --git a/src/hack_forked/utils/lsp/lsp_fmt.ml b/src/hack_forked/utils/lsp/lsp_fmt.ml index 71450d2a051..79c5d0c6f56 100644 --- a/src/hack_forked/utils/lsp/lsp_fmt.ml +++ b/src/hack_forked/utils/lsp/lsp_fmt.ml @@ -969,7 +969,19 @@ let print_initialize (r : Initialize.result) : json = ("documentHighlightProvider", Some (JSON_Bool cap.documentHighlightProvider)); ("documentSymbolProvider", Some (JSON_Bool cap.documentSymbolProvider)); ("workspaceSymbolProvider", Some (JSON_Bool cap.workspaceSymbolProvider)); - ("codeActionProvider", Some (JSON_Bool cap.codeActionProvider)); + ( "codeActionProvider", + Some + (match cap.codeActionProvider with + | CodeActionBool b -> JSON_Bool b + | CodeActionOptions { codeActionKinds } -> + JSON_Object + [ + ( "codeActionKinds", + JSON_Array + (List.map + ~f:(fun k -> JSON_String (CodeActionKind.string_of_kind k)) + codeActionKinds) ); + ]) ); ( "codeLensProvider", Base.Option.map cap.codeLensProvider ~f:(fun codelens -> JSON_Object [("resolveProvider", JSON_Bool codelens.codelens_resolveProvider)]) diff --git a/src/lsp/flowLsp.ml b/src/lsp/flowLsp.ml index 6454afb94ae..eff2297a7ca 100644 --- a/src/lsp/flowLsp.ml +++ b/src/lsp/flowLsp.ml @@ -472,7 +472,7 @@ let send_lsp_to_server (cenv : connected_env) (metadata : LspProt.metadata) (mes (************************************************************************) let do_initialize flowconfig : Initialize.result = - let code_action_provider = FlowConfig.autofix_exports flowconfig in + let code_action_provider = Initialize.CodeActionBool (FlowConfig.autofix_exports flowconfig) in Initialize. { server_capabilities =