The Official VSCode plugin for ReScript
You must have ReScript >= 9.1 installed locally in your project, through the usual npm or yarn installation. Older versions are not guaranteed to work.
Our highlighting works well with most popular VSCode themes, such as:
The only 2 themes we don't (and can't) support, due to their lack of coloring, are:
Note 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, see this post.
.res
, .resi
, rescript.json
and the legacy config file bsconfig.json
.external
features such as @bs.module
and @bs.val
try
, for
, etc.//#region
and //#endregion
.Launch VS Code Quick Open (Ctrl+P
), paste the following command, and press enter.
ext install chenglou92.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").
There is a pre-release channel available. It is intended for testing new and therefore possibly unstable features. You can activate it by clicking on the "Switch to Pre-Release Version" button on the rescript-vscode
extension page in VSCode. From this point on, pre-release versions will always have an odd version minor (1.5.x, 1.7.x, 2.1.x, etc.) while stable releases have even version minor numbers (1.4.x, 1.6.x, 2.0.0, etc.).
Even if the pre-release channel seems too experimental to you, we still suggest you to give it a try and submit any issues that you run into. In the long run it will give us a better editor experience overall.
Command Description ReScript: Create an interface file for this implementation file Creates an interface file (.resi
) for the current .res
file, automatically filling in all types and values in the current file. ReScript: Open the compiled JS file for this implementation file Opens the compiled JS file for the current ReScript file. ReScript: Switch implementation/interface 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
. ReScript: Start Code Analyzer This will start code analysis in the ReScript project of the file you run the command from.
You'll find all ReScript specific settings under the scope rescript.settings
.
rescript.settings.askToStartBuild
. ReScript Binary Path The extension will look for the existence of a node_modules/.bin/rescript
file and use its directory as the binaryPath
. If it does not find it at the project root (which is where the nearest rescript.json
resides), it goes up folders in the filesystem recursively until it either finds it (often the case in monorepos) or hits the top level. To override this lookup process, the path can be configured explicitly using the setting rescript.settings.binaryPath
ReScript Platform Path The extension will look for the existence of a node_modules/rescript
directory and use the subdirectory corresponding to the current platform as the platformPath
. If it does not find it at the project root (which is where the nearest rescript.json
resides), it goes up folders in the filesystem recursively until it either finds it (often the case in monorepos) or hits the top level. To override this lookup process, the path can be configured explicitly using the setting rescript.settings.platformPath
Inlay Hints (experimental) This allows an editor to place annotations inline with text to display type hints. Enable using rescript.settings.inlayHints.enable: true
Code Lens (experimental) This tells the editor to add code lenses to function definitions, showing its full type above the definition. Enable using rescript.settings.codeLens: true
Signature Help This tells the editor to show signature help when you're writing function calls. Enable using rescript.settings.signatureHelp.enabled: true
Default settings:
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.
Configuring the Code AnalyzerThe Code Analyzer uses reanalyze, 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 adding reanalyze
in rescript.json
. You'll get autocomplete for what configuration options are valid. You can also read all about configuring reanalyze
here.
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 the Stop 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 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 type:
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:
See CHANGELOG
Read our Contributing Guide
See the LICENSE file for details.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4