summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMichael Davis2022-10-22 17:51:20 +0000
committerBlaž Hrastnik2022-11-24 02:07:05 +0000
commit452f7d071ceb57aad9da36473e6d2a0f0bedb462 (patch)
tree5be13bfe1f8a8eaf220843c55045bc486aa4762c /runtime
parenta3f321a531554b51160f3fe7e6da1c269030f3b6 (diff)
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.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/edoc/highlights.scm2
-rw-r--r--runtime/queries/edoc/injections.scm4
-rw-r--r--runtime/queries/erlang/highlights.scm10
-rw-r--r--runtime/queries/erlang/injections.scm9
4 files changed, 17 insertions, 8 deletions
diff --git a/runtime/queries/edoc/highlights.scm b/runtime/queries/edoc/highlights.scm
index 4267cb9e..5bab7992 100644
--- a/runtime/queries/edoc/highlights.scm
+++ b/runtime/queries/edoc/highlights.scm
@@ -48,3 +48,5 @@
(language_identifier)
(quote_content)
] @markup.raw.block
+
+(parameter) @variable.parameter
diff --git a/runtime/queries/edoc/injections.scm b/runtime/queries/edoc/injections.scm
index 9630995b..28c44b9f 100644
--- a/runtime/queries/edoc/injections.scm
+++ b/runtime/queries/edoc/injections.scm
@@ -16,5 +16,5 @@
(tag) @_tag
(argument) @injection.content)
(#eq? @_tag "@type")
- (#set injection.language "erlang")
- (#set injection.include-children))
+ (#set! injection.language "erlang")
+ (#set! injection.include-children))
diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm
index 58c8fb8a..050fb613 100644
--- a/runtime/queries/erlang/highlights.scm
+++ b/runtime/queries/erlang/highlights.scm
@@ -94,10 +94,6 @@
(unary_operator operator: _ @operator)
["/" ":" "->"] @operator
-(tripledot) @comment.discard
-
-(comment) @comment
-
; Macros
(macro
"?"+ @constant
@@ -112,8 +108,14 @@
((variable) @comment.discard
(#match? @comment.discard "^_"))
+(tripledot) @comment.discard
+
+[(comment) (line_comment) (shebang)] @comment
+
; Basic types
(variable) @variable
+((atom) @constant.builtin.boolean
+ (#match? @constant.builtin.boolean "^(true|false)$"))
(atom) @string.special.symbol
(string) @string
(character) @constant.character
diff --git a/runtime/queries/erlang/injections.scm b/runtime/queries/erlang/injections.scm
index 07858185..11cbd01e 100644
--- a/runtime/queries/erlang/injections.scm
+++ b/runtime/queries/erlang/injections.scm
@@ -1,2 +1,7 @@
-((comment_content) @injection.content
- (#set! injection.language "edoc"))
+((line_comment (comment_content) @injection.content)
+ (#set! injection.language "edoc")
+ (#set! injection.include-children)
+ (#set! injection.combined))
+
+((comment (comment_content) @injection.content)
+ (#set! injection.language "comment"))