Skip to content
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

feat!: new operator has and not-has, deprecate stmt_register #181

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,6 @@ module.exports = grammar({
field("file", choice(alias($.unquoted, $.val_string), $._stringish)),
),

stmt_register: ($) =>
prec.left(
PREC().low,
seq(
KEYWORD().register,
field(
"plugin",
choice(alias($.unquoted, $.val_string), $.val_variable),
),
field("signature", optional($.val_record)),
),
),

_stmt_hide: ($) => choice($.hide_mod, $.hide_env),

hide_mod: ($) =>
Expand Down Expand Up @@ -1530,13 +1517,12 @@ function _block_body_rules(suffix) {
/// Statements

["_statement" + suffix]: (
/**⋅@type {any} */ /** @type {{ [x: string]: string; _ctrl_statement?: any; _stmt_hide?: any; _stmt_overlay?: any; stmt_register?: any; stmt_source?: any; assignment?: any; }} */ $,
/**⋅@type {any} */ /** @type {{ [x: string]: string; _ctrl_statement?: any; _stmt_hide?: any; _stmt_overlay?: any; stmt_source?: any; assignment?: any; }} */ $,
) =>
choice(
$._ctrl_statement,
$._stmt_hide,
$._stmt_overlay,
$.stmt_register,
$.stmt_source,
alias_for_suffix($, "assignment", suffix),
alias_for_suffix($, "stmt_let", suffix),
Expand Down Expand Up @@ -2109,6 +2095,8 @@ function OPR() {
// membership tests
in: "in",
not_in: "not-in",
has: "has",
not_has: "not-has",
starts_with: "starts-with",
ends_with: "ends-with",

Expand Down Expand Up @@ -2151,12 +2139,6 @@ function PREC() {
};
}

function STATEMENT_PREC() {
return {
control: 1,
};
}

/// map of operators and their precedence
function TABLE() {
const multiplicatives = [
Expand Down Expand Up @@ -2191,6 +2173,8 @@ function PREDICATE() {
const memberships = [
OPR().in,
OPR().not_in,
OPR().has,
OPR().not_has,
OPR().starts_with,
OPR().ends_with,
];
Expand Down
67 changes: 5 additions & 62 deletions queries/nu/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"source-env"

"overlay"
"register"

"loop"
"while"
Expand Down Expand Up @@ -96,67 +95,11 @@ file_path: (val_string) @variable.parameter

;;; ---
;;; operators
(expr_binary [
"+"
"-"
"*"
"/"
"mod"
"//"
"++"
"**"
"=="
"!="
"<"
"<="
">"
">="
"=~"
"!~"
"and"
"or"
"xor"
"bit-or"
"bit-xor"
"bit-and"
"bit-shl"
"bit-shr"
"in"
"not-in"
"starts-with"
"ends-with"
] @operator )

(where_command [
"+"
"-"
"*"
"/"
"mod"
"//"
"++"
"**"
"=="
"!="
"<"
"<="
">"
">="
"=~"
"!~"
"and"
"or"
"xor"
"bit-or"
"bit-xor"
"bit-and"
"bit-shl"
"bit-shr"
"in"
"not-in"
"starts-with"
"ends-with"
] @operator)
(expr_binary
opr: _ @operator)

(where_command
opr: _ @operator)

(assignment [
"="
Expand Down
Loading