- Notifications
You must be signed in to change notification settings - Fork0
Official VSCode plugin for ReScript
License
cknitt/rescript-vscode
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The official VSCode plugin for ReScript.
Youmust haverescript >=9.1 orbs-platform >=8.3.3 installed locally in your project, through the usualnpm installation. Older versions are not guaranteed to work.
Our highlighting works well with most popular VSCode themes, such as:
- Dark+ (default dark), Light+ (default light)
- Solarized Dark, Solarized Light
- Monokai Dimmed
- Tomorrow Night Blue
- One Dark Pro
The only 2 themes we don't (and can't) support, due to their lack of coloring, are:
- Dark (Visual Studio), Light (Visual Studio)
If your custom theme doesn't seem to highlight much (e.g. no colors for upper-case JSX tag, no distinction between module and variant), try one of the recommended themes to see if that's the problem. For more info, seethis post.
The plugin's onVSCode Marketplace. In VSCode,cmd-shift-p -> "Install Extensions", then find "rescript-vscode".
The plugin activates on.res and.resi files. If you've already got Reason-Language-Server installed, it's possible that the latter took precedence over this one. Make sure you're using this plugin ("ReScript syntax") rather than Reason-Language-Server ("BuckleScript syntax").
- Supports
.res,.resiandbsconfig.json. - Syntax highlighting.
- Formatting, with caveats:
- Currently requires the file to be part of a ReScript project, i.e. with a
bsconfig.json. - Cannot be a temporary file.
- Currently requires the file to be part of a ReScript project, i.e. with a
- Build diagnostics.
- Built-in bsb watcher (optional, and exposed explicitly as a pop-up; no worries of dangling build).
- Type hint hover.
- Jump to definition.
- Autocomplete.
- Find references.
- Rename.
- Snippets to ease a few syntaxes:
externalfeatures such as@bs.moduleand@bs.valtry,for, etc.
- Folding, andcustom folding through
//#regionand//#endregion.
Creates an interface file (.resi) for the current.res file, automatically filling in all types and values in the current file.
Opens the compiled JS file for the current ReScript file.
Switches between the implementation and interface file. If you're in a.res file, the command will open the corresponding.resi file (if it exists), and if you're in a.resi file the command will open the corresponding.res file.
This can also be triggered with the keybinding
Alt+O.
The Code Analyzer is a mode in the extension that runs additional code analysis in your project. The analysis helps you find dead code at a granular level, find unhandled exceptions, and more.
The Code Analyzer usesreanalyze, which is embedded in the extension, so you don't need to install anything extra to run it.
You'll need to configure what code analysis you want to run, and what (if any) directories you want to ignore. Configuration is done via addingreanalyze inbsconfig.json. You'll get autocomplete for what configuration options are valid. You can also readall about configuringreanalyze here.
The Code Analyzer needs to be started manually by default. However, you can configure the extension to start the Code Analyzer automatically via the settingrescript.settings.autoRunCodeAnalysis.
Open the command palette and run> ReScript: Start Code Analyzer. This will start code analysis in the ReScript project of the file you run the command from.
Dead code is highlighted in the editor, and code actions for suppressing dead code warnings are available in most cases.
When done, stop the code analysis mode by clicking theStop Code Analyzer button in the editor status bar. This will clear all reported analysis warnings.
Currently does not work for full monorepo dead code analysis (although it should work for each monorepo package individually).
You'll find all ReScript specific settings under the scoperescript.settings. Open your VSCode settings and typerescript.settings to see them.
If there's no ReScript build running already in the opened project, the extension will prompt you and ask if you want to start a build automatically. You can turn off this automatic prompt via the settingrescript.settings.askToStartBuild.
You can configure VSCode to collapse the JavaScript files ReScript generates under its source ReScript file. This will "hide" the generated files in the VSCode file explorer, but still leaving them accessible by expanding the source ReScript file they belong to.
Open your VSCode settings and typeeditor.filenesting. Enable the feature and scroll down to patterns.
The example has two patterns added:
This nests implementations under interfaces if they're present and nests all generated files under the main ReScript file. Adapt and tweak to your liking.
A screenshot of the result:
This repo also contains a language server that can power other editors.However, the language server in this project is a pure implementation detail. We don't guarantee its stability for other editors' consumption apart from Vim and Sublime Text.
Still, if you'd like to use this language-server with other editors:
- Get the release binaries from the Github Releases page.
- Unzip the
.vsixand get theserverfolder. That's the only folder you need. - The language server will be at
server/out/server.js. Call it through node, and optionally pass--stdioif your editor doesn't support the default JSONRPC.
About
Official VSCode plugin for ReScript
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Languages
- ReScript60.2%
- OCaml32.7%
- TypeScript6.7%
- Shell0.2%
- Makefile0.2%
- Rust0.0%


