Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Signature Help #1720

wants to merge 1 commit into from

Conversation

3Rafal
Copy link
Collaborator

@3Rafal 3Rafal commented Jan 4, 2024

The goal of this PR is to upstream SignatureHelp functionality from ocaml-lsp to merlin. Similarly to #1286.

@3Rafal 3Rafal marked this pull request as ready for review January 8, 2024 07:53
@3Rafal 3Rafal requested a review from voodoos January 8, 2024 07:54
@3Rafal 3Rafal changed the title WIP: Signature Help Signature Help Apr 26, 2024
@3Rafal
Copy link
Collaborator Author

3Rafal commented Apr 26, 2024

@voodoos, I've rebased this branch and it should be good for review

@voodoos
Copy link
Collaborator

voodoos commented Apr 26, 2024

Thanks Rafal !

Copy link
Collaborator

@xvw xvw left a 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
Copy link
Collaborator

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
Copy link
Collaborator

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"?

Copy link
Collaborator

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.

Comment on lines +180 to +184
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))
Copy link
Collaborator

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?

Comment on lines +243 to +247
let pos =
match pos with
| None -> 0
| Some pos -> pos + 1
in
Copy link
Collaborator

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 ?

Comment on lines +16 to +25
val application_signature :
prefix:string
-> Mbrowse.t
-> application_signature option

val prefix_of_position :
short_path: bool
-> Msource.t
-> Msource.position
-> string
Copy link
Collaborator

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?

Copy link
Collaborator

@voodoos voodoos left a 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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants