Installation

tree-sitter requires Emacs 25.1 or above, built with dynamic module support. Some Emacs distributions have this disabled by default. To check whether your Emacs has dynamic module support enabled, try evaluating one of these:

(functionp 'module-load) ; should be t

module-file-suffix ; should be non-nil

The methods below download pre-compiled binaries, so they only work for macOS, Linux and Windows, on x86_64 machines. For other systems, you will have to build from source.

Installing from MELPA

  • Run M-x package-refresh-contents.

  • Install tree-sitter and tree-sitter-langs packages.

  • Load the framework and the language bundle:

    (require 'tree-sitter)
    (require 'tree-sitter-langs)
    

Installing with straight.el

  • Run (straight-pull-package "melpa") to update MELPA recipes, if necessary.

  • Install tree-sitter and tree-sitter-langs packages.

    (straight-use-package 'tree-sitter)
    (straight-use-package 'tree-sitter-langs)
    
  • Load the framework and the language bundle:

    (require 'tree-sitter)
    (require 'tree-sitter-langs)
    

Installing from Source

  • Clone the source repository:

    git clone https://github.com/emacs-tree-sitter/elisp-tree-sitter
    
  • Add its core, lisp and langs directories to load-path:

    (add-to-list 'load-path "/path-to/emacs-tree-sitter/core")
    (add-to-list 'load-path "/path-to/emacs-tree-sitter/lisp")
    (add-to-list 'load-path "/path-to/emacs-tree-sitter/langs")
    
  • Load the libraries in your config:

    (require 'tree-sitter)
    (require 'tree-sitter-hl)
    (require 'tree-sitter-langs)
    (require 'tree-sitter-debug)
    (require 'tree-sitter-query)