Skip to content

Commit 303302d

Browse files
authored
Add more syntax overrides (#84)
- Adds `!`, `?`, and `@` as word characters for identifiers - Does the same for HEEx, but only for the first two - Adds `\` as a word character for char literals - Adds `&` as a word character for parameter placeholders within anonymous function captures - Disables bracket auto-closing within sigils using those brackets as delimiters - Fixes Elixir completion query characters for Tailwind - Fixes range inclusivity for comments override in HEEx
1 parent 79cfe22 commit 303302d

4 files changed

Lines changed: 93 additions & 15 deletions

File tree

languages/elixir/config.toml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,48 @@ path_suffixes = ["ex", "exs"]
44
line_comments = ["# "]
55
autoclose_before = ";:.,=}])>"
66
brackets = [
7-
{ start = "{", end = "}", close = true, newline = true },
8-
{ start = "[", end = "]", close = true, newline = true },
9-
{ start = "(", end = ")", close = true, newline = true },
10-
{ start = "do", end = "end", close = false, newline = true, not_in = ["string", "comment"] },
11-
{ start = "fn", end = "end", close = false, newline = true, not_in = ["string", "comment"] },
7+
{ start = "{", end = "}", close = true, newline = true, not_in = ["sigil_curly"] },
8+
{ start = "[", end = "]", close = true, newline = true, not_in = ["sigil_square"] },
9+
{ start = "(", end = ")", close = true, newline = true, not_in = ["sigil_round"] },
1210
{ start = "<<", end = ">>", close = false, newline = true },
13-
{ start = "\"\"\"", end = "\n\"\"\"", close = true, newline = true, not_in = ["string", "comment"] },
14-
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
15-
{ start = "'''", end = "\n'''", close = true, newline = true, not_in = ["string", "comment"] },
16-
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
11+
{ start = "\"\"\"", end = "\n\"\"\"", close = true, newline = true, not_in = [
12+
"comment",
13+
"string",
14+
"quoted_atom",
15+
"sigil_string",
16+
] },
17+
{ start = "\"", end = "\"", close = true, newline = false, not_in = [
18+
"comment",
19+
"string",
20+
"quoted_atom",
21+
"sigil_string",
22+
] },
23+
{ start = "'''", end = "\n'''", close = true, newline = true, not_in = [
24+
"comment",
25+
"string",
26+
"quoted_atom",
27+
"sigil_string",
28+
] },
29+
{ start = "'", end = "'", close = true, newline = false, not_in = [
30+
"comment",
31+
"string",
32+
"quoted_atom",
33+
"sigil_string",
34+
] },
1735
]
1836
tab_size = 2
1937
decrease_indent_pattern = '^\s*(after|catch|else|rescue)$'
2038
scope_opt_in_language_servers = ["tailwindcss-language-server"]
2139

2240
[overrides.string]
23-
word_characters = ["-"]
41+
completion_query_characters = ["-"]
2442
opt_into_language_servers = ["tailwindcss-language-server"]
43+
44+
[overrides.identifier]
45+
word_characters = ["!", "?", "@"]
46+
47+
[overrides.char]
48+
word_characters = ["\\"]
49+
50+
[overrides.capture]
51+
word_characters = ["&"]

languages/elixir/overrides.scm

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,49 @@
44
(string)
55
(charlist)
66
] @string
7+
8+
[
9+
(quoted_atom)
10+
(quoted_keyword)
11+
] @quoted_atom
12+
13+
[
14+
(identifier)
15+
(atom)
16+
(keyword)
17+
(unary_operator
18+
operator: "@")
19+
] @identifier
20+
21+
(char) @char
22+
23+
(unary_operator
24+
operator: "&"
25+
operand: (integer)) @capture
26+
27+
(sigil
28+
quoted_start: "{"
29+
quoted_end: "}") @sigil_curly
30+
31+
(sigil
32+
quoted_start: "["
33+
quoted_end: "]") @sigil_square
34+
35+
(sigil
36+
quoted_start: "("
37+
quoted_end: ")") @sigil_round
38+
39+
[
40+
(sigil
41+
quoted_start: "\"\"\""
42+
quoted_end: "\"\"\"")
43+
(sigil
44+
quoted_start: "\""
45+
quoted_end: "\"")
46+
(sigil
47+
quoted_start: "'''"
48+
quoted_end: "'''")
49+
(sigil
50+
quoted_start: "'"
51+
quoted_end: "'")
52+
] @sigil_string

languages/heex/config.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HEEX"
22
grammar = "heex"
33
path_suffixes = ["heex", "html.eex", "leex", "neex"]
4-
block_comment = { start = "<%!--", prefix = "", end = "--%>", tab_size = 0 }
4+
block_comment = { start = "<%!-- ", prefix = "", end = " --%>", tab_size = 0 }
55
wrap_characters = { start_prefix = "<", start_suffix = ">", end_prefix = "</", end_suffix = ">" }
66
autoclose_before = ">})%"
77
brackets = [
@@ -10,13 +10,16 @@ brackets = [
1010
{ start = "(", end = ")", close = true, newline = true },
1111
{ start = "<", end = ">", close = true, newline = true },
1212
{ start = "%", end = "%", close = true, newline = true },
13-
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
14-
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
15-
{ start = "!--", end = " --", close = true, newline = false, not_in = ["string", "comment"] },
13+
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
14+
{ start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] },
15+
{ start = "!--", end = " --", close = true, newline = false, not_in = ["comment", "string"] },
1616
]
1717
tab_size = 2
1818
scope_opt_in_language_servers = ["tailwindcss-language-server"]
1919

2020
[overrides.string]
2121
completion_query_characters = ["-"]
2222
opt_into_language_servers = ["tailwindcss-language-server"]
23+
24+
[overrides.function]
25+
word_characters = ["!", "?"]

languages/heex/overrides.scm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
(comment) @comment.inclusive
1+
(comment) @comment
22

33
[
44
(attribute_value)
55
(quoted_attribute_value)
66
] @string
7+
8+
(function) @function

0 commit comments

Comments
 (0)