aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/querycheck.rs
diff options
context:
space:
mode:
authorAlexander Brevig2022-09-19 13:38:20 +0000
committerGitHub2022-09-19 13:38:20 +0000
commit08b2ecc99a1ac1c461117bf6c79b77484eb433e4 (patch)
treed6510c5a5814918401118fdd8cc292051ac8cd68 /xtask/src/querycheck.rs
parent5ea7855977aa281206c9c540aa88ce9384619b87 (diff)
feat: xtask themelint (#3234)
* feat: cargo xtask themelint <theme> * fix: add docs and print json error status * fix: refactor paths -> path * fix: remove unused function * fix: only report one err per scope (ui.statusline is reported if none of ui.statusline.* is recognized) * fix: save work for later * fix: finally decided on a design * fix: ready for discussion * fix: better rules * fix: lint precision * fix: String -> &'static str * fix: allowlist not denylist for file type * fix: add missing and indication of what's needed * fix: copy pasteable errors * fix: use Loader:read_names * Update xtask/src/helpers.rs Co-authored-by: Ivan Tham <pickfire@riseup.net> * fix: remove into and clone for str * Update book/src/themes.md Co-authored-by: Ivan Tham <pickfire@riseup.net> * fix: better lint output * fix: cleaner logic for lint reporting * style: use explicit imports * Pascal support (#3542) * fix: add difference check for statusline normal,insert,select * fix: fg for whitespace and early exit if and one is ok * chore: cleaning up, no idea how these got here or how this will look * chore: revert from older commit? * refactor: use static fn to equalize api between difference and existance * refactor: querycheck and clippy * refactor: clippy fixes * fix: query-check behaves as before * fix: error with x of y message, not total count * fix: consistent reporting and less mutable state * fix: selection difference ref #3942 ref #1833 Co-authored-by: Ivan Tham <pickfire@riseup.net> Co-authored-by: ath3 <45574139+ath3@users.noreply.github.com>
Diffstat (limited to 'xtask/src/querycheck.rs')
-rw-r--r--xtask/src/querycheck.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/xtask/src/querycheck.rs b/xtask/src/querycheck.rs
new file mode 100644
index 00000000..5595b8ec
--- /dev/null
+++ b/xtask/src/querycheck.rs
@@ -0,0 +1,39 @@
+use crate::DynError;
+
+pub fn query_check() -> Result<(), DynError> {
+ use crate::helpers::lang_config;
+ use helix_core::{syntax::read_query, tree_sitter::Query};
+ use helix_loader::grammar::get_language;
+
+ let query_files = [
+ "highlights.scm",
+ "locals.scm",
+ "injections.scm",
+ "textobjects.scm",
+ "indents.scm",
+ ];
+
+ for language in lang_config().language {
+ let language_name = language.language_id.to_ascii_lowercase();
+ let grammar_name = language.grammar.unwrap_or(language.language_id);
+ for query_file in query_files {
+ let language = get_language(&grammar_name);
+ let query_text = read_query(&language_name, query_file);
+ if let Ok(lang) = language {
+ if !query_text.is_empty() {
+ if let Err(reason) = Query::new(lang, &query_text) {
+ return Err(format!(
+ "Failed to parse {} queries for {}: {}",
+ query_file, language_name, reason
+ )
+ .into());
+ }
+ }
+ }
+ }
+ }
+
+ println!("Query check succeeded");
+
+ Ok(())
+}