Vim runtime files for ReScript.
If you are experiencing any troubles, open an issue or visit our Forum and ask for guidance.
- Syntax highlighting for ReSript files
- Filetype detection for
.res,.resi - Basic automatic indentation
See :h rescript for the detailed helpfile.
vim-rescript can be installed either manually or by using your favourite plugin manager.
" vim-plug
Plug 'rescript-lang/vim-rescript'
" Vundle
Plugin 'rescript-lang/vim-rescript'
" NeoBundle
NeoBundle 'rescript-lang/vim-rescript'-- vim.pack builtin, require neovim 0.12+
vim.pack.add { 'https://github.com/rescript-lang/vim-rescript' }
-- Lazy.nvim
{ 'rescript-lang/vim-rescript', ft = 'rescript' }You can also pin your installation to specific tags (check our releases here):
With Plug:
Plug 'rescript-lang/vim-rescript', {'tag': 'v3.0.0'}With Lazy.nvim:
{ 'rescript-lang/vim-rescript', tag = "v3.0.0" }First you need install the language server for ReScript from npm
Note If you are using mason.nvim you can install the ReScript Language Server using the command
MasonInstall rescript-language-server
Or intall using npm:
npm install -g @rescript/language-serverThe binary is called rescript-language-server
Install the nvim-lspconfig package and setup the LSP
vim.lsp.config("rescriptls", {})
vim.lsp.enable("rescriptls")For more details, see server configuration
(:h rescript-coc)
After the installation, open your coc config (:CocConfig) and add the following configuration:
"languageserver": {
"rescript": {
"enable": true,
"module": "rescript-language-server",
"args": ["--node-ipc"],
"filetypes": ["rescript"],
"rootPatterns": ["rescript.json", "bsconfig.json"]
}
}Tree-sitter is a parser generator tool and incremental parsing library. Unlike regex-based syntax highlighting, Tree-sitter builds a full concrete syntax tree for a source file and updates it incrementally as you type. In Neovim, this enables more accurate, context-aware highlighting, smarter text objects, and structural navigation — none of which are possible with pattern matching alone.
Neovim supports three distinct highlighting mechanisms that can be used independently or layered on top of each other:
-
Regex-based syntax (
:h syntax) — The classic Vim approach. Syntax rules are defined as regex patterns in.vimfiles. This is whatvim-rescriptprovides by default and works in both Vim and Neovim without any additional dependencies. -
Tree-sitter (
:h treesitter) — Available since Neovim 0.5. Uses a parsed AST instead of regex patterns, producing more precise and context-aware highlighting. Requires a compiled parser for each language. This plugin ships Tree-sitter highlight queries in thequeries/rescript/directory, which Neovim loads automatically once a ReScript parser is installed. -
LSP semantic tokens (
:h lsp-semantic_tokens) — Available since Neovim 0.9. The language server sends token data with semantic information about each symbol (e.g. distinguishing a local variable from a type alias or a module name). These are applied on top of Tree-sitter or regex highlights and provide the highest level of semantic accuracy.
When all three are active, they layer in that order: regex forms the base, Tree-sitter overrides it with structural context, and LSP semantic tokens refine it further with type information from the compiler.
Neovim does not ship a ReScript parser. You need to install one separately.
nvim-treesitter is archived, meaning it no longer receives updates, but it still works and remains the most common way to install and manage parsers. Install it as a regular plugin.
Now, overwrite the parser config information to install the latest version of parser.
---@type ParserInfo
local rescript_parser = {
install_info = {
revision = 'v6.0.0',
url = 'https://github.com/rescript-lang/tree-sitter-rescript',
queries = 'queries/'
},
}
vim.api.nvim_create_autocmd('User', {
pattern = 'TSUpdate',
callback = function()
require('nvim-treesitter.parsers').rescript = rescript_parser
end,
})
require('nvim-treesitter.parsers').rescript = rescript_parserNow, open nvim and install using the command TSInstall rescript. Once a parser is installed, Neovim loads the Tree-sitter queries from this plugin automatically when you open a .res or .resi file.
- amirales: Started the plugin w/ syntax & indent functionality