You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OCaml's syntax can be puzzling for new users and sometime prove to be challenging to search on the internet due to the use of special characters. On the other hand, the manual and compiler's parsetree.mli provides useful comments when one knows where to look for: that is the name of the features.
The proposition is to add a command to Merlin that, given a certain OCaml syntax, will display the corresponding Parsetree node name and a documentation string. For example, on module F (M : T) = it will give the hints “Pmod_functor” and “Functor declaration: [functor(X : MT1) -> ME]”.
Tasks:
Boilerplate code to add a new command to the protocol and associated tests.
Identify the most interesting node around the cursor. (It would be natural to do it on the non-preprocessed AST for this feature, but Merlin only has utilities that work on the Typedtree.)
Lookup documentation for the interesting nodes, in the sources themselves and in a complementary table.
Update ocaml-lsp to also provide that information as a code action or in addition to the standard document request.
The text was updated successfully, but these errors were encountered:
After meeting with @voodoos, here are some ideas on how to get started with this issue.
Will need to create a new command new_commands that can look up documentation for the node currently under the cursor (or the most interesting node around the cursor)
Update the query_protocol to use this new command.
Develop some logic for this new command in query_commands
Update query_json to use this new command so we can parse the CLI and also display the result
Write a test case to verify the new command
On the question of if to work on the AST or the TypedTree, @voodoos indicates that this feature is really developed for the end user, who may likely not be very concerned with the semantics found in the Parsetree and perhaps the documentation or comments found in the parsetree may be of little help to end users.
So a possible implementation may require building on the TypedTree as it already contains most of the functions (such as getting cursor position and nodes etc) and also to ensure compatibility moving forward with changes to the Merlin codebase.
This may also involve providing some basic documentation for what's currently in the Parsetree.
A likely outcome when a user hovers will be something like:
Name: some name
Description: some description or definition
Documentation: https://v2.ocaml.org/...some link to the specific documentation for the node example: https://v2.ocaml.org/releases/5.1/htmlman/extensiblevariants.html
OCaml's syntax can be puzzling for new users and sometime prove to be challenging to search on the internet due to the use of special characters. On the other hand, the manual and compiler's
parsetree.mli
provides useful comments when one knows where to look for: that is the name of the features.The proposition is to add a command to Merlin that, given a certain OCaml syntax, will display the corresponding Parsetree node name and a documentation string. For example, on
module F (M : T) =
it will give the hints “Pmod_functor” and “Functor declaration: [functor(X : MT1) -> ME]”.Tasks:
ocaml-lsp
to also provide that information as a code action or in addition to the standarddocument
request.The text was updated successfully, but these errors were encountered: