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.
This commit is contained in:
Michael Davis 2022-10-22 12:51:20 -05:00 committed by Blaž Hrastnik
parent a3f321a531
commit 452f7d071c
5 changed files with 19 additions and 10 deletions

View File

@ -1184,7 +1184,7 @@ language-server = { command = "erlang_ls" }
[[grammar]]
name = "erlang"
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "0e7d677d11a7379686c53c616825714ccb728059" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "ce0ed253d72c199ab93caba7542b6f62075339c4" }
[[language]]
name = "kotlin"
@ -1574,7 +1574,7 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "edoc"
source = { git = "https://github.com/the-mikedavis/tree-sitter-edoc", rev = "1691ec0aa7ad1ed9fa295590545f27e570d12d60" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-edoc", rev = "74774af7b45dd9cefbf9510328fc6ff2374afc50" }
[[language]]
name = "jsdoc"

View File

@ -48,3 +48,5 @@
(language_identifier)
(quote_content)
] @markup.raw.block
(parameter) @variable.parameter

View File

@ -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))

View File

@ -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

View File

@ -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"))