GithubHelp home page GithubHelp logo

emacs-tree-sitter / elisp-tree-sitter Goto Github PK

View Code? Open in Web Editor NEW
803.0 26.0 70.0 1.36 MB

Emacs Lisp bindings for tree-sitter

Home Page: https://emacs-tree-sitter.github.io

License: MIT License

Shell 2.77% Rust 26.85% Emacs Lisp 68.11% PowerShell 1.95% Makefile 0.32%
rust emacs binding emacs-modules incremental parsing tree-sitter

elisp-tree-sitter's Introduction

ELisp Tree-sitter

Documentation GitHub Actions

For Emacs 29+, please use the built-in integration instead of this package.

This is an Emacs Lisp binding for tree-sitter, an incremental parsing library. It requires Emacs 25.1 or above, built with dynamic module support.

It aims to be the foundation for a new breed of Emacs packages that understand code structurally. For example:

  • Faster, fine-grained code highlighting.
  • More flexible code folding.
  • Structural editing (like Paredit, or even better) for non-Lisp code.
  • More informative indexing for imenu.

The author of tree-sitter articulated its merits a lot better in this Strange Loop talk.

Installation

See the installation section in the documentation.

If you want to hack on emacs-tree-sitter itself, see the next section instead.

Setup for Development

Note: On Windows, use Powershell instead of Bash or cmd.exe.

  • Clone this repo with the --recursive flag.
  • Add 3 of its directories to load-path: core/, lisp/ and langs/.
  • Install eask.
  • Run bin/setup.

If you want to hack on the high-level features (in Lisp) only:

  • Make changes to the .el files.
  • Add tests to tree-sitter-tests.el and run them with bin/test.

If you want to build additional (or all) grammars from source, or work on the core dynamic module, see the next 2 sections.

Building grammars from source

Note: If you are only interested in building the grammar binaries, not the dynamic module, check out tree-sitter-langs.

  • Install NodeJS. It is needed to generate the grammar code from the JavaScript DSL. The recommended tool to manage NodeJS is volta.
  • Install tree-sitter CLI tool: (Its binary can also be downloaded directly from GitHub.) Note: version 0.20+ cannot be used, as they introduced a breaking change in binary storage location.
    # For yarn user
    yarn global add [email protected]
    
    # For npm user
    npm install -g [email protected]
  • Run langs/script/compile. For example:
    langs/script/compile rust

Working on the dynamic module

  • Install the Rust toolchain.
  • Build:
    bin/build
  • Test:
    bin/test
  • Continuously rebuild and test on change (requires cargo-watch):
    bin/test watch

To test against a different version of Emacs, set the environment variable EMACS (e.g. EMACS=/snap/bin/emacs make test).

Alternatives

Contribution

Contributions are welcomed. Please take a look at the issue list for ideas, or create a new issue to describe any idea you have for improvement.

For language-specific issues/features, please check out tree-sitter-langs instead.

Show respect and empathy towards others. Both technical empathy and general empathy are highly valued.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.