Treesitter Emacs On Windows

Configuring Treesitter with precomiled grammars on windows

If you are using treesitter on windows, it can be a bit of work to configure everything in order to compile grammars on your own. Using pre-compiled grammars is possible, but it's not very obvious how, so here is my small guide.

Download precompiled grammars

First step is to find some source of precompiled grammars. tree-sitter-langs is the best source I have found. I placed mine in P:\Languages.

Rename files

Once you have the dlls you have to re-name them, by prefixing libtree-sitter-. I used powershell:

  dir | Rename-Item -NewName {"libtree-sitter-" + $_.Name}

Point Treesit-emacs to the files

Finally we need to tell treesitter where to find them:

(use-package treesit
  :config
  (add-to-list 'treesit-extra-load-path "P:/Languages"))

To verify that it works you can use ex:

  (treesit-language-available-p 'json)

It should return t if it finds the json grammar.