|
1 |
| -# ReScript grammar for Tree-sitter |
| 1 | +# tree-sitter-rescript |
2 | 2 |
|
3 |
| -This repository contains a parser definition of the [ReScript](https://rescript-lang.org/) language for the [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) parser generator tool. |
4 |
| - |
5 |
| -Queries for text objects are also included which help you to navigate, select, and modify ReScript code syntactically. For NeoVim, the [`nvim-treesitter-textobjects`](https://github.com/nvim-treesitter/nvim-treesitter-textobjects) plugin is required to use Tree-sitter text objects. |
6 |
| - |
7 |
| -## Installation |
8 |
| - |
9 |
| -### Neovim |
10 |
| - |
11 |
| -If you want ReScript Tree-sitter in NeoVim, you will first need to register a new parser for it like so: |
12 |
| - |
13 |
| -```lua |
14 |
| -local parser_config = require("nvim-treesitter.parsers").get_parser_configs() |
15 |
| -parser_config.rescript = { |
16 |
| - install_info = { |
17 |
| - url = "https://github.com/rescript-lang/tree-sitter-rescript", |
18 |
| - branch = "main", |
19 |
| - files = { "src/parser.c", "src/scanner.c" }, |
20 |
| - generate_requires_npm = false, |
21 |
| - requires_generate_from_grammar = true, |
22 |
| - use_makefile = true, -- macOS specific instruction |
23 |
| - }, |
24 |
| -} |
25 |
| -``` |
26 |
| - |
27 |
| -This will make `TSInstall rescript` globally available. For more persistent approach you should add this parser to your Lua configuration. |
28 |
| - |
29 |
| -Default configuration detects `.res` and `.resi` files. You can confirm that it's correctly installed by invoking `:InspectTree` when you are in the ReScript file. |
30 |
| - |
31 |
| -- Notice that by default you will not see the highlighting! To enable highlighting, you will need to install this package either as a dependency or directly. |
32 |
| - |
33 |
| -If you are using `lazy.nvim` example configuration will look like so: |
34 |
| - |
35 |
| -```lua |
36 |
| - { |
37 |
| - "nvim-treesitter/nvim-treesitter", |
38 |
| - dependencies = { |
39 |
| - "rescript-lang/tree-sitter-rescript" |
40 |
| - }, |
41 |
| - opts = function(_, opts) -- this is needed so you won't override your default nvim-treesitter configuration |
42 |
| - vim.list_extend(opts.ensure_installed, { |
43 |
| - "rescript", |
44 |
| - }) |
45 |
| - |
46 |
| - local parser_config = require("nvim-treesitter.parsers").get_parser_configs() |
47 |
| - parser_config.rescript = { |
48 |
| - install_info = { |
49 |
| - url = "https://github.com/rescript-lang/tree-sitter-rescript", |
50 |
| - branch = "main", |
51 |
| - files = { "src/scanner.c" }, |
52 |
| - generate_requires_npm = false, |
53 |
| - requires_generate_from_grammar = true, |
54 |
| - use_makefile = true, -- macOS specific instruction |
55 |
| - }, |
56 |
| - } |
57 |
| - end, |
58 |
| - } |
59 |
| -``` |
60 |
| - |
61 |
| -- If you want it for other purposes, you probably know what to do. |
| 3 | +ReScript grammar for [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) |
62 | 4 |
|
63 | 5 | ## Contributing
|
64 | 6 |
|
|
0 commit comments