mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat: add @comment.documentation where applicable
This commit is contained in:
parent
3a82b58745
commit
5a87bc98da
32 changed files with 256 additions and 58 deletions
|
|
@ -94,11 +94,9 @@
|
|||
[
|
||||
"exception"
|
||||
"raise"
|
||||
] @exception
|
||||
(comment) @comment
|
||||
(comment) @spell ;; spell-check comments
|
||||
(string_literal) @string
|
||||
(string_literal) @spell ;; spell-check strings
|
||||
] @exception
|
||||
(comment) @comment @spell
|
||||
(string_literal) @string @spell
|
||||
(character_literal) @string
|
||||
(numeric_literal) @number
|
||||
|
||||
|
|
@ -173,6 +171,24 @@
|
|||
; ] @function.spec
|
||||
;)
|
||||
|
||||
((comment) @comment.documentation
|
||||
. [
|
||||
(entry_declaration)
|
||||
(subprogram_declaration)
|
||||
(parameter_specification)
|
||||
])
|
||||
|
||||
(compilation_unit
|
||||
. (comment) @comment.documentation)
|
||||
|
||||
(component_list
|
||||
(component_declaration)
|
||||
. (comment) @comment.documentation)
|
||||
|
||||
(enumeration_type_definition
|
||||
(identifier)
|
||||
. (comment) @comment.documentation)
|
||||
|
||||
;; Highlight errors in red. This is not very useful in practice, as text will
|
||||
;; be highlighted as user types, and the error could be elsewhere in the code.
|
||||
;; This also requires defining :hi @error guifg=Red for instance.
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@
|
|||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
;; Parameters
|
||||
(parameter_declaration
|
||||
declarator: (identifier) @parameter)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,14 @@
|
|||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
||||
(using_directive
|
||||
(identifier) @type)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,18 @@
|
|||
(line_comment)
|
||||
(block_comment)
|
||||
(nesting_block_comment)
|
||||
] @comment
|
||||
] @comment @spell
|
||||
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
||||
((block_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
((nesting_block_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$"))
|
||||
|
||||
[
|
||||
"(" ")"
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@
|
|||
(false) @boolean
|
||||
(null_literal) @constant.builtin
|
||||
|
||||
(documentation_comment) @comment
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
(documentation_comment) @comment.documentation @spell
|
||||
|
||||
; Keywords
|
||||
; --------------------
|
||||
|
|
|
|||
|
|
@ -123,12 +123,13 @@
|
|||
(undefined)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
(hash_bang_line) @preproc
|
||||
|
||||
(comment) @spell
|
||||
|
||||
(string) @string @spell
|
||||
(template_string) @string
|
||||
(escape_sequence) @string.escape
|
||||
|
|
|
|||
|
|
@ -29,12 +29,10 @@
|
|||
((identifier) @comment (#match? @comment "^_"))
|
||||
|
||||
; Comments
|
||||
(comment) @comment
|
||||
(comment) @spell
|
||||
(comment) @comment @spell
|
||||
|
||||
; Strings
|
||||
(string) @string
|
||||
(string) @spell
|
||||
(string) @string @spell
|
||||
|
||||
; Modules
|
||||
(alias) @type
|
||||
|
|
@ -214,15 +212,15 @@
|
|||
(unary_operator
|
||||
operator: "@"
|
||||
operand: (call
|
||||
target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment
|
||||
target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment.documentation
|
||||
(arguments [
|
||||
(string)
|
||||
(boolean)
|
||||
(charlist)
|
||||
(sigil
|
||||
"~" @comment
|
||||
((sigil_name) @comment)
|
||||
quoted_start: _ @comment
|
||||
(quoted_content) @comment
|
||||
quoted_end: _ @comment)
|
||||
] @comment))) @comment
|
||||
"~" @comment.documentation
|
||||
((sigil_name) @comment.documentation)
|
||||
quoted_start: _ @comment.documentation
|
||||
(quoted_content) @comment.documentation
|
||||
quoted_end: _ @comment.documentation)
|
||||
] @comment.documentation))) @comment.documentation
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
] @comment @spell
|
||||
|
||||
((block_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^{[-]|[^|]"))
|
||||
|
||||
|
||||
; Keywords
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@
|
|||
(integer) @number
|
||||
(float) @float
|
||||
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[%%][%%]"))
|
||||
|
||||
;; keyword
|
||||
[
|
||||
|
|
@ -104,7 +107,6 @@
|
|||
(type_alias name: _ @type) @type.definition
|
||||
(spec) @type.definition
|
||||
|
||||
(comment) @comment
|
||||
[(string) (binary)] @string
|
||||
|
||||
;;; expr_function_call
|
||||
|
|
|
|||
|
|
@ -324,6 +324,9 @@
|
|||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^!>"))
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
|
|
|
|||
|
|
@ -82,11 +82,14 @@
|
|||
(identifier) @variable
|
||||
|
||||
; Comments
|
||||
[
|
||||
(comment)
|
||||
] @comment @spell
|
||||
|
||||
[
|
||||
(module_comment)
|
||||
(statement_comment)
|
||||
(comment)
|
||||
] @comment
|
||||
] @comment.documentation @spell
|
||||
|
||||
; Unused Identifiers
|
||||
[
|
||||
|
|
|
|||
|
|
@ -196,20 +196,46 @@
|
|||
(float_literal) @float
|
||||
(imaginary_literal) @number
|
||||
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(nil) @constant.builtin
|
||||
|
||||
(keyed_element
|
||||
. (literal_element (identifier) @field))
|
||||
(field_declaration name: (field_identifier) @field)
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
;; Doc Comments
|
||||
|
||||
(source_file . (comment)+ @comment.documentation)
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (const_declaration))
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (function_declaration))
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (type_declaration))
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (var_declaration))
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
|
||||
; Spell
|
||||
|
||||
((interpreted_string_literal) @spell
|
||||
(#not-has-parent? @spell
|
||||
import_spec
|
||||
)
|
||||
)
|
||||
(#not-has-parent? @spell import_spec))
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@
|
|||
[
|
||||
(comment)
|
||||
(heredoc)
|
||||
] @comment
|
||||
] @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
"function" @keyword.function
|
||||
|
||||
|
|
|
|||
|
|
@ -279,3 +279,12 @@
|
|||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment @spell
|
||||
|
||||
((block_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
|
|
|||
|
|
@ -217,12 +217,13 @@
|
|||
|
||||
;;; Literals
|
||||
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
(shebang_line) @preproc
|
||||
|
||||
(comment) @spell
|
||||
|
||||
(real_literal) @float
|
||||
[
|
||||
(integer_literal)
|
||||
|
|
|
|||
|
|
@ -187,6 +187,12 @@
|
|||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[-][-][-]"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
||||
|
||||
(hash_bang_line) @preproc
|
||||
|
||||
(number) @number
|
||||
|
|
|
|||
|
|
@ -248,7 +248,36 @@
|
|||
|
||||
; -- Comments
|
||||
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
. [(unit) (declProc)])
|
||||
|
||||
(declTypes
|
||||
(comment) @comment.documentation
|
||||
. (declType))
|
||||
|
||||
(declSection
|
||||
(comment) @comment.documentation
|
||||
. [(declField) (declProc)])
|
||||
|
||||
(declEnum
|
||||
(comment) @comment.documentation
|
||||
. (declEnumValue))
|
||||
|
||||
(declConsts
|
||||
(comment) @comment.documentation
|
||||
. (declConst))
|
||||
|
||||
(declVars
|
||||
(comment) @comment.documentation
|
||||
. (declVar))
|
||||
|
||||
(pp) @preproc
|
||||
|
||||
; -- Type declaration
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@
|
|||
"type"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
(comment)
|
||||
(developer_comment)
|
||||
] @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
(developer_comment) @comment.documentation @spell
|
||||
|
||||
[
|
||||
(attribute)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,10 @@
|
|||
(false)
|
||||
] @boolean
|
||||
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
[
|
||||
"("
|
||||
|
|
@ -53,7 +56,7 @@
|
|||
"}"
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
";"
|
||||
|
|
|
|||
|
|
@ -130,5 +130,6 @@
|
|||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(qldoc)
|
||||
] @comment
|
||||
] @comment @spell
|
||||
|
||||
(qldoc) @comment.documentation
|
||||
|
|
|
|||
|
|
@ -173,13 +173,30 @@
|
|||
(float) @float
|
||||
|
||||
[
|
||||
(nil)
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(comment) @comment
|
||||
(comment) @spell
|
||||
(nil) @constant.builtin
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
(program
|
||||
(comment)+ @comment.documentation
|
||||
(class))
|
||||
|
||||
(module
|
||||
(comment)+ @comment.documentation
|
||||
(body_statement (class)))
|
||||
|
||||
(class
|
||||
(comment)+ @comment.documentation
|
||||
(body_statement (method)))
|
||||
|
||||
(body_statement
|
||||
(comment)+ @comment.documentation
|
||||
(method))
|
||||
|
||||
(string_content) @spell
|
||||
|
||||
; Operators
|
||||
|
|
|
|||
|
|
@ -148,6 +148,18 @@
|
|||
(block_comment)
|
||||
] @comment @spell
|
||||
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
((line_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^//!"))
|
||||
|
||||
((block_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
((block_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][!]"))
|
||||
|
||||
(boolean_literal) @boolean
|
||||
(integer_literal) @number
|
||||
(float_literal) @float
|
||||
|
|
|
|||
|
|
@ -234,6 +234,9 @@
|
|||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
;; `case` is a conditional keyword in case_block
|
||||
|
||||
(case_block
|
||||
|
|
|
|||
|
|
@ -182,3 +182,10 @@
|
|||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
(class_definition
|
||||
(comment) @comment.documentation)
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@
|
|||
|
||||
; Comments
|
||||
|
||||
[
|
||||
(comment)
|
||||
(documentation_comment)
|
||||
] @comment @spell
|
||||
(comment) @comment @spell
|
||||
|
||||
(documentation_comment) @comment.documentation @spell
|
||||
|
|
|
|||
|
|
@ -252,6 +252,14 @@
|
|||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
|
|
|
|||
|
|
@ -107,6 +107,15 @@
|
|||
(multiline_comment)
|
||||
] @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
||||
((multiline_comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
; String literals
|
||||
(line_str_text) @string
|
||||
(str_escaped_char) @string
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@
|
|||
;; Primitives
|
||||
(boolean) @boolean
|
||||
(comment) @comment @spell
|
||||
(shebang_comment) @comment
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[-][-][-]"))
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
||||
(shebang_comment) @preproc
|
||||
(identifier) @variable
|
||||
((identifier) @variable.builtin
|
||||
(#eq? @variable.builtin "self"))
|
||||
|
|
|
|||
|
|
@ -198,3 +198,11 @@
|
|||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
|
|
|||
|
|
@ -406,5 +406,8 @@
|
|||
|
||||
(ERROR) @error
|
||||
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
|
||||
(_
|
||||
(comment)+ @comment.documentation
|
||||
[(function_declaration) (type_declaration) (const_spec) (enum_declaration)])
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
; highlights.scm
|
||||
|
||||
; highlight comments and symbols
|
||||
(comment) @comment
|
||||
(comment) @comment @spell
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
(symbol) @symbol
|
||||
(member_access_expression (_) (identifier) @symbol)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
(line_comment) @comment @spell
|
||||
|
||||
[
|
||||
(container_doc_comment)
|
||||
(doc_comment)
|
||||
(line_comment)
|
||||
] @comment @spell
|
||||
] @comment.documentation @spell
|
||||
|
||||
[
|
||||
variable: (IDENTIFIER)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue