All Projects → Wilfred → tree-sitter-elisp

Wilfred / tree-sitter-elisp

Licence: MIT license
tree-sitter grammar for emacs lisp

Programming Languages

c
50402 projects - #5 most used programming language
javascript
184084 projects - #8 most used programming language
rust
11053 projects
scheme
763 projects
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to tree-sitter-elisp

haskell-tree-sitter
Haskell bindings for tree-sitter
Stars: ✭ 123 (+515%)
Mutual labels:  tree-sitter
kosmikoa.nvim
A dark color scheme for Neovim with support for LSP, Treesitter. This mirror is deprecated. Use the repo at https://sr.ht/~novakane/kosmikoa.nvim/
Stars: ✭ 23 (+15%)
Mutual labels:  tree-sitter
go-tree-sitter
Golang bindings for tree-sitter https://github.com/tree-sitter/tree-sitter
Stars: ✭ 137 (+585%)
Mutual labels:  tree-sitter
swift-tree-sitter
Swift bindings for the tree-sitter parsing library
Stars: ✭ 29 (+45%)
Mutual labels:  tree-sitter
tree-sitter-hcl
A tree-sitter grammar for HCL (HashiCorp Configuration Language), used by projects such as Terraform.
Stars: ✭ 65 (+225%)
Mutual labels:  tree-sitter
tree-sitter-comment
Tree-sitter grammar for comment tags like TODO, FIXME(user).
Stars: ✭ 86 (+330%)
Mutual labels:  tree-sitter
tree-sitter.el
An Emacs dynamic module exposing tree-sitter.
Stars: ✭ 59 (+195%)
Mutual labels:  tree-sitter
playground
Treesitter playground integrated into Neovim
Stars: ✭ 467 (+2235%)
Mutual labels:  tree-sitter
tree-sitter-css
CSS grammar for Tree-sitter
Stars: ✭ 57 (+185%)
Mutual labels:  tree-sitter
tree-sitter-elixir
ananthakumaran.in/tree-sitter-elixir
Stars: ✭ 43 (+115%)
Mutual labels:  tree-sitter
reason-tree-sitter
ReasonML bindings for tree-sitter
Stars: ✭ 22 (+10%)
Mutual labels:  tree-sitter
ltreesitter
Standalone tree sitter bindings for the Lua language
Stars: ✭ 62 (+210%)
Mutual labels:  tree-sitter
tree-sitter-java
Java grammar for tree-sitter
Stars: ✭ 73 (+265%)
Mutual labels:  tree-sitter
tree-sitter-cli
CLI tool for creating and testing tree-sitter parsers
Stars: ✭ 43 (+115%)
Mutual labels:  tree-sitter
tree-sitter-haskell
Haskell grammar for tree-sitter.
Stars: ✭ 110 (+450%)
Mutual labels:  tree-sitter
tree-sitter-rust
Rust grammar for tree-sitter
Stars: ✭ 199 (+895%)
Mutual labels:  tree-sitter
tree-sitter-regex
Tree-sitter parser for regular expressions
Stars: ✭ 42 (+110%)
Mutual labels:  tree-sitter
tree-sitter-typescript
TypeScript grammar for tree-sitter
Stars: ✭ 154 (+670%)
Mutual labels:  tree-sitter
tree-sitter-julia
Julia grammar for Tree-sitter
Stars: ✭ 53 (+165%)
Mutual labels:  tree-sitter
awesome-tree-sitter
Curated list of awesome tree-sitter language grammars, bindings, tools, libraries
Stars: ✭ 29 (+45%)
Mutual labels:  tree-sitter

Tree-sitter Grammar for Emacs Lisp

A simple tree-sitter grammar for elisp.

Syntax supported:

  • Atoms (integers, floats, strings, characters, symbols)
  • Lists (normal syntax (a b) and dotted (a . b))
  • Vectors
  • Quoting and unquoting (', #', `, ,, ,@)
  • Some special read syntax ($#, ##, #("foo" 1 2 x))
  • Bytecode literals (#[1 2 3 4])
  • Special forms (let etc)
  • Comments

Currently unsupported:

  • Autoload cookies
  • Definitions (e.g. defun, defvar, defmacro)

Limitations

Elisp is a lisp-2 with user-defined macros. A simple parser cannot detect if e.g. (foo (let ...)) is a function call with a let expression argument, or a macro call where let means something else.

Currently tree-sitter-elisp treats everything as an s-expression. This is accurate, but makes this package less useful for generating a summary of file contents, or for syntax highlighting.

Emacs itself has more information that it can use. Emacs will highlight macro calls based on which macros are defined in the current instance. Some elisp packages also offer custom highlighting logic, such as dash-fontify-mode in dash.el.

Developing

Check out the repo, then use npm to install dependencies.

$ npm install

You can then parse your favourite elisp files.

$ npm run parse ~/.emacs.d/init.el

The grammar itself is in grammar.js. You'll need to regenerate the code after editing the grammar.

$ npm run generate

This project also contains a few tests.

$ npm test

You can also run this parser against your .emacs.d to confirm it can parse everything.

$ npm run parse -- '/home/wilfred/.emacs.d/**/*.el' --quiet --stat

Why?

The best place to read and write elisp is of course Emacs.

However, there is a growing ecosystem of tools built on top of tree-sitter, such as GitHub. This project should allow them to support emacs lisp too.

Related Projects

tree-sitter-clojure is another tree-sitter package for the lisp family. It's a useful project to compare with, and has notes discussing lisp-specific challenges.

language-emacs-lisp is a textmate grammar for elisp that's used for Atom and GitHub.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].