(address . guix-patches@gnu.org)
Hi Guix!
Here's a patch series that adds support for the Tree-sitter library,
command-line tool and its support in emacs:
The series in split into multiple parts:
1. Add the tree-sitter package, which is both a command-line tool for
generating parsers and a runtime library. The runtime is written in
C but the tooling in Rust.
* gnu: rust-chunked-transfer: Update to 1.4.0.
* gnu: Add rust-fdlimit.
* gnu: Add rust-html-escape.
* gnu: Add rust-smallbitvec.
* gnu: rust-tiny-http: Update to 0.8.
* gnu: rust-spin: Update to 0.7.
* gnu: Add tree-sitter.
2. Add support for native addons to the node build-system.
* gnu: node: Patch /usr/bin/env in node-gyp.
* guix: node-build-system: Support compiling addons with node-gyp.
I've not touched the node build system before so it'd be great to get
some review here!
The idea is that when a package has a `binding.gyp' file then there's
native code that needs to be compiled against node. This uses
node-gyp, which is a build system written in python.
Normally, there shouldn't be anything to do, the package.json file
should invoke `node-gyp` tp compile C code. However, `node-gyp' needs
node headers to compile against, packaged as a tarball, which it tries
to download. Instead, we can run a `node-gyp --tarball <> configure'
step to manually provide the tarball, which we can package separately
for any given node version.
I could have added this into the packages themselves, but I thought it
made more sense to be a part of the build system, let me know what you
think!
3. Packaging grammars for multiple languages.
Tree-sitter grammars are Nodejs packages, they consist of a grammar.js
file which the tree-sitter command-line program uses to generate C
code for the parser/scanner. Using npm as a packaging mechanism for
this seems overkill, but it's true some grammars depend on each other
(cpp on c, typescript and javascript).
* gnu: Add node-nan.
* gnu: Add tree-sitter-c.
* gnu: Add tree-sitter-cpp.
* gnu: Add tree-sitter-css.
* gnu: Add tree-sitter-go.
* gnu: Add tree-sitter-html.
* gnu: Add tree-sitter-java.
* gnu: Add tree-sitter-javascript.
* gnu: Add tree-sitter-json.
* gnu: Add tree-sitter-julia.
* gnu: Add tree-sitter-php.
* gnu: Add tree-sitter-python.
* gnu: Add tree-sitter-rust.
* gnu: Add tree-sitter-typescript.
4. Finally, emacs support!
emacs-tree-sitter can be used for syntax highlighting, replacing
font-lock. The tree-sitter runtime library is built as a Rust crate
and exposed to emacs using a module thanks to the rust-emacs crate.
Then emacs-tree-sitter-core provides just the core APIs as exposed by
the rust module, then emacs-tree-sitter integrates it with emacs'
syntax highlighting (and probably other things).
Finally, we bundle together the various language grammars into a
single emacs-tree-sitter-langs package so that they can get loaded
along with their respective major modes. Note that there are grammars
left to support which I've not yet managed to package, but what we
have already is a good start I think :-). So far I've tested C++,
Rust, Python and JavaScript and JSON.
* gnu: Add rust-bindgen@0.56.
* gnu: Add rust-tree-sitter.
* gnu: rust-emacs-module: Update to 0.16.
* gnu: rust-emacs-macros: Update to 0.17.
* gnu: rust-emacs: Update to 0.17.
* gnu: Add emacs-tree-sitter-core.
* gnu: Add emacs-tree-sitter.
* gnu: Add emacs-tree-sitter-langs.
Let me know what you think! This rebuilds all node packages, but there
aren't that many so hopefully that'll be ok on master.
Thanks,
Pierre
Pierre Langlois (31):
gnu: rust-chunked-transfer: Update to 1.4.0.
gnu: Add rust-fdlimit.
gnu: Add rust-html-escape.
gnu: Add rust-smallbitvec.
gnu: rust-tiny-http: Update to 0.8.
gnu: rust-spin: Update to 0.7.
gnu: Add tree-sitter.
gnu: node: Patch /usr/bin/env in node-gyp.
guix: node-build-system: Support compiling addons with node-gyp.
gnu: Add node-nan.
gnu: Add tree-sitter-c.
gnu: Add tree-sitter-cpp.
gnu: Add tree-sitter-css.
gnu: Add tree-sitter-go.
gnu: Add tree-sitter-html.
gnu: Add tree-sitter-java.
gnu: Add tree-sitter-javascript.
gnu: Add tree-sitter-json.
gnu: Add tree-sitter-julia.
gnu: Add tree-sitter-php.
gnu: Add tree-sitter-python.
gnu: Add tree-sitter-rust.
gnu: Add tree-sitter-typescript.
gnu: Add rust-bindgen@0.56.
gnu: Add rust-tree-sitter.
gnu: rust-emacs-module: Update to 0.16.
gnu: rust-emacs-macros: Update to 0.17.
gnu: rust-emacs: Update to 0.17.
gnu: Add emacs-tree-sitter-core.
gnu: Add emacs-tree-sitter.
gnu: Add emacs-tree-sitter-langs.
gnu/local.mk | 1 +
gnu/packages/crates-io.scm | 290 +++++++++++--
gnu/packages/node-xyz.scm | 30 ++
gnu/packages/node.scm | 29 +-
gnu/packages/tree-sitter.scm | 716 +++++++++++++++++++++++++++++++
guix/build-system/node.scm | 16 +
guix/build/node-build-system.scm | 15 +
7 files changed, 1064 insertions(+), 33 deletions(-)
create mode 100644 gnu/packages/tree-sitter.scm
--
2.32.0
-----BEGIN PGP SIGNATURE-----
iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmEQaBcYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31Uk64H/RTjvpOAq1dLgQVt69syGPZO
cx2KRhhKea+vAnjzkcau71H+ekqv2faeUCeRYJATBViOsavxbs0cMp4lqTS+7YQY
1K0rH/sR0Kc4D5Reb6OhUBkp1QjbrETydrAhp9vdX8KPwsMf8qApaxZT7KC49eYj
UeiCFytDQ0f7fcELUWMnIsy3ca1F9Q/FarUofITWGNiJ5biWxkr0xhdO4qe7roo/
xEElSYGbVp7qNeXcyku7kRWQES7F2ijsc354Hv1G6HAA76tkyDF6r2OOzKtGLFPg
rpfduwfzWo4DENtOvSjekIHtkVSWuW3g5s6ThN+jSoAZf0IUE4XoxSn5i5b/Keg=
=vVea
-----END PGP SIGNATURE-----