rescript-lang / rescript-vscode Goto Github PK
View Code? Open in Web Editor NEWOfficial VSCode plugin for ReScript
License: MIT License
Official VSCode plugin for ReScript
License: MIT License
Taking an example from the documentation, this snippet:
let drawCircle: (~color: color, ~radius: int=?, unit) => unit =
(~color: color, ~radius: option<int>=?, ()) => {
setColor(color)
switch radius {
| None => startAt(1, 1)
| Some(r_) => startAt(r_, r_)
}
}
highlights >=
as an operator, rather than as a closing bracket for the generic and an equal sign. This happens in VS Code as well:
This is particularly problematic for those who use ligature fonts, as ligatures depend on proper coloring to break up things that look like ligatures but really aren't.
Is the tokenizer/grammar that colors this defined here, or in another repository?
Using 1.0.4
on macOS.
Hovering on labelled arguments does not produce any results. Here's an example in code:
type cfg = {content: string}
let someFunction = (
~process: string => string,
~anotherSubFunction: cfg => string,
content: string,
) => {
anotherSubFunction({content: content->process})
}
// Hovering `process` or `anotherSubFunction` here gives no results. I'd expect `string => string` and `cfg => string` (ideally with `cfg` expanded in the hover too).
let x = someFunction(~process=s => s, ~anotherSubFunction=({content}) => content, "hello")
A repro is available in code here: https://github.com/zth/rescript-editor-tooling-playground/blob/master/src/FunctionHoverIssues.res
Please add an option for configuring the format width (like Reason Language Server had with reason_language_server.format_width
).
This is a feature request/idea that I'm sure you're already well aware of, but I'll go ahead and add it here anyway. Two things that I think would greatly enhance the experience of using ReScript day-to-day is:
I've included a "repro"/examples of what I mean here: https://github.com/zth/rescript-editor-tooling-playground/blob/dd7dd23fd58270683e91dd6e57898e6e40e212d4/src/AutoComplete.res
I understand this is probably non-trivial. But, the type of "exploratory" autocompletion it enables is something that I think is one of the absolute best aspects of the editor integration of for example TypeScript.
VS Code provides a contribution point for json schemas. Using this would avoid the need for a $schema
property in the bsconfig.json (which currently is a bit broken, since the schema doesn't allow for a $schema
property.....). All that would be necessary is the addition of
"jsonValidation": [
{
"fileMatch": ".jshintrc",
"url": "https://json.schemastore.org/jshintrc"
}
]
to the contributions.
Steps to reproduce:
The file is not formatted. (Might be due to the buffer being in memory and not yet written to disk?)
this might be a duplicate of #34. I post it as a new issue since it has nothing to do with Angular or a specific project.
Description: VS Code does not update errors (or the lack of) from the complier-log. Neither Problem-View nor "red underlines".
Since this a very basic function, I suspect it has to do with my environment which is Node 14, Ubuntu 20.04 and VSCode 1.52. I used a new clean build of VSCode and only installed rescript-vscode 1.0.2.
Steps: See the the Video to reproduce
Observations:
Thanks so much for all your hard work. Let me know, if I can do anything to help track down the issue. (I'm very dedicated, this is the only issue that prevents my team to switch to ReScript).
With ts, flow or reason-language-server, you can find compilation/types errors in the error panel of VScode, not just as inline errors in files.
This is very handy to quickly knows if you project is "ok & running well" or not, without having to check all files or console or browser/simulators (without even being sure it's "up to date").
Here is a project with a "Problem" with RLS.
Note bottom bar (on the left) where you have the counter of errors/warnings.
This is not the case with rescript-vscode 1.0.0. Would be nice to have support for this.
I'd like to propose a special "go-to-definition" for navigating JSX
components.
In the previous LSP it is really cumbersome to go to a definition for any JSX element.
It's very common (at least for me) to create components with a lot of submodule components. Whenever I follow a definition in some JSX using a parent component, I land at the beginning of the target module and I need to manually find the make function (which is tedious, since each submodule also implements a make function as well, so regex find is not a straightforward option)
Given following example:
let a = <div>
<MyComponent text="test"/>
</div>
I'd expect following behavior:
React JSX enabled
MyComponent
, it should point to the @react.component
make function, instead of the module definitiontext
argument of MyComponent
, it should point to the ~text
argument in the make
functionReact JSX disabled
MyComponent
should point to MyComponent.createElement
text
should point to the labeled argument text
in let createElement = (~text,...)
<MyComponent.SubComponent> ... </MyComponent.SubComponent>
Definitions of MyComponent
and SubComponent
should be able to be followed separately, depending on what element was selected.
@react.component
type props = {
"text": string // The labeled argument is equivalent to this line
};
let makeProps = ...
// Plain function (happens sometimes)
let make = (props) => {
...
}
Here we can't really point to labeled arguments, so when a labeled argument is navigated, I am not sure if it should point to the attribute within the props
type, or the props
argument within the make
function itself. I guess the latter is easier, and good enough.
Would the maintainers be open to regularly publishing releases to Open VSX so that VSCode compatible editors like Onivim2 may leverage the latest versions of this extension?
Thanks for the great extension!
Js.log ("hel")
let a = 1 + 2
let u = [1,2]
let v = u + 3
The problem panel is empty.
lib/bs/.compiler.log is correct
#Start(595963434)
We've found a bug for you!
C:\Users\hongbozhang\git\hello\src\demo.res:10:9
8 โ let u = [1,2]
9 โ
10 โ let v = u + 3
11 โ
This has type: array<int>
Somewhere wanted: int
#Done(595964572)
Version 1.0.2
on macOS.
It seems documentation written with @ocaml.doc()
doesn't format properly when shown in VSCode. This example code:
@ocaml.doc(`This is a comment that's supposed to show up when hovering the value below. Hover this binding inside of DocIssues.res.
Note that line breaks are displayed as \n rather than as an actual line break when hovering.
## That fact seems to...
...break some of the markdown capabilities too.
`)
let getTestInt = () => 123
Notice that line breaks are printed as-is rather than as line breaks. Unsure whether this is the main issue/only issue. However, when broken line breaks do not interfere, markdown formatting etc seems to work just fine.
Hi,
Syntax highlighting of nested comments is broken:
/*
let foo = 1
/*
let bar = 1
*/
let baz = 1
*/
GitHub has the same problem, so the code block above is a good demonstration. The compiler seems to support nested comments.
When formatting on Windows I get this error:
[Error - 20:56:35] Request textDocument/formatting failed.
Message: Cannot find a nearby node_modules\bs-platform\win32\bsc.exe. It's needed for formatting.
Code: -32600
I found the cause of the error in:
// TODO: remove this hack
let filePath = openFile.replace('file://', '');
because just removing the file://
prefix isn't enough in Windows. On my system filePath
contains \c%3A\Users\Alberto\workspace\rescript-vscode\node_modules\bs-platform\win32\bsc.exe
which isn't recognized by NodeJS's APIs.
I think it makes sense to support stdout and/or tcp since many language servers do not support node ipc.
related: rescript-lang/vim-rescript#20
๐
Thanks for making this project! With all of the tooling surrounding ReScript/ReasonML/OCaml being very hard to use, it would be nice if this package could work on all of the supported syntaxes. That would make the IDE/tooling experience much nicer.
We can finish the indexing of auto-completions for stdlib/belt , so that auto-complete for such modules could be done immediately
Hi, seems like moving to this extension from Reasonml introduces much worse experience in syntax highlighting. (less things are highlighted, and in general it looks "less")
Before i go ahead and try to improve it, is someone working on this?
(last time i tried to improve something my work got turned down since someone already worked on it, dont want to waste my time again)
On the same theme as https://github.com/rescript-lang/rescript-vscode/issues/64, I think autocompleting labelled arguments would be very valuable.
So, let someVar = someFunc(~
would autocomplete a list of all (unused) labelled arguments for someFunc
.
I've included a sample of what I mean at the bottom of this file:
I ran into a very annoying error message with ReasonReact where I had a typo in a prop (onKeypress
instead of onKeyPress
). The most valuable part of the error message is at the bottom and I couldn't see it.
module Button = {
@react.component
let make = (~count: int) => {
<button onKeypress={(_) => ()}> {msg->React.string} </button>
}
}
This problem has several facets:
I'm primarily a TS dev so I'm used to reading error messages from bottom to top, but I don't think it makes for the best experience - especially when compared to Rust for example.
rescript-vscode/server/src/server.ts
Line 291 in ba96a2f
E.g. this wouldn't work for monorepos that use yarn workspaces, b/c binaries are hoisted above the bsconfig's node_modules.
Hey โ
First of all, thank you everyone for your effort. Things have started to come together recently and I wanted to test how well this extension works. Looks like syntax highlighting is not complete. TextMate grammar file needs some more regexps/scopes to be able to deliver much "complete" highlighting experience. I'd like to contribute to this and I've even started ๐. I wonder If anyone working on this? If not, I'm gonna continue.
Also, semantic highlighting would be awesome! I'd like to contribute to that too but I haven't dig into the rescript-editor-support yet. I believe that is where the tokenization, type on hover process etc. occurs. Looks like we need that info to make semantic highlighting possible.
P.S: I have no experience in VSCode extension development, language servers etc. Just trying to help and learn new things.
Using 1.0.4
on macOS.
Doc strings added on record members/fields does not seem to show. A reproduction + explanation of the issue is available here: https://github.com/zth/rescript-editor-tooling-playground/blob/cf6a19321973051e03445291a6bd2da22d91b3be/src/HoverIssues.res
If VSCode is running with ReScript files already open when returning from sleep, the bsb build is not running and the "Start Build" dialog does not appear.
Expected: Modifying a ReScript file makes plugin to realize the build is not running and it pops the dialog
Workarouds:
Platform: Ubuntu 18.04
Using 1.0.2
on macOS.
In short, the editor does not show me doc strings for modules or nested modules. I have this:
@ocaml.doc("This hover does not show up for the top level module.")
module Nested = {
let x = "123"
@ocaml.doc("...and neither does this hover")
module NestedAgain = {
let y = 123
}
}
And hovering Nested
or NestedAgain
from another file (like SomeModule.Nested
or SomeModule.Nested.NestedAgain
) does not show the attached doc strings.
Here's a commit that details the issue: zth/rescript-editor-tooling-playground@5f484ba
This is a feature request to add folding regions to .res
files:
Folding Regions
According to VSCode docs:
To have region markers configured for your language, contact the language extension provider.
It would be a really helpful feature to organise larger files.
The outline is not working when I focus on a .res
file.
it does work when I use a .re
Without this, it is hard to navigate long files.
Edit
Another benefit of the Outline is that you can search symbols with Cmd-shift-o
in this screenshot shows the spotlight to search symbols, although in Rescript files is currently not working.
One of the hardest thing in ReScript is finding the right magic of annotations. i find myself always looking at other libs and examples. just because there's no logic to it and very little organization(it's all under bs namespace).
One thing that might REALLY help is allowing us to just type
@bs. and have a list of all supported annotations with a helping text as to how to use them, when, and alternatives.
I think this is super important, i know for myself i would be able to write better bindings if some love was invested in this area, and good bindings are sorely missing in the rescript ecosystem.
Awesome v1 release!!! super pumped at the new direction ReScript is going!
After migrating a few Reason files to the ReScript syntax, I noticed that the Tailwind CSS IntelliSense (e.g. autocomplete, linting, hover previews, syntax highlighting) provided via the Tailwind CSS VS Code extension does not appear to work for res
files. I'm not certain as to whether this would be an issue with rescript-vscode
or vscode-tailwindcss
, but I figured I'd open an issue here to hopefully identify the issue origin. Thanks!
Reason Syntax | ReScript Syntax |
---|---|
![]() |
![]() |
I'm not sure if it's a problem with my setup or something that hasn't been implemented yet but it would be great to have some sort of autocomplete. I don't see it on the feature list so I'm assuming it's not there yet. I'm only starting to look at rescript so it's very possible that I've missed something too. Thanks very much!
I'm getting this error in a popup, after about 7s after clicking the button:
Error processing attach: Error: Could not connect to debug target at http://localhost:6009: Promise was canceled
at e (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:1:103397)
at async t (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:59:47354)
at async P.launch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:1:126302)
at async t.Binder.captureLaunch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:59:127629)
at async t.Binder._launch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:59:127180)
at async Promise.all (index 5)
at async t.Binder._boot (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:59:126440)
at async t.default._onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:1:110922)
The extension development host
window does open and stay open.
Tested on Windows 10, Mac MacOS 10.13.6 High Sierra.
1.51.1
rescript-vscode
version 1.0.0
bs-platform
version 8.3.3
When opening any res
file the output of the language server throws an exception and nothing seems to work.
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:89:31
at ChildProcess.exithandler (child_process.js:295:7)
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)
[Error - 23:47:10] Connection to server got closed. Server will not be restarted.
[Error - 23:47:10] Request textDocument/completion 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)
It seems like the type diagnostics on hover are assuming my mouse to be on top of a completely different expression.
In the following screenshot I am hovering over the addEventListener
but the type diagnostics say that i am hovering over Belt.Option
. (Which is 5 rows above and to the right of where I am actually hovering).
Modified a buffer with the following contents:
let serverFunction = (. req, res) => {
Js.log(req.path)
switch req.path {
| "/stylesheet.css" =>
let markup = ReactDOMServer.renderToStaticMarkup(<Hello />)
res.send(. markup)
| _ =>
}
I was expecting to see a syntax error after hitting format, but nothing happened
Currently, the language server crashes for me when I work on a remote server (via a Remote - SSH plugin), with the following message:
Error: Command failed: /home/sergey/.vscode-server/extensions/chenglou92.rescript-vscode-1.0.2/server/linux/rescript-editor-support.exe dump /home/sergey/monorepo/frontend/packages/product-calendar/src/components/PcLink.res:19:14
Fatal error: exception Sys_error("/tmp/lsp.log: Permission denied")
And this is because /tmp/lsp.log
is created and owned by my teammate, not by me. Deleting the file resolves the problem.
But even if we figure out the file permissions, won't it mean that only one person at a time is able to work at one particular machine? That would be unfortunate because the server is meant to be used for development by many people at once.
It pops up every time when a file is opened.
I don't even know what this notification means.
There should be an option for disabling this notification (in fact, every notification)
This is just annoying.
This is using 1.0.2
on macOS.
In summary - hovering nested record members seems to show the wrong information (some form of off-by-one error). Here's a reproduction case with comments on what's happening: https://github.com/zth/rescript-editor-tooling-playground/blob/master/src/HoverIssues.res
I posted about this on the RLS repo as well way back, so it's probably originally an issue in RLS: jaredly/reason-language-server#419
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.