Skip to content

Commit

Permalink
update: separate keyword from variable
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Aug 26, 2023
1 parent 62dfb6d commit 0b49c5d
Show file tree
Hide file tree
Showing 6 changed files with 1,685 additions and 2,445 deletions.
21 changes: 9 additions & 12 deletions grammar.js
Expand Up @@ -11,28 +11,26 @@ module.exports = grammar({
choice(
$.source,
$.exec,
$.declaration,
$.assignment,
$.command,
$.keyword,
$.section,
$._linebreak
)
),

assignment: ($) => seq($.variable, "=", field("value", $._value)),
declaration: ($) => seq($.variable, "=", $._value, $._linebreak),

command: ($) =>
seq(
choice($.name),
"=",
choice(seq(field("value", $._value), $._linebreak), $._linebreak)
),
assignment: ($) => seq($.name, "=", optional($._value), $._linebreak),

keyword: ($) => seq($.name, "=", $.params, $._linebreak),

section: ($) =>
seq(
choice($.name, seq($.name, ":", field("device", $.name))),
"{",
$._linebreak,
repeat(choice($.command, $.section)),
repeat(choice($.assignment, $.keyword, $.section)),
"}",
$._linebreak
),
Expand All @@ -51,8 +49,7 @@ module.exports = grammar({
$.mod,
$.keys,
$.string,
$.variable,
$.params
$.variable
),

boolean: () => choice("true", "false", "on", "off", "yes", "no"),
Expand Down Expand Up @@ -94,7 +91,7 @@ module.exports = grammar({

string: () => token(prec(-1, /[^\n,]+/)),

params: ($) => prec.right(-1, seq($._value, repeat(seq(",", $._value)))),
params: ($) => prec(-1, seq($._value, repeat(seq(",", $._value)))),

name: () => /[a-zA-Z][a-zA-Z0-9_\.\-]*/,

Expand Down
6 changes: 5 additions & 1 deletion queries/hypr/highlights.scm
Expand Up @@ -5,7 +5,11 @@
(exec "exec" @keyword)
(exec "exec-once" @keyword)

(command
(keyword
(name) @keyword
)

(assignment
(name) @property
)

Expand Down
88 changes: 49 additions & 39 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b49c5d

Please sign in to comment.