Skip to content

Commit

Permalink
Merge pull request #103 from crystal-lang-tools/keidax/nvim-instructions
Browse files Browse the repository at this point in the history
Update README with neovim install steps
  • Loading branch information
nobodywasishere authored Jan 12, 2025
2 parents 9079be3 + b822c4d commit 9dc81f2
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,37 @@

[Crystal](https://crystal-lang.org/) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).

## :construction: WIP :construction:
This grammar is mostly complete, and can parse the majority of Crystal's own source code without errors.

This grammar is still under construction.
## Setup

Syntax highlighting has not been implemented yet, and many syntax features are incomplete.
Hopefully support for this parser will be upstreamed by editors soon. At the moment, it must be integrated manually.

### Neovim

0. Set up the [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) plugin.
1. Check out this repo locally. Its location will be referred to as `<ts-crystal-install-path>`.
2. In a terminal, navigate to wherever nvim-treesitter is installed (this will depend on your plugin manager). Run:
```bash
mkdir queries/crystal
cd queries/crystal
ln -s <ts-crystal-install-path>/queries/nvim/*.scm .
```
3. Include this lua snippet in your neovim setup:
```lua
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.crystal = {
install_info = {
url = "<ts-crystal-install-path>",
files = {"src/parser.c", "src/scanner.c"},
branch = "main",
},
filetype = "cr",
}
```
4. Restart neovim and run `:TSInstall crystall`

To confirm the grammar is functioning, run `:checkhealth nvim-treesitter` and look for this line:
```
- crystal ✓ . ✓ . ✓
```

0 comments on commit 9dc81f2

Please sign in to comment.