Commit graph

113 commits

Author SHA1 Message Date
Douglas Creager
e841fcfa1b cli: Extract CLI configuration into separate crate
This patch adds the `tree-sitter-config` crate, which manages
tree-sitter's configuration file.  This new setup allows different
components to define their own serializable configuration types, instead
of having to create a single monolithic configuration type.  But the
configuration itself is still stored in a single JSON file.

Before, the default location for the configuration file was
`~/.tree-sitter/config.json`.  This patch updates the default location
to follow the XDG Base Directory spec (or other relevant platform-
specific spec).  So on Linux, for instance, the new default location is
`~/.config/tree-sitter/config.json`.  We will look in the new location
_first_, and fall back on reading from the legacy location if we can't
find anything.
2021-06-10 10:21:22 -04:00
Douglas Creager
66c30648c2 rust: Extract runtime language detection into separate crate
This patch adds a new `tree-sitter-loader` crate, which holds the CLI's
logic for finding and building local grammar definitions at runtime.
This allows other command-line tools to use this logic too!
2021-06-09 17:42:30 -04:00
Douglas Creager
d2d01e77e3 cli: Use anyhow and thiserror for errors
This patch updates the CLI to use anyhow and thiserror for error
management.  The main feature that our custom `Error` type was providing
was a _list_ of messages, which would allow us to annotate "lower-level"
errors with more contextual information.  This is exactly what's
provided by anyhow's `Context` trait.

(This is setup work for a future PR that will pull the `config` and
`loader` modules out into separate crates; by using `anyhow` we wouldn't
have to deal with a circular dependency between with the new crates.)
2021-06-09 16:17:23 -04:00
Max Brunsfeld
8d8690538e 0.19.5 2021-05-20 15:02:46 -07:00
Max Brunsfeld
5664b77535 rust: 0.19.5 2021-05-20 14:29:25 -07:00
Amin Yahyaabadi
919eab023f Fix build-wasm on Windows 2021-04-04 19:07:16 -05:00
Max Brunsfeld
810d10fa26 0.19.4 2021-03-18 10:36:05 -07:00
Max Brunsfeld
5f313689f0 rust: 0.19.4 2021-03-18 10:36:05 -07:00
Max Brunsfeld
48fa4bdb00 rust: 0.19.3 2021-03-12 15:21:47 -08:00
Max Brunsfeld
24785cdb39 0.19.3 2021-03-08 16:36:59 -08:00
Max Brunsfeld
841e160898 rust libs: 0.19.2 2021-03-08 10:03:45 -08:00
Max Brunsfeld
d037c4914d 0.19.2 2021-03-05 15:35:51 -08:00
Max Brunsfeld
0818892a1a libs: 0.19.1 2021-03-05 15:31:48 -08:00
Max Brunsfeld
d6254e35c3 0.19.1 2021-03-03 13:35:38 -08:00
Max Brunsfeld
22fb88e89d Bump library versions to 0.19 2021-03-01 14:46:43 -08:00
Max Brunsfeld
5f1bb20c49 0.19.0 2021-03-01 12:19:41 -08:00
hvithrafn
05f79f0f90 Update dependencies; fix breakage 2021-02-26 10:55:20 -07:00
Patrick Thomson
44010d69ea Walk query files recursively in tree-sitter test.
We were only walking one level of depth into the `queries/` folder
during invocations of `test`, which made us attempt to open folders
rather than recurse into them.

We have to pull in the `walkdir` crate, which is required for
cross-platform walking of directories.

Fixes #938.
2021-02-25 10:24:54 -05:00
Douglas Creager
a29c8d9264 Move allocation tracking into lib crate
We have several test cases defined in the `cli` crate that depend on the
`lib` crate's `allocation-tracking` feature.  The implementation of the
actual allocation tracker used to live in the `cli` crate, close to the
test cases that use it.  The `allocation-tracking` feature in the `lib`
crate was just used to tell the tree-sitter implementation to expect
that the allocation tracker exists, and to use it.

That pattern meant that we had a circular dependency: `cli` depends on
`lib`, but `lib` required some code that was implemented in `cli`.
That, in turn, caused linker errors — but only when compiling in certain
configurations! [1]

This patch moves all of the allocation tracking implementation into the
`lib` crate, gated on the existing `allocation-tracking` feature, which
fixes the circular dependency.

