Skip to content

Commit

Permalink
fix(#17): add support for display and position
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Jun 15, 2024
1 parent e5da7d0 commit 9c3dffd
Show file tree
Hide file tree
Showing 7 changed files with 1,718 additions and 1,367 deletions.
20 changes: 16 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ module.exports = grammar({

extras: ($) => [/[ \t]/, $.comment],

conflicts: ($) => [[$._value, $.gradient]],
conflicts: ($) => [
[$._value, $.gradient],
[$.number, $.legacy_hex],
],

word: ($) => $.string,

Expand Down Expand Up @@ -52,23 +55,26 @@ module.exports = grammar({
$.boolean,
$.number,
$.vec2,
$.display,
$.color,
$.gradient,
$.mod,
$.keys,
$.string,
$.variable
$.variable,
prec(1, $.position)
),

boolean: () => choice("true", "false", "on", "off", "yes", "no"),

number: () => seq(optional(choice("+", "-")), /[0-9][0-9\.]*/),
number: ($) =>
choice($._zero, seq(optional(choice("+", "-")), /[0-9][0-9\.]*/)),

vec2: ($) => seq($.number, $.number),

color: ($) => choice($.legacy_hex, $.rgb),

legacy_hex: ($) => seq("0x", $.hex),
legacy_hex: ($) => seq($._zero, "x", $.hex),

rgb: ($) =>
seq(choice("rgb", "rgba"), "(", choice($.hex, $.number_tuple), ")"),
Expand All @@ -77,6 +83,10 @@ module.exports = grammar({

number_tuple: ($) => seq($.number, repeat(seq(",", $.number))),

display: ($) => seq($.position, optional(seq("@", $.number))),

position: ($) => seq($.number, "x", $.number),

hex: () => /[0-9a-fA-F]{6,8}/,

angle: () => seq(/[0-9]{1,3}/, "deg"),
Expand Down Expand Up @@ -113,6 +123,8 @@ module.exports = grammar({

variable: () => seq("$", /\w[\w\d]*/),

_zero: () => "0",

_linebreak: () => "\n",

comment: () => seq("#", /.*/),
Expand Down
2 changes: 2 additions & 0 deletions queries/hyprlang/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
(legacy_hex)
(angle)
(hex)
(display)
(position)
] @number

"deg" @type
Expand Down
104 changes: 92 additions & 12 deletions src/grammar.json

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

60 changes: 57 additions & 3 deletions src/node-types.json

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

Loading

0 comments on commit 9c3dffd

Please sign in to comment.