Tree-sitter

Manually manage Tree-sitter for Neovim.

Prerequisites

Tree-sitter CLI.

Parser

Apparently there's an issue in the official Haskell parser now, so we use the fork tree-sitter-grammars/tree-sitter-haskell instead.

git clone https://github.com/tree-sitter-grammars/tree-sitter-haskell
cd tree-sitter-haskell
tree-sitter build

Copy the resulted haskell.so to ~/.config/nvim/parser/.

Queries

We still use the query files from the archived nvim-treesitter repo.

git clone https://github.com/nvim-treesitter/nvim-treesitter
cd nvim-treesitter/runtime/queries/haskell

We should see four .scm files there. Copy them to ~/.config/nvim/queries/haskell/.

Neovim configuration

We now need to tell Neovim to start Tree-sitter. This could be added as an auto command or just a filetype plugin. We demonstrate the latter here. Just put vim.treesitter.start() in ~/.config/nvim/ftplugin/haskell.lua. Now our Haskell files should be very colorful!

References

  1. https://tree-sitter.github.io/tree-sitter/
  2. https://neovim.io/doc/user/treesitter/