Note that this patch does **not** fix the fact that feature unification
causes the `lib` crate to be built with the `allocation-tracking`
feature enabled, even though it's not a default.  Fixing that depends on
the forthcoming version 2 feature resolver [2], or using the `dev_dep`
workaround [3] in the meantime.

[1] https://github.com/tree-sitter/tree-sitter/issues/919
[2] https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2
[3] https://github.com/tree-sitter/tree-sitter/issues/919#issuecomment-777107086
2021-02-23 09:16:37 -05:00
Max Brunsfeld
796f655b03 0.18.2 2021-02-18 14:33:03 -08:00
Max Brunsfeld
f51026dff1 0.18.1 2021-02-11 14:59:17 -08:00
Max Brunsfeld
1dc127e5da 0.18.0 2021-01-07 17:07:29 -08:00
Yijun Yu
9e08712773 Add --xml option to save the parsed code into XML, using node.start_byte() and node.end_byte() 2021-01-04 22:07:38 +00:00
Kája Lišková
915834c113 Update CC to version with better target support
This is just a minimal set of changes to dependencies.
macOS aarch64 support was only introduced in `cc` version 1.0.58, so this now allows tree-sitter to build natively on M1 computers
2020-12-20 16:09:17 -06:00
Max Brunsfeld
281e75d74d rust binding: 0.17.1 2020-11-02 20:53:08 -08:00
Max Brunsfeld
c439a676cf 0.17.3 2020-11-02 14:53:01 -08:00
Max Brunsfeld
1992734195 0.17.2 2020-10-28 14:12:56 -07:00
Max Brunsfeld
b972a7158d Tweak cancellation logic for CLI commands
In 'parse' and 'highlight' cancel on stdin if stdin is a tty.
2020-10-23 12:15:44 -07:00
Max Brunsfeld
08356f79c7 Bump sibling cargo deps 2020-09-30 21:19:32 -07:00
Max Brunsfeld
5080de496a 0.17.1 2020-09-24 15:08:19 -07:00
Max Brunsfeld
28557ea8b4 highlight: 0.3 2020-09-24 15:07:56 -07:00
Max Brunsfeld
7361cf9a0b rust binding: 0.17.0 2020-09-24 15:05:34 -07:00
Max Brunsfeld
b6fba7ca4c 0.17.0 2020-09-23 13:09:19 -07:00
Max Brunsfeld
12341dbbc0 0.16.9 2020-07-17 14:23:54 -07:00
Max Brunsfeld
9a82dcc666 0.16.8 2020-06-01 13:48:37 -07:00
Max Brunsfeld
c31afbb86a lib: 0.16.1 2020-06-01 13:45:54 -07:00
Max Brunsfeld
97018168d3 0.16.7 2020-05-14 10:52:21 -07:00
Max Brunsfeld
d17d1b36b2 tags: 0.2.0 2020-05-12 16:32:37 -07:00
Max Brunsfeld
862b56dfe1 0.16.6 2020-05-12 16:22:44 -07:00
Max Brunsfeld
8eac81b8df Merge branch 'master' into tags 2020-03-25 12:49:15 -07:00
Max Brunsfeld
4dc82d8b8b Remove unused serde dependency from highlight crate 2020-03-25 12:49:11 -07:00
Max Brunsfeld
e3e1bdba75 tags: Start work on C API 2020-03-17 13:19:18 -07:00
Max Brunsfeld
94a60b8e13 tags: Start adapting Tag struct for use in C API 2020-03-17 11:19:30 -07:00
Max Brunsfeld
f453178ca2 rust: Remove unnecessary dependencies from core library 2020-03-16 14:46:05 -07:00
Max Brunsfeld
feac368a30 Start work on new tree-sitter-tags crate
Co-Authored-By: Patrick Thomson <patrickt@users.noreply.github.com>
2020-03-04 14:27:31 -08:00
Max Brunsfeld
078cab3f96 rust: 0.6.3 2020-03-02 15:02:45 -08:00
Max Brunsfeld
e259af6a4e 0.16.5 2020-03-02 12:41:22 -08:00
Max Brunsfeld
1217f58b8d rust: 0.6.2 2020-02-17 22:37:12 -08:00
Max Brunsfeld
f049ba350f 0.16.4 2020-01-28 10:09:26 -08:00
Max Brunsfeld
2bc7e457df lib: 0.6.1 2020-01-28 09:27:10 -08:00