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

Add instructions for LSP setup #3

Open
ryyppy opened this issue Nov 25, 2020 · 1 comment
Open

Add instructions for LSP setup #3

ryyppy opened this issue Nov 25, 2020 · 1 comment

Comments

@ryyppy
Copy link
Member

ryyppy commented Nov 25, 2020

Probably might be worth submitting a PR to the sublime-LSP repo, which apparently offers proper docs for each configurable language server.

(Example for Reason)

@ManBearTM
Copy link

ManBearTM commented Jul 16, 2021

As one of the dozen people using sublime with rescript, I thought I'd share my findings with getting LSP to work with ST4.

First of all you need to install the sublime-lsp package and rescript-sublime (this package).

Next step is to find the rescript language server. It is currently part of the rescript-vscode package. You can either follow the instructions here and place it somewhere on your computer (remember the path). Or if you already have vscode and rescript-vscode installed, you can do like me and just use the path to the extension directly: ~/.vscode/extensions/chenglou92.rescript-vscode-1.1.2/server/out/server.js.

Downside with the latter approach is that it will stop working if the vscode extension is updated. Upside is (also) that it will stop working if the vscode extension is updated, since you would otherwise need to manually check for updates. Ideally I'd like to see the language server become a separate package (with official support for sublime), but I understand why that is not a priority.

Once you have the path you need to open LSP.sublime-settings and add the client (replace PATH/TO/ with actual path):

{
  "clients": {
    "rescript": {
      "command": [
        "node",
        "PATH/TO/server.js",
        "--stdio"
      ],
      "enabled": true,
      "selector": "source.res | source.resi",
    }
  }
}

Now restart sublime and make sure that the compiler is also running (yarn start/npm start). Open a rescript file and see that the language server is now running (if not perhaps try the LSP: Troubleshoot server command).

You may notice that the syntax highlighting is not working. To get it working you need to open Preferences.sublime-settings and add the following configuration:

{
  "mdpopups.sublime_user_lang_map": {
    "rescript": [["rescript"], ["ReScript/rescript-sublime/ReScript"]],
  }
}

That should be all! I hope this can be of some use to the (probably few) people using sublime with rescript. I didn't want to make a PR to the sublime-LSP repo, since I don't feel like this package is quite ready for it yet (the rescript language server needs to officially support sublime and it should be bundled with the sublime package IMHO).

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

No branches or pull requests

2 participants