Skip to content

Commit a91c92d

Browse files
authored
Include new nvim-treesitter instructions (#139)
1 parent 0c8eddc commit a91c92d

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,53 @@ Hopefully support for this parser will be upstreamed by editors soon. At the mom
1010

1111
### Neovim
1212

13-
0. Set up the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) plugin.
13+
0. Set up the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/tree/main) plugin.
14+
15+
#### For nvim-treesitter v0.10 or newer (recommended)
16+
17+
1. Include this lua snippet in your neovim setup:
18+
19+
```lua
20+
vim.api.nvim_create_autocmd("User", {
21+
pattern = 'TSUpdate',
22+
callback = function()
23+
require('nvim-treesitter.parsers').crystal = {
24+
install_info = {
25+
url = 'https://github.com/crystal-lang-tools/tree-sitter-crystal',
26+
-- path = '<ts-crystal-install-path>', -- if you want to use a local version instead
27+
generate = false,
28+
generate_from_json = false,
29+
queries = 'queries/nvim'
30+
},
31+
}
32+
end,
33+
})
34+
35+
vim.treesitter.language.register("crystal", { "cr" })
36+
```
37+
38+
2. Restart neovim and run `:TSUpdate`
39+
40+
To confirm the grammar is functioning, run `:checkhealth nvim-treesitter` and look for this line:
41+
42+
```
43+
- crystal ✓ . ✓ . ✓
44+
```
45+
46+
47+
#### For older nvim-treesitter versions (aka the master branch)
48+
1449
1. Check out this repo locally. Its location will be referred to as `<ts-crystal-install-path>`.
1550
2. In a terminal, navigate to wherever nvim-treesitter is installed (this will depend on your plugin manager). Run:
51+
1652
```bash
1753
mkdir queries/crystal
1854
cd queries/crystal
1955
ln -s <ts-crystal-install-path>/queries/nvim/*.scm .
2056
```
57+
2158
3. Include this lua snippet in your neovim setup:
59+
2260
```lua
2361
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
2462
parser_config.crystal = {
@@ -30,9 +68,5 @@ Hopefully support for this parser will be upstreamed by editors soon. At the mom
3068
filetype = "cr",
3169
}
3270
```
33-
4. Restart neovim and run `:TSInstall crystal`
3471

35-
To confirm the grammar is functioning, run `:checkhealth nvim-treesitter` and look for this line:
36-
```
37-
- crystal ✓ . ✓ . ✓
38-
```
72+
4. Restart neovim and run `:TSInstall crystal`

queries/injections.scm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33

44
(heredoc_body
55
(literal_content) @injection.content
6-
(heredoc_end) @injection.language
7-
(#downcase! @injection.language))
6+
(heredoc_end) @injection.language)

queries/nvim/injections.scm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
(heredoc_body
99
(literal_content) @injection.content
10-
(heredoc_end) @injection.language
11-
(#downcase! @injection.language))
10+
(heredoc_end) @injection.language)
1211

1312
(macro_def
1413
body: (expressions) @injection.content

0 commit comments

Comments
 (0)