New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signature Help #1720
base: master
Are you sure you want to change the base?
Signature Help #1720
Conversation
@voodoos, I've rebased this branch and it should be good for review |
Thanks Rafal ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I made a first round of review (with maybe some nitpicking. Feel free to discard comments if you find it not relevant)
|
||
let active_parameter_by_arg ~arg params = | ||
let find_by_arg = function | ||
| { argument = Some a; _ } when a == arg -> true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not particularly familiar with the structure of a
, but do we really want physical equality (rather than structural equality?).
| _ -> None | ||
|
||
module String = struct | ||
include String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to include String
(as you can always reference Stdlib.String
if necessary) and inclusion doesn't seem to be useful "within the current String module"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also move these utilities to Merlin's Std.
let lsplit2 s ~on = | ||
match String.index_opt s on with | ||
| None -> None | ||
| Some i -> | ||
Some (sub s ~pos:0 ~len:i, sub s ~pos:(i + 1) ~len:(length s - i - 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about using Option.map
here?
let pos = | ||
match pos with | ||
| None -> 0 | ||
| Some pos -> pos + 1 | ||
in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let pos = (Option.value ~default:(-1) pos) + 1
?
val application_signature : | ||
prefix:string | ||
-> Mbrowse.t | ||
-> application_signature option | ||
|
||
val prefix_of_position : | ||
short_path: bool | ||
-> Msource.t | ||
-> Msource.position | ||
-> string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about moving (or duplicating) some of your meaningful comments from the .ml
to the .mli
as doc purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Rafal, I think this covers well the first step which was to bring the code from ocaml-lsp
to merlin-lib
.
You should also document the new command in the protocol file: https://github.com/ocaml/merlin/blob/master/doc/dev/PROTOCOL.md
Aditionnaly, it looks like the LSP protocol also provides additional optional parameters to help the server provide a correct answer: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_signatureHelp
May be we should also accept these even if they are not used right now ?
The goal of this PR is to upstream SignatureHelp functionality from ocaml-lsp to merlin. Similarly to #1286.