Skip to content

Commit 664bb40

Browse files
committed
style: format with *Prettier*
1 parent 7158479 commit 664bb40

2 files changed

Lines changed: 71 additions & 45 deletions

File tree

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

grammar.js

Lines changed: 70 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = grammar({
2020
file: ($) =>
2121
repeat(seq(optional(choice($._statement_list, $.if_statement)), $._eol)),
2222

23-
_statement_list: ($) => sep1($._command, ';'),
23+
_statement_list: ($) => sep1($._command, ";"),
2424

2525
_command: ($) =>
2626
choice(
@@ -122,18 +122,18 @@ module.exports = grammar({
122122
alias(/\%if/, $.if_keyword),
123123
/\s+/,
124124
alias($.string, $.condition),
125-
sep0($._command, ';'),
126-
repeat(seq(
127-
alias(/\%elif/, $.elif_keyword),
128-
/\s+/,
129-
alias($.string, $.condition),
130-
sep0($._command, ';'),
131-
)),
132-
optional(seq(
133-
alias(/\%else/, $.else_keyword),
134-
/\s+/,
135-
sep0($._command, ';'),
136-
)),
125+
sep0($._command, ";"),
126+
repeat(
127+
seq(
128+
alias(/\%elif/, $.elif_keyword),
129+
/\s+/,
130+
alias($.string, $.condition),
131+
sep0($._command, ";"),
132+
),
133+
),
134+
optional(
135+
seq(alias(/\%else/, $.else_keyword), /\s+/, sep0($._command, ";")),
136+
),
137137
alias(/%endif/, $.endif_keyword),
138138
),
139139

@@ -143,6 +143,7 @@ module.exports = grammar({
143143
command(
144144
$,
145145
choice("attach-session", "attach"),
146+
146147
cmd_opts(
147148
options($, "dErx"),
148149
$._working_directory,
@@ -152,10 +153,7 @@ module.exports = grammar({
152153
),
153154
_note: ($) => option($, "N", alias($._string, $.note)),
154155
_key_table: ($) => option($, "T", alias($._string, $.key_table)),
155-
key: ($) => prec.right(repeat1(choice(
156-
$.backslash_escape,
157-
$._string,
158-
))),
156+
key: ($) => prec.right(repeat1(choice($.backslash_escape, $._string))),
159157
bind_key_directive: ($) =>
160158
command(
161159
$,
@@ -366,19 +364,23 @@ module.exports = grammar({
366364
),
367365
_variable_name: (_) => /[A-Za-z_][A-Za-z0-9_]*/,
368366
environment_assignment: ($) =>
369-
prec.right(seq(
370-
field('name', alias($._variable_name, $.name)),
371-
'=',
372-
field('value', alias(optional($._string), $.value))
373-
)),
367+
prec.right(
368+
seq(
369+
field("name", alias($._variable_name, $.name)),
370+
"=",
371+
field("value", alias(optional($._string), $.value)),
372+
),
373+
),
374374
hidden_assignment: ($) =>
375-
prec.right(seq(
376-
alias(/\%hidden/, $.hidden_keyword),
377-
/\s+/,
378-
field('name', alias($._variable_name, $.name)),
379-
'=',
380-
field('value', alias(optional($._string), $.value))
381-
)),
375+
prec.right(
376+
seq(
377+
alias(/\%hidden/, $.hidden_keyword),
378+
/\s+/,
379+
field("name", alias($._variable_name, $.name)),
380+
"=",
381+
field("value", alias(optional($._string), $.value)),
382+
),
383+
),
382384
find_window_directive: ($) =>
383385
command(
384386
$,
@@ -676,7 +678,12 @@ module.exports = grammar({
676678
command(
677679
$,
678680
choice("run-shell", "run"),
679-
cmd_opts(options($, "bC"), $._delay, $._start_directory, $._target_pane),
681+
cmd_opts(
682+
options($, "bC"),
683+
$._delay,
684+
$._start_directory,
685+
$._target_pane,
686+
),
680687
$._shell,
681688
),
682689
save_buffer_directive: ($) =>
@@ -893,13 +900,25 @@ module.exports = grammar({
893900
attribute: (_) => /[a-z-]+/,
894901
raw_string_quote: (_) => "'",
895902
raw_string: ($) =>
896-
seq("'", repeat(choice(
897-
$.variable_raw, $.hash_escape, $._hash, /([^#'])+/,
898-
)), "'"),
903+
seq(
904+
"'",
905+
repeat(choice($.variable_raw, $.hash_escape, $._hash, /([^#'])+/)),
906+
"'",
907+
),
899908
string: ($) =>
900-
seq('"', repeat(choice(
901-
$.variable, $.backslash_escape, $.hash_escape, $._hash, /([^#"\\]|\\\r?\n)+/,
902-
)), '"'),
909+
seq(
910+
'"',
911+
repeat(
912+
choice(
913+
$.variable,
914+
$.backslash_escape,
915+
$.hash_escape,
916+
$._hash,
917+
/([^#"\\]|\\\r?\n)+/,
918+
),
919+
),
920+
'"',
921+
),
903922
_word: (_) => /([^"'\\\s])([^"'\\\s]|\\["'\\\s])*/,
904923
_string: ($) => choice($.string, $.raw_string, $._word, $._code),
905924
_commands: ($) => repeat1($._command),
@@ -948,7 +967,7 @@ function spaceSep1($, rule) {
948967
}
949968

950969
function quoted_string(char, name, char_rule = null) {
951-
char_rule = char_rule || char
970+
char_rule = char_rule || char;
952971
return seq(
953972
char_rule,
954973
alias(
@@ -975,7 +994,7 @@ function cmd_opts(...args) {
975994
}
976995

977996
function variable_rule($, quote) {
978-
const variable = quote == '"' ? $.variable : $.variable_raw
997+
const variable = quote == '"' ? $.variable : $.variable_raw;
979998
return choice(
980999
seq(token.immediate(prec(1, "#")), $.variable_name_short),
9811000
seq(
@@ -988,12 +1007,18 @@ function variable_rule($, quote) {
9881007
seq(alias($.variable_name, $.function_name), ":"),
9891008
seq($.operator, ":"),
9901009
),
991-
commaSep1(repeat(choice(
992-
variable,
993-
$.hash_escape,
994-
$._hash,
995-
token.immediate(prec(1, quote == '"' ? /[^,}"#]+/ : /[^,}'#]+/)),
996-
))),
1010+
commaSep1(
1011+
repeat(
1012+
choice(
1013+
variable,
1014+
$.hash_escape,
1015+
$._hash,
1016+
token.immediate(
1017+
prec(1, quote == '"' ? /[^,}"#]+/ : /[^,}'#]+/),
1018+
),
1019+
),
1020+
),
1021+
),
9971022
),
9981023
),
9991024
"}",
@@ -1008,5 +1033,5 @@ function variable_rule($, quote) {
10081033
),
10091034
"]",
10101035
),
1011-
)
1036+
);
10121037
}

0 commit comments

Comments
 (0)