Commit graph

3632 commits

Author SHA1 Message Date
Max Brunsfeld
12207c1f70
Merge pull request #1163 from ahlinc/fix/error-prefix
fix(cli): Don't print 'Error:' prefix
2021-06-14 08:09:29 -07:00
Andrew Hlynskyi
318b00e437 fix(cli): Don't print 'Error:' prefix 2021-06-14 10:46:39 +03:00
Douglas Creager
6ed42747a4
Merge pull request #1157 from dcreager/xdg-config
cli: Extract CLI configuration into separate crate
2021-06-10 15:39:45 -04:00
Douglas Creager
d02636ff53 Update documentation with new config locations 2021-06-10 15:20:05 -04:00
Max Brunsfeld
4d9d7589f8
Merge pull request #1115 from tree-sitter/dependabot/bundler/docs/nokogiri-1.11.4
build(deps): bump nokogiri from 1.10.8 to 1.11.4 in /docs
2021-06-10 11:23:50 -07:00
Douglas Creager
b44270efab cli: Missing config file shouldn't be an error
Just fall back on the default values for each configuration option.
2021-06-10 10:22:20 -04:00
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
ebae034b0c
Merge pull request #1153 from dcreager/extract-loader
rust: Extract runtime language detection into separate crate
2021-06-10 08:40:31 -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
162ce789bc
Merge pull request #1152 from dcreager/anyhow
cli: Use anyhow and thiserror for errors
2021-06-09 17:09:27 -04:00
Douglas Creager
75da247317 cli: Ignore BrokenPipe errors again
With the change to anyhow in the previous commit, we stopped ignoring
BrokenPipe errors.  Now we do again, not as a core part of our error
type, but as part of the `main` functions reaction to any error that
occurs.
2021-06-09 16:17:23 -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
9d77561c43
Merge pull request #1150 from ahlinc/fix/panic-on-broken-pipe
Stylistic fix for #1135 - Panic on broken pipe
2021-06-08 11:21:04 -07:00
Andrew Hlynskyi
8bbf27b82b chore(cli): Panic on broken pipe; stylistic fix 2021-06-08 21:04:26 +03:00
Max Brunsfeld
22620dee73
Merge pull request #1135 from ahlinc/fix/panic-on-broken-pipe
fix(cli): Panic on broken pipe
2021-06-07 11:15:37 -07:00
Andrew Hlynskyi
ce2bb561b4 chore(cli): Panic on broken pipe; review fixes 2021-06-07 21:11:49 +03:00
Andrew Hlynskyi
dbdda25224 fix(cli): Panic on broken pipe; use conditional match arm with ErrorKind 2021-06-07 20:22:12 +03:00
Max Brunsfeld
ad8bd3c3f5
Merge pull request #1120 from claudi/cast-printed-pointers
Fix: cast pointers to `void *` when printing
2021-06-07 09:09:54 -07:00
Max Brunsfeld
ac23797686
Merge pull request #1134 from ahlinc/fix/playground-tree-presentation
fix: Cut dangling closing bracket in the playground tree
2021-06-07 09:09:26 -07:00
Max Brunsfeld
b303a488eb
Merge pull request #1145 from jhchabran/master
Update documentation on creating a parser: minor inconsitency on the generated files
2021-06-07 09:04:20 -07:00
Max Brunsfeld
2407eda993
Merge pull request #1146 from ngalaiko/fix-docs-link
docs: fix language ingection section link
2021-06-07 09:04:06 -07:00
Nikita Galaiko
de3600dd75
docs: fix language ingection section link 2021-06-07 16:54:47 +02:00
Jean-Hadrien Chabran
2aa1578f6b Update generated files 2021-06-07 14:33:32 +02:00
Max Brunsfeld
fecc2de515
Merge pull request #1130 from tree-sitter/query-cursor-api
Improve the QueryCursor API
2021-06-02 13:18:50 -07:00
Max Brunsfeld
f3ea60e23f Merge branch 'master' into query-cursor-api 2021-06-02 11:51:26 -07:00
Max Brunsfeld
82f3d3232b
Merge pull request #1127 from dcreager/query-mempool
query: Allow unlimited pending matches
2021-06-02 11:39:17 -07:00
Douglas Creager
cc20708a33 query: Minor cleanups 2021-06-02 14:16:04 -04:00
Douglas Creager
47f1af818a query: Remove bits.h 2021-06-02 14:14:57 -04:00
Douglas Creager
ad3907c2a6 wasm: Add matchLimit option to query methods
This exposes the new configurable match limits for query cursors.
2021-06-02 13:51:00 -04:00
Douglas Creager
1f6eac555c query: Use uint32_t for capture list IDs 2021-06-02 13:19:52 -04:00
Max Brunsfeld
8416894923 Use std::iter::Once in impl TextProvider for [u8]
Co-Authored-By: Douglas Creager <dcreager@dcreager.net>
2021-06-02 09:15:04 -07:00
Douglas Creager
cd96552448 query: Allow configurable match limit
The default is now a whopping 64K matches, which "should be enough for
everyone".  You can use the new `ts_query_cursor_set_match_limit`
function to set this to a lower limit, such as the previous default of
32.
2021-06-02 11:30:55 -04:00
Andrew Hlynskyi
65dc922944 fix(cli): Panic on broken pipe for: 'tree-sitter parse ... | head'
Introduce a concept of ignored errors when the Error wrapper struct
contains None instead of Vec of String messages.
2021-05-31 18:34:09 +03:00
Andrew Hlynskyi
4c5459814e Cut dangling closing bracket in the playground tree 2021-05-31 14:12:22 +03:00
Max Brunsfeld
d72771a19f Make ::set_{byte,point}_range methods take a Range
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 14:21:11 -07:00
Max Brunsfeld
7f4eb9a222 Provide ::set_{byte,point}_range on both query iterators 2021-05-28 14:07:54 -07:00
Max Brunsfeld
97dfee6325 Add QueryMatch::nodes_for_capture_index
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 12:38:30 -07:00
Max Brunsfeld
dab11134c2 Add Query::capture_index_for_name method
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 12:27:50 -07:00
Max Brunsfeld
851f55afce Report non-rooted matches that intersect cursor's range restriction
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 11:58:38 -07:00
Max Brunsfeld
919e9745a6 Add ts_tree_cursor_goto_first_child_for_point function
This function (and the similar `ts_tree_cursor_goto_first_child_for_byte`)
allows you to efficiently seek the tree cursor to a given position,
exploiting the tree's internal balancing, without having to visit
all of the preceding siblings of each node.
2021-05-27 12:30:19 -07:00
Max Brunsfeld
036aceed57 In script/generate-bindings, add flags for latest bindgen 2021-05-25 18:02:39 -07:00
Max Brunsfeld
fda35894d4 Stop matching new patterns past the end of QueryCursor's range
This restores the original signatures of the `set_byte_range` and
`set_point_range` functions. Now, the QueryCursor will properly report
matches that intersect, but are not fully contained by its range.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-25 18:02:35 -07:00
Max Brunsfeld
f597cc6a75 Preserve matches that contain the QueryCursor's start byte
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-05-25 13:06:24 -07:00
Max Brunsfeld
a61f25bc58 Add APIs for advancing a QueryCursor to an arbitrary position 2021-05-24 21:07:59 -07:00
Max Brunsfeld
0c7b37a9fd
Merge pull request #1126 from jiyee/master
FIX: node-tree-sitter url
2021-05-24 11:26:32 -07:00
Douglas Creager
78010722a4 query: Allow unlimited pending matches
Well, not completely unlimited — we're still using a 16-bit counter to
keep track of them.  But we longer have a static maximum of 32 pending
matches when executing a query.
2021-05-24 11:02:58 -04:00
Jiyee Sheng
6ceecb3928 FIX: node-tree-sitter url 2021-05-24 16:28:08 +08:00
Max Brunsfeld
8c3d1466ec Allow QueryCursor's text callback to return an iterator 2021-05-23 21:05:26 -07:00
Max Brunsfeld
b1c2723327
Merge pull request #1125 from ahlinc/fix/build-wasm-in-docker
fix(cli): Correct fallback on docker compilation for all platforms, fixes #1124
2021-05-23 12:09:36 -07:00
Andrew Hlynskyi
0ae70289ae fix(cli): Correct fallback on docker compilation for all platforms, fixes #1124 2021-05-23 17:04:34 +03:00