-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add reason language to ast_editor #1685
base: master
Are you sure you want to change the base?
Add reason language to ast_editor #1685
Conversation
Can we think of a way of having this feature without making the plugin on reason? In the past, I've found the the dependency on reason to be rather disruptive to development. I would much prefer if we had a way to extend this plugin so that you could reason support externally. |
Do you have any idea of how "extending the plugin" would work in terms of VSCode packaging, APIs, etc.? Or are you talking about like an ocamlmerlin-reason integration, or to have "reason" installed in the host? The OCaml platform already supports syntax highlight for Reason files, and I personally find it useful to have a better integration with Reason, such as converting between syntaxes built-in visiting the AST or ppx output. What are the problems of reason as a dependency on development? Maybe we can fix those? |
The problem is that the reason package is not actively maintained, and the version in opam has historically lagged behind. This is particularly painful for a package that depends on the internals of the compiler. I don't really have a concrete idea on how to work around this. I was hoping that you would think of something. One simple approach is to call out to a reason binary to dump the parsetree |
Oh, reason has been very maintained this past years (since 2022), and we plan to keep it that way: https://github.com/reasonml/reason/releases releases are pushed to opam only. Sure, there might be other options, but it faces problems with compatibility (that a package manager like opam fixes for us) and other issues. Happy to commit to keep ocaml-platform up-to-date as dependency of Reason. |
Happy to hear reason is being maintained again. While that certainly makes this more risky, the fact that reason is barely used, makes the reward for taking such a risk less enticing. Merlin and lsp both support reason without a hard dependency. I'd hate to improvish the vscode extension with such a dependency. |
a9db2e6
to
12e48b6
Compare
@rgrinberg, it turned out that I was overcomplicating it; Ast can handle |
src/ast_editor.ml
Outdated
let file_name = | ||
match Pp_path.get_kind ~document with | ||
| Structure `Reason -> | ||
String.chop_suffix_exn ~suffix:".re" (TextDocument.fileName document) | ||
^ ".ml" | ||
| Signature `Reason -> | ||
String.chop_suffix_exn ~suffix:".rei" (TextDocument.fileName document) | ||
^ ".mli" | ||
| _ -> TextDocument.fileName document | ||
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.
In the future we can use the refmt executable to convert it from ocaml to reasonml.
src/ast_editor.ml
Outdated
match Pp_path.get_kind ~document with | ||
| Structure `Reason -> | ||
String.chop_suffix_exn ~suffix:".re" (TextDocument.fileName document) | ||
^ ".ml" | ||
| Signature `Reason -> | ||
String.chop_suffix_exn ~suffix:".rei" (TextDocument.fileName document) | ||
^ ".mli" | ||
| _ -> TextDocument.fileName document |
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.
Since this relies on dune and isn't straight forward to understand reading the code, would you add a comment explaining that .ml is present at the same location as the .re file, etc?
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.
This part is related to creating the PP doc preview. It establishes a preview file with ocaml syntax, but as the current file can be a .re
, I change it here to fit the ocaml syntax.
As I said in this comment, later we can convert this content from ocaml syntax to reasonml, and this change of extension will not be needed anymore.
12e48b6
to
8d013db
Compare
package.json
Outdated
@@ -1269,6 +1269,7 @@ | |||
"@vscode/vsce": "3.2.1", | |||
"esbuild": "0.24.0", | |||
"ovsx": "0.10.1", | |||
"parcel": "2.13.2", |
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.
Missadded it, going to remove.
@pedrobslisboa You have to add a change log entry as well. |
True, thank you. I'm going to fix it as well |
8d013db
to
c43108a
Compare
@smorimoto Done, ready for review |
de7ad0d
to
0f60ca2
Compare
0f60ca2
to
55e2a05
Compare
Description
This PR adds reasonml to ast_editor to be able to see AST and Pp
Screenshots
Working with both ocaml and reason
How to test
vscode-ocaml-platform/CONTRIBUTING.md
Line 27 in 88cbda6
.re
file.pp.ml
file