Improve Edoc highlighting within Erlang
This highlights edoc within Erlang comments. The trick was to have
the Erlang grammar consume newlines and then give them to EDoc in the
injection to use so that line-wise elements could be parsed accurately.
commit452f7d071ceb57aad9da36473e6d2a0f0bedb462
authorMichael Davis <mcarsondavis@gmail.com>
dateSat 22 Oct 2022, 12:51 (4 years ago)
parenta3f321a
languages.toml+2−2
@@ -1184,7 +1184,7 @@ language-server = { command = "erlang_ls" }
11841184
11851185[[grammar]]
11861186name = "erlang"
1187−source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "0e7d677d11a7379686c53c616825714ccb728059" }
1187+source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "ce0ed253d72c199ab93caba7542b6f62075339c4" }
11881188
11891189[[language]]
11901190name = "kotlin"
@@ -1574,7 +1574,7 @@ indent = { tab-width = 4, unit = " " }
15741574
15751575[[grammar]]
15761576name = "edoc"
1577−source = { git = "https://github.com/the-mikedavis/tree-sitter-edoc", rev = "1691ec0aa7ad1ed9fa295590545f27e570d12d60" }
1577+source = { git = "https://github.com/the-mikedavis/tree-sitter-edoc", rev = "74774af7b45dd9cefbf9510328fc6ff2374afc50" }
15781578
15791579[[language]]
15801580name = "jsdoc"
runtime/queries/edoc/highlights.scm+2
@@ -48,3 +48,5 @@
4848 (language_identifier)
4949 (quote_content)
5050] @markup.raw.block
51+
52+(parameter) @variable.parameter
runtime/queries/edoc/injections.scm+2−2
@@ -16,5 +16,5 @@
1616 (tag) @_tag
1717 (argument) @injection.content)
1818 (#eq? @_tag "@type")
19− (#set injection.language "erlang")
20− (#set injection.include-children))
19+ (#set! injection.language "erlang")
20+ (#set! injection.include-children))
runtime/queries/erlang/highlights.scm+6−4
@@ -94,10 +94,6 @@
9494(unary_operator operator: _ @operator)
9595["/" ":" "->"] @operator
9696
97−(tripledot) @comment.discard
98−
99−(comment) @comment
100−
10197; Macros
10298(macro
10399 "?"+ @constant
@@ -112,8 +108,14 @@
112108((variable) @comment.discard
113109 (#match? @comment.discard "^_"))
114110
111+(tripledot) @comment.discard
112+
113+[(comment) (line_comment) (shebang)] @comment
114+
115115; Basic types
116116(variable) @variable
117+((atom) @constant.builtin.boolean
118+ (#match? @constant.builtin.boolean "^(true|false)$"))
117119(atom) @string.special.symbol
118120(string) @string
119121(character) @constant.character
runtime/queries/erlang/injections.scm+7−2
@@ -1,2 +1,7 @@
1−((comment_content) @injection.content
2− (#set! injection.language "edoc"))
1+((line_comment (comment_content) @injection.content)
2+ (#set! injection.language "edoc")
3+ (#set! injection.include-children)
4+ (#set! injection.combined))
5+
6+((comment (comment_content) @injection.content)
7+ (#set! injection.language "comment"))