Skip to content

Commit 4d37bd6

Browse files
committed
feat: allow color declarations
1 parent 22723f2 commit 4d37bd6

File tree

5 files changed

+728
-660
lines changed

5 files changed

+728
-660
lines changed

grammar.js

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,55 +26,72 @@ module.exports = grammar({
2626
$.assignment,
2727
$.keyword,
2828
$.section,
29-
$._linebreak
30-
)
29+
$._linebreak,
30+
),
3131
),
3232

3333
declaration: ($) =>
3434
seq(
3535
field("name", $.variable),
3636
"=",
37-
field("value", choice($.mod, $.number, $.string_literal)),
38-
$._linebreak
37+
field("value", choice($.mod, $.number, $.string_literal, $.color)),
38+
$._linebreak,
3939
),
4040

41-
assignment: ($) => seq(field("name", $.name), "=", field("value", optional($._value)), $._linebreak),
41+
assignment: ($) =>
42+
seq(
43+
field("name", $.name),
44+
"=",
45+
field("value", optional($._value)),
46+
$._linebreak,
47+
),
4248

43-
keyword: ($) => seq(field("keyword", $.name), "=", field("value", $.params), $._linebreak),
49+
keyword: ($) =>
50+
seq(
51+
field("keyword", $.name),
52+
"=",
53+
field("value", $.params),
54+
$._linebreak,
55+
),
4456

4557
section: ($) =>
4658
seq(
47-
seq(field("name", $.name), optional(seq(":", field("device", $.device_name)))),
59+
seq(
60+
field("name", $.name),
61+
optional(seq(":", field("device", $.device_name))),
62+
),
4863
"{",
4964
$._linebreak,
5065
repeat(choice($.assignment, $.keyword, $.section, $._linebreak)),
5166
"}",
52-
$._linebreak
67+
$._linebreak,
5368
),
5469

5570
source: ($) => seq("source", "=", $.string, $._linebreak),
5671

57-
arguments: ($) => repeat1(choice($.number, alias($._window_rule_argument, $.string))),
72+
arguments: ($) =>
73+
repeat1(choice($.number, alias($._window_rule_argument, $.string))),
5874

5975
window_rule: ($) => seq($.name, optional($.arguments)),
6076

61-
rules: ($) => seq("[", $.window_rule, repeat(seq(';', $.window_rule)), "]"),
77+
rules: ($) => seq("[", $.window_rule, repeat(seq(";", $.window_rule)), "]"),
6278

63-
exec: ($) => choice(
64-
seq(
65-
choice("exec-once", "exec"),
66-
"=",
67-
optional($.rules),
68-
$.string,
69-
$._linebreak,
70-
),
71-
seq(
72-
choice("execr-once", "execr", "exec-shutdown"),
73-
"=",
74-
$.string,
75-
$._linebreak,
79+
exec: ($) =>
80+
choice(
81+
seq(
82+
choice("exec-once", "exec"),
83+
"=",
84+
optional($.rules),
85+
$.string,
86+
$._linebreak,
87+
),
88+
seq(
89+
choice("execr-once", "execr", "exec-shutdown"),
90+
"=",
91+
$.string,
92+
$._linebreak,
93+
),
7694
),
77-
),
7895

7996
_value: ($) =>
8097
choice(
@@ -88,7 +105,7 @@ module.exports = grammar({
88105
$.string,
89106
$.variable,
90107
prec(1, $.color),
91-
prec(1, $.position)
108+
prec(1, $.position),
92109
),
93110

94111
boolean: () => choice("true", "false", "on", "off", "yes", "no"),
@@ -132,7 +149,7 @@ module.exports = grammar({
132149
"LOGO",
133150
"MOD4",
134151
"MOD5",
135-
"TAB"
152+
"TAB",
136153
),
137154

138155
keys: ($) => choice(seq($.mod, $.mod), seq($.variable, $.mod)),
@@ -148,7 +165,7 @@ module.exports = grammar({
148165

149166
device_name: () => /[\w\d][\w\d\/\.\-:]*/,
150167

151-
variable: () => seq("$", /\w[\w\d]*/),
168+
variable: () => seq("$", field("name", /\w[\w\d]*/)),
152169

153170
_zero: () => "0",
154171

@@ -157,6 +174,5 @@ module.exports = grammar({
157174
_linebreak: () => "\n",
158175

159176
comment: () => seq("#", /.*/),
160-
161177
},
162178
});

queries/hyprlang/outline.scm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(section
2+
name: (name) @name) @item

src/grammar.json

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)