Update tree-sitter-erlang and highlights

A few changes:

* 0-arity type specs like the following previously would not have the
  expected 'variable.parameter' highlighting for the return type:

    -spec foo() -> Value when Value :: term().

* Highlight module, type and function docs as documentation comments
  and inject markdown into them.

* Replace `#match?` predicates with `#any-of?` where possible.

* Remove custom auto-pairs. Now that Erlang uses markdown for
  documentation, the asciidoc-style backtick-singlequote pair is no
  longer useful.
This commit is contained in:
Michael Davis 2023-04-14 11:41:20 -05:00 committed by Blaž Hrastnik
parent 459eb9a4c1
commit fdcd461e65
4 changed files with 24 additions and 14 deletions

View File

@ -1711,17 +1711,9 @@ comment-token = "%%"
indent = { tab-width = 4, unit = " " } indent = { tab-width = 4, unit = " " }
language-servers = [ "erlang-ls" ] language-servers = [ "erlang-ls" ]
[language.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'"' = '"'
"'" = "'"
'`' = "'"
[[grammar]] [[grammar]]
name = "erlang" name = "erlang"
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "731e50555a51f0d8635992b0e60dc98cc47a58d7" } source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "9d4b36a76d5519e3dbf1ec4f4b61bb1a293f584c" }
[[language]] [[language]]
name = "kotlin" name = "kotlin"

View File

@ -3,7 +3,7 @@
(attribute (attribute
name: (atom) @keyword name: (atom) @keyword
(arguments (atom) @namespace) (arguments (atom) @namespace)
(#match? @keyword "(module|behaviou?r)")) (#any-of? @keyword "module" "behaviour" "behavior"))
(attribute (attribute
name: (atom) @keyword name: (atom) @keyword
@ -50,12 +50,20 @@
name: (atom) @keyword name: (atom) @keyword
(arguments (arguments
(_) @keyword.directive) (_) @keyword.directive)
(#match? @keyword "ifn?def")) (#any-of? @keyword "ifndef" "ifdef"))
(attribute (attribute
name: (atom) @keyword name: (atom) @keyword
module: (atom) @namespace module: (atom) @namespace
(#match? @keyword "(spec|callback)")) (#any-of? @keyword "spec" "callback"))
(attribute
name: (atom) @keyword
(arguments [
(string)
(sigil)
] @comment.block.documentation)
(#any-of? @keyword "doc" "moduledoc"))
; Functions ; Functions
(function_clause name: (atom) @function) (function_clause name: (atom) @function)
@ -84,7 +92,7 @@
((attribute ((attribute
name: (atom) @keyword name: (atom) @keyword
(stab_clause (stab_clause
pattern: (arguments (variable) @variable.parameter) pattern: (arguments (variable)? @variable.parameter)
body: (variable)? @variable.parameter)) body: (variable)? @variable.parameter))
(#match? @keyword "(spec|callback)")) (#match? @keyword "(spec|callback)"))
; functions ; functions

View File

@ -5,3 +5,13 @@
((comment (comment_content) @injection.content) ((comment (comment_content) @injection.content)
(#set! injection.language "comment")) (#set! injection.language "comment"))
; EEP-59 doc attributes use markdown by default.
(attribute
name: (atom) @_attribute
(arguments [
(string (quoted_content) @injection.content)
(sigil (quoted_content) @injection.content)
])
(#set! injection.language "markdown")
(#any-of? @_attribute "doc" "moduledoc"))

View File

@ -1,7 +1,7 @@
; Specs and Callbacks ; Specs and Callbacks
(attribute (attribute
(stab_clause (stab_clause
pattern: (arguments (variable) @local.definition) pattern: (arguments (variable)? @local.definition)
; If a spec uses a variable as the return type (and later a `when` clause to type it): ; If a spec uses a variable as the return type (and later a `when` clause to type it):
body: (variable)? @local.definition)) @local.scope body: (variable)? @local.definition)) @local.scope