Commit graph

741 commits

Author SHA1 Message Date
Max Brunsfeld
af0ed73f76
Merge branch 'master' into fix/1032 2021-06-29 15:59:15 -07:00
Max Brunsfeld
23433f4826
Merge pull request #1210 from ahlinc/fix/init-config-experience
fix(cli): init-config experience, it shouldn't silently overwrite existing config file
2021-06-29 15:53:36 -07:00
Max Brunsfeld
e7d3b29470
Merge pull request #1180 from CyberShadow/pull-20210618-110411
Pin emscripten/emsdk Docker version
2021-06-29 15:45:24 -07:00
Vladimir Panteleev
b14ea51e3d
Refactor emscripten/emsdk version to a single file 2021-06-29 21:39:12 +00:00
Andrew Hlynskyi
f22d62393b fix(cli): actual Rust binding version in generated Cargo.toml 2021-06-30 00:36:11 +03:00
Andrew Hlynskyi
202a37f1a1 chore(cli): Use DeriveDisplayOrder Clap's setting
To show sub commands in the defined order that looks more accurate
and have more meaning for sub commands use order.
2021-06-27 03:37:56 +03:00
Andrew Hlynskyi
2e2b239c42 fix(cli): Don't silently overwrite existing config file 2021-06-27 03:15:35 +03:00
Vladimir Panteleev
5adf7bdcde
cli/src/main.rs: Fix panic with empty file list to parse
E.g.: tree-sitter parse --paths /dev/null
2021-06-26 18:11:30 +00:00
Vladimir Panteleev
725f3f7f2b
Pin emscripten/emsdk Docker version
Fixes issues caused by incompatible changes in Emscripten since the
time that tree-sitter was built.
2021-06-26 18:07:12 +00:00
Max Brunsfeld
d7746bec99
Merge pull request #1198 from ahlinc/feat/color-and-aliases
feat(cli): colored help and frequent command aliases
2021-06-24 09:12:48 -07:00
Max Brunsfeld
cf8e7bd413
Merge pull request #1199 from dcreager/edit-file
cli: Allow `$` in `tree-sitter parse --edit`
2021-06-24 09:07:38 -07:00
Andrew Hlynskyi
bd0e60240e fix(cli): Change -h -> -H for the highlight subcommand to don't clash with the help flag 2021-06-24 12:09:00 +03:00
Andrew Hlynskyi
650ee94800 fix(cli): disable help subcommand, -h, --help are enough 2021-06-24 12:04:12 +03:00
Andrew Hlynskyi
1220ec3852 feat(cli): Rename web-ui -> playground with fallback alias 2021-06-24 12:04:12 +03:00
Andrew Hlynskyi
80ee33b073 feat(cli): Add short aliases for frequent subcommands 2021-06-24 11:55:50 +03:00
Andrew Hlynskyi
04badf8a8e feat(cli): Enable clap colored help 2021-06-24 11:55:50 +03:00
Douglas Creager
71c43a869b Allow $ in tree-sitter parse --edit
You can now specify `$` as the position to apply an edit, signifying the
end of the file.  (That prevents you from having to calculate the size
of the file yourself.)
2021-06-23 10:04:29 -04:00
Andrew Hlynskyi
421815a68d feat(cli): Make more clearer sub command selection 2021-06-23 10:51:55 +03:00
Andrew Hlynskyi
4578e58794 fix(cli): close #1032 - fix repository template url generation in cargo.toml 2021-06-23 01:02:29 +03:00
Edgar
9feca80b08
Make HighlightConfiguration::configure use into iterator instead of a Vec<String> 2021-06-16 19:14:45 +02:00
Andrew Hlynskyi
318b00e437 fix(cli): Don't print 'Error:' prefix 2021-06-14 10:46:39 +03: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
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
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
f3ea60e23f Merge branch 'master' into query-cursor-api 2021-06-02 11:51:26 -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
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
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
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
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
Max Brunsfeld
8c3d1466ec Allow QueryCursor's text callback to return an iterator 2021-05-23 21:05:26 -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
Niranjan Hasabnis
c0e2b43d34 Fixing Rust formatting issue 2021-05-21 15:43:10 +00:00
Niranjan Hasabnis
c31acb8fec Changing API name; Adding unit test and Rust bindings 2021-05-21 01:50:10 +00:00
Max Brunsfeld
8d8690538e 0.19.5 2021-05-20 15:02:46 -07:00
Andrew Hlynskyi
3c0152a331 chore(fmt): Apply 'cargo fmt' to the whole code base 2021-05-19 23:21:43 +03:00
Markus F.X.J. Oberhumer
cc519b3121 cli: Improve const-correctness of the generated parsers (part 2 of 2).
This is a follow-up to my previous commit 1badd131f9 .

I've made this an extra patch as it requires a minor
API change in <tree_sitter/parser.h>.

This commit moves the remaining generated tables into
the read-only segment.

Before:
  $ for f in bash c cpp go html java javascript jsdoc json php python ruby rust; do \
       gcc -o $f.o -O2 -Ilib/include -c test/fixtures/grammars/$f/src/parser.c; \
    done
  $ size --totals *.o
      text    data     bss     dec     hex filename
   5353477   24472       0 5377949  520f9d (TOTALS)

After:
  $ for f in bash c cpp go html java javascript jsdoc json php python ruby rust; do \
       gcc -o $f.o -O2 -Ilib/include -c test/fixtures/grammars/$f/src/parser.c; \
    done
  $ size --totals *.o
   5378147       0       0 5378147  521063 (TOTALS)
2021-05-19 12:49:57 +02:00
Max Brunsfeld
fe5a29a1c6
Merge pull request #1081 from ahlinc/feat/fail-ci-on-compiler-warnings
feat: Fail CI on compiler warnings
2021-05-01 09:26:44 -07:00
Andrew Hlynskyi
b856f7e1bd Remove unneeded dead_code annotations 2021-04-30 06:55:00 +03:00