@@ -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+
14491 . Check out this repo locally. Its location will be referred to as ` <ts-crystal-install-path> ` .
15502 . 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+
21583 . 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 `
0 commit comments