[ANN] Editor Plugin for VSCode and VIM officially released!

I think there are missing steps for the vim plugin installation instructions. I installed using vim-plug and added the coc configuration. Coc notified me that rescript language server failed 5 times within 3 minutes.
I tried running the server manually to see what might be wrong and it crashes with

Error: Cannot find module 'vscode-languageserver-protocol'

I had to go to the plugin and npm install manually in all the directories. Then it started working.

The plugin also adds around 15 seconds to the vim startup time which is weird. I understand that it’s hard with vim as this can be due to conflicts with some other plugins that I have installed. Just wonder if anybody else noticed this. Removing the plugin brings the startup time back to instant

Oh okay, probably forgot to check in all dependencies…will have a look at it tomorrow!
Regarding startup times I would need more context about your vim setup. Maybe let’s open an issue for that to discuss the details? (note: it shouldn’t add such long startup times, at least that’s something I never observed on my machine)

@alexeygolev I just released a new tagged v1.0.1 version on vim-rescript… can you clean your previous installation and try this Plug instruction?

  Plug 'rescript-lang/vim-rescript', {'tag': 'v1.0.1'}

This should fix the LSP dependency issue.

Not sure if this will fix your 15s issue though, since I believe this is caused by some weird vim plugin combinations, or at least caused by vim-coc… our vim plugin actually does nothing computation intensive, nor does it mess with your global configuration.

1 Like

what an amazing release!! and thank you so much for the clear communication! excited to see this community mature.going to try this all out on the weekend.

3 Likes

This is fantastic news @ryyppy. Thank you and the team so much for your work!

Had a go with this yesterday evening. Fantastic stuff. Thanks very much

Am I the only one that has issues with the VSCode plugin?

I tried on Windows 10 and MacOS Sierra and in both cases the plugin is crushing immediately.

The moment I open .res file:

image

undefined:1



SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\server\out\RescriptEditorSupport.js:58:31
    at ChildProcess.exithandler (child_process.js:311:5)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
[Info  - 20:51:01] Connection to server got closed. Server will restart.
[Error - 20:51:01] Request textDocument/hover failed.
Error: Connection got disposed.
	at Object.dispose (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\main.js:904:25)
	at Object.dispose (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-languageclient\lib\client.js:74:35)
	at LanguageClient.handleConnectionClosed (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-languageclient\lib\client.js:2309:42)
	at LanguageClient.handleConnectionClosed (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-languageclient\lib\main.js:155:15)
	at closeHandler (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-languageclient\lib\client.js:2296:18)
	at CallbackList.invoke (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\events.js:121:36)
	at closeHandler (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\main.js:240:26)
	at CallbackList.invoke (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\events.js:62:39)
	at Emitter.fire (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\events.js:121:36)
	at IPCMessageReader.fireClose (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\messageReader.js:111:27)
	at ChildProcess.<anonymous> (c:\Users\Mickey\.vscode\extensions\chenglou92.rescript-vscode-1.0.0\client\node_modules\vscode-jsonrpc\lib\messageReader.js:213:45)
	at ChildProcess.emit (events.js:228:7)
	at maybeClose (internal/child_process.js:1021:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

I have opened an issue https://github.com/rescript-lang/rescript-vscode/issues/25 2 days ago.

Am I doing something wrong?

Thank you.

The plugin works now. The startup delay isn’t there for anymore…maybe it was a fluke:) Thank you!

Try to build first. There’s a fix for this case in master.

@cristianoc, what do you mean?

npm run build

Does not help. Same errors.

The issue observed with Windows is tracked here: https://github.com/rescript-lang/rescript-vscode/issues/25
The fix will be applied in the forthcoming bug-fix release.

The issue observed with Windows is tracked here: https://github.com/rescript-lang/rescript-vscode/issues/25
The fix will be applied in the forthcoming bug-fix release.

Some first impression feedback (I have shared that on Discord first before I remembered that we want to focus discussion on here):

Pro:

  • Blazing fast
  • Really helpful error messages (esp. for things like misspelled poly variants, also the suggestions for primitive type conversion are pure gold)
  • Navigates exactly where I expect so far (even deep into node_modules & *.re files)
  • Great global autocompletion
  • Record autocompletion ( :heart: )
  • The automatic build runner for VSCode is really convenient
  • Everything works / completes / navigates perfectly fine with ppx involvement

Cons / Problems:

  • None so far, just works
    ( - Just found one tiny thing: missing some auto completion inside the scope of an open statement, no big deal)

Things that would hit it right out of the park in the future:

  • Autocompletion of JSX props
  • Go to definition for JSX props
  • Autocompletion for Js.t inside the [""] where possible (probably a lot of work for not too much benefit?)
  • Autocompletion for poly variants if the type is known and properly constrained (for example inside a switch / function argument)
  • Type info / go to definition Js.t inside the [""]
  • Autocompletion for (at least the default ones for bindings) @ annotations like @module

To summarize: Holy cow guys - this is how it was supposed to feel like all along - love it.

Edit: Good news, installing the *.vsix directly into Onivim 2 works flawlessly as well (even the build runner popup, that’s pretty cool).

8 Likes

100% agree with @jsiebern, exceeds expectations! I think this is a huge step in the right direction. We converted our whole codebase to .res already!

Another point that would improve the editor experience (which is a slight regression) is the ability to work not only after save but also while typing.

3 Likes

You can achieve this behaviour with a little workaround:

3 Likes

Is anyone able to get this working in a mono repo using yarn workspaces?

Language server works just fine, but the RescriptFormat command will not work:

rescript format returned an error

If anyone else is having this issue, I believe I have a quick fix PR up that will allow your workspaces project to work :slight_smile:

Let me know if you have any issues or if this fixes your issue!

Update: https://github.com/rescript-lang/vim-rescript/pull/19

Plug 'rescript-lang/vim-rescript', {'branch': 'monorepo-support'}

Sorry for reopening the post, but thanks! That just made my rescript experience faaar better. Maybe this could be in the vscode plugin docs instead of lost in this comment thread? It would be very helpful for beginners coming from ts like me :slight_smile:

1 Like

I think PRs are always appreciated :wink: