-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: dump all merlin config (#922)
Signed-off-by: Rudi Grinberg <[email protected]>
- Loading branch information
Showing
8 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
open Import | ||
open Fiber.O | ||
|
||
let command_name = "ocamllsp/show-merlin-config" | ||
|
||
let command_run server store = | ||
let* json = | ||
let+ docs = | ||
Document_store.fold store ~init:[] ~f:(fun doc acc -> | ||
match Document.kind doc with | ||
| `Other -> acc | ||
| `Merlin m -> m :: acc) | ||
|> Fiber.parallel_map ~f:(fun doc -> | ||
let+ config = Document.Merlin.mconfig doc in | ||
let config : Json.t = (Mconfig.dump config :> Json.t) in | ||
let uri = Document.uri (Document.Merlin.to_doc doc) in | ||
(Uri.to_string uri, config)) | ||
in | ||
let json = `Assoc docs in | ||
Format.asprintf "%a@.%!" Json.pp json | ||
in | ||
let uri, chan = | ||
Filename.open_temp_file | ||
(sprintf "merlin-config.%d" (Unix.getpid ())) | ||
".json" | ||
in | ||
output_string chan json; | ||
close_out_noerr chan; | ||
let req = | ||
let uri = Uri.of_path uri in | ||
Server_request.ShowDocumentRequest | ||
(ShowDocumentParams.create ~uri ~takeFocus:true ()) | ||
in | ||
let+ { ShowDocumentResult.success = _ } = Server.request server req in | ||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
open Import | ||
|
||
val command_name : string | ||
|
||
val command_run : _ Server.t -> Document_store.t -> unit Fiber.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters