-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: Extract CLI configuration into separate crate #1157
Conversation
c.f. #628 |
Compiled parsers are now placed into the user's cache directory, typically |
cli/config/src/lib.rs
Outdated
Err(anyhow!(concat!( | ||
"Cannot find a tree-sitter configuration file.\n", | ||
"Please run `tree-sitter init-config` to create one!" | ||
))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this makes it a hard error to run tree-sitter
without having a config file in place, which is different than before. I'm honestly not sure that I like this part of the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! And in fact that makes the test cases fail! Okay that definitely tells me we don't want this to be a hard error. I'll push up a fix for that.
@dcreager @maxbrunsfeld I know that |
I quite like that idea, though I think it should be done in a separate PR |
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.
Just fall back on the default values for each configuration option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great.
Can you do a cursory read of the syntax highlighting docs path and see if anything should be updated or rephrased, due to the changes to the config file's location?
Done ✔️ |
Does so as of tree-sitter/tree-sitter#1157 And having this set seems to cause tree-sitter to fail, see tree-sitter/tree-sitter#1222
Does so as of tree-sitter/tree-sitter#1157 And having this set seems to cause tree-sitter to fail, see tree-sitter/tree-sitter#1222
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.