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

OCaml (+ ReasonML) support #5316

Closed
maxkorp opened this issue Jul 6, 2022 · 10 comments
Closed

OCaml (+ ReasonML) support #5316

maxkorp opened this issue Jul 6, 2022 · 10 comments
Labels
feature [core label] language An umbrella label for all programming languages syntax behaviors potential extension Functionality that could be implemented as an extension (consider moving to community extensions) unsupported language

Comments

@maxkorp
Copy link

maxkorp commented Jul 6, 2022

Preliminarily, the TLDR basic request here is syntax and LSP support for OCaml and ReasonML (another syntax for OCaml).
I realize that this may need to be a third party extension, but perhaps all of this can provide context on what's required to support it by adding ones own LSP calls (as I think that's on the short term roadmap?).

In VSCode, this is provided by this extension: https://github.com/ocamllabs/vscode-ocaml-platform
That extension calls out to this LSP, which I'll describe installation of below: https://github.com/ocaml/ocaml-lsp

The minimum file syntax support would be for .ml, .mli, .re and .rei files which I believe is provided through the LSP. There are more related file types listed here: https://github.com/ocamllabs/vscode-ocaml-platform#features. Not sure if those are included via LSP or separately.

A bit more detail that I hope will be useful:
A bit of a note is that the ocaml toolchain is not typically installed directly but as a package by opam (the primary ocaml package manager, think nvm + npm), or sometimes esy (which also does venv-type sandbox stuff and also ties into actual npm).
Opam uses "switches" (think nvm use 12, but with names so you can many on the same version) which are either global or local. esy uses sandboxes (which can be defined with an esy.json file or inside of package.json iirc). The vscode extension allows you to switch to the sandbox you desire so it can run the appropriate LSP. Whatever solution comes soon for running one's own LSP would need a way to specify which switch to activate before running the lsp, unless starting the lsp is left to the user to do externally. There's also a need to pass flags to the LSP at times in a project, which again would need to be doable if this is controlled within zed.

Hopefully that wasn't more confusing than helpful!

@maxkorp maxkorp added feature [core label] triage labels Jul 6, 2022
@JosephTLyons JosephTLyons added the language An umbrella label for all programming languages syntax behaviors label Aug 23, 2022
@iamnbutler iamnbutler changed the title Language Support: OCaml (And ReasonML) OCaml (+ ReasonML) support Oct 13, 2022
@dangdennis
Copy link

I'm also interested in seeing OCaml support. Can you share any notes on how zed incorporates the various different lsp's? Looking at the python support doc, does zed install pyright if it's not yet installed, or does it also attempt to install it?

To get a simple but workable setup for OCaml development, I think we only need ocamllsp link and ocamlformat link.

VSCode's ocaml platform wraps a handful of other libraries like ocamlformat and sandboxing but it seems unnecessary to have out that out of the box.

@hovsater hovsater added the potential extension Functionality that could be implemented as an extension (consider moving to community extensions) label Apr 30, 2023
@smorimoto
Copy link

I want to see this combination as soon as possible!

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@smorimoto
Copy link

@huwaireb huwaireb mentioned this issue Jan 28, 2024
7 tasks
SomeoneToIgnore pushed a commit that referenced this issue Feb 2, 2024
This pull request implements support for the [OCaml
Language](https://ocaml.org/).

### Additions
- [x]
[tree-sitter-ocaml](https://github.com/tree-sitter/tree-sitter-ocaml)
grammar
- [x] Highlight, Indents, Outline queries
- [x] A new file icon for .ml(i) files. Based on
[ocaml/ocaml-logo](https://github.com/ocaml/ocaml-logo/blob/master/Colour/SVG/colour-transparent-icon.svg)
- [x] LSP Integration with
[ocaml-language-server](https://github.com/ocaml/ocaml-lsp)
- [x] Completion Labels
- [x] Symbol Labels

### Bug Fixes
- [x] Improper parsing of LSP headers. 

### Missing [will file a separate issue]
- Documentation on completionItem, requires: `completionItem/resolve`
with support for `documentation` as a provider.

### Screenshots

<details><summary>Zed</summary>
<img width="1800" alt="Screenshot 2024-02-01 at 03 33 20"
src="https://github.com/zed-industries/zed/assets/69181766/e17c184e-203e-40c3-a08f-4de46226b79c">
</details>

Release Notes:
- Added OCaml Support
([#5316](#5316)).

> [!NOTE]
> Partially completes #5316 
> To complete #5316:
> 1. addition of a reason tree-sitter grammar.
> 2. opam/esy integration, however it may be better as it's own plugin.
@JosephTLyons
Copy link
Collaborator

Since OCaml language support has landed in Zed, let's close this issue out and open a new issue for whatever else didn't make it in from the original request.

@davesnx
Copy link

davesnx commented Jun 8, 2024

Hey, do I need to open another issue for ReasonML?

Tree-sitter is here: https://github.com/reasonml-editor/tree-sitter-reason

@jpx40
Copy link

jpx40 commented Sep 7, 2024

Hey, do I need to open another issue for ReasonML?

Tree-sitter is here: https://github.com/reasonml-editor/tree-sitter-reason

just wanted to open a issue myself xd

@davesnx
Copy link

davesnx commented Sep 7, 2024

Go for it @jpx40

@jpx40
Copy link

jpx40 commented Sep 8, 2024

Go for it @jpx40

Do you know if u could add multiple treesitter in one extension maybe i could make a commit for the ocaml one, it's not worth to add a specific reason extension because of the lsp. It's the same as the ocaml one.

@Khady
Copy link

Khady commented Dec 3, 2024

@jpx40 I believe it is, the ocaml extension already has multiple ones

https://github.com/zed-extensions/ocaml/blob/f03fd28794a003e8f266eeb91f1483e438b07f7d/extension.toml#L13-L25

@jpx40
Copy link

jpx40 commented Dec 3, 2024

@Khady yeah, it would be nice to have reasonml as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [core label] language An umbrella label for all programming languages syntax behaviors potential extension Functionality that could be implemented as an extension (consider moving to community extensions) unsupported language
Projects
None yet
Development

No branches or pull requests

8 participants