Skip to content

Commit c379199

Browse files
TheFedaikinEmilios1995
authored andcommitted
feat(plugin): installation
update queries structure, add native nvim-treesitter.parsers instructions
1 parent 5ca149c commit c379199

File tree

6 files changed

+66
-2
lines changed

6 files changed

+66
-2
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,59 @@ Queries for text objects are also included which help you to navigate, select, a
88

99
## Installation
1010

11-
- If you want ReScript Tree-sitter in NeoVim, refer to [`nvim-treesitter-rescript`](https://github.com/nkrkv/nvim-tree-sitter-rescript/) installation notes;
11+
### Neovim
12+
13+
If you want ReScript Tree-sitter in NeoVim, you will first need to register a new parser for it like so:
14+
15+
```lua
16+
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
17+
parser_config.rescript = {
18+
install_info = {
19+
url = "https://github.com/nkrkv/tree-sitter-rescript",
20+
branch = "main",
21+
files = { "src/scanner.c" },
22+
generate_requires_npm = false,
23+
requires_generate_from_grammar = true,
24+
use_makefile = true, -- macOS specific instruction
25+
},
26+
}
27+
```
28+
29+
This will make `TSInstall rescript` globally available. For more persistent approach you should add this parser to your Lua configuration.
30+
31+
Default configuration detects `.res` and `.resi` files. You can confirm that it's correctly installed by using [`nvim-treesitter/playground`](https://github.com/nvim-treesitter/playground) and invoking `TSPlaygroundToggle` when you are in the ReScript file.
32+
33+
- 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.
34+
35+
If you are using `lazy.nvim` example configuration will look like so:
36+
37+
```lua
38+
{
39+
"nvim-treesitter/nvim-treesitter",
40+
dependencies = {
41+
"nkrkv/tree-sitter-rescript"
42+
},
43+
opts = function(_, opts) -- this is needed so you won't override your default nvim-treesitter configuration
44+
vim.list_extend(opts.ensure_installed, {
45+
"rescript",
46+
})
47+
48+
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
49+
parser_config.rescript = {
50+
install_info = {
51+
url = "https://github.com/nkrkv/tree-sitter-rescript",
52+
branch = "main",
53+
files = { "src/scanner.c" },
54+
generate_requires_npm = false,
55+
requires_generate_from_grammar = true,
56+
use_makefile = true, -- macOS specific instruction
57+
},
58+
}
59+
end,
60+
}
61+
```
62+
63+
- Legacy way of installing the parser is available via [`nvim-treesitter-rescript`](https://github.com/nkrkv/nvim-tree-sitter-rescript/)
1264
- If you want it for other purposes, you probably know what to do.
1365

1466
## Contributing

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@
1717
"res",
1818
"resi"
1919
],
20-
"injection-regex": "rescript"
20+
"injection-regex": "rescript",
21+
"highlights": [
22+
"queries/rescript/highlights.scm"
23+
],
24+
"locals": [
25+
"queries/rescript/locals.scm"
26+
],
27+
"injections": [
28+
"queries/rescript/injections.scm"
29+
],
30+
"textobjects": [
31+
"queries/rescript/textobjects.scm"
32+
]
2133
}
2234
]
2335
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)