Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 1.31 KB

README.md

File metadata and controls

38 lines (31 loc) · 1.31 KB

tree-sitter-crystal

Crystal grammar for tree-sitter.

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

Setup

Hopefully support for this parser will be upstreamed by editors soon. At the moment, it must be integrated manually.

Neovim

  1. Set up the nvim-treesitter plugin.
  2. Check out this repo locally. Its location will be referred to as <ts-crystal-install-path>.
  3. In a terminal, navigate to wherever nvim-treesitter is installed (this will depend on your plugin manager). Run:
    mkdir queries/crystal
    cd queries/crystal
    ln -s <ts-crystal-install-path>/queries/nvim/*.scm .
  4. Include this lua snippet in your neovim setup:
    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",
    }
  5. Restart neovim and run :TSInstall crystall

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

- crystal             ✓ . ✓ . ✓