mirror of
https://github.com/neovim/neovim
synced 2025-07-21 22:02:16 +00:00
build(deps): drop unused bundled bash, python parsers and queries
Problem: Neovim bundles treesitter parsers for bash and python but does not use them by default. This dilutes the messaging about the bundled parsers being required for functionality or reasonable out-of-the-box experience. It also increases the risk of query incompatibilities for no gain. Solution: Stop bundling bash and python parser and queries.
This commit is contained in:
2
BUILD.md
2
BUILD.md
@ -240,7 +240,7 @@ cmake --build build
|
|||||||
### How to build without "bundled" dependencies
|
### How to build without "bundled" dependencies
|
||||||
|
|
||||||
1. Manually install the dependencies:
|
1. Manually install the dependencies:
|
||||||
- libuv libluv libutf8proc libvterm luajit lua-lpeg lua-mpack msgpack-c tree-sitter tree-sitter-bash tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-python tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium
|
- libuv libluv libutf8proc libvterm luajit lua-lpeg lua-mpack msgpack-c tree-sitter tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium
|
||||||
2. Run CMake:
|
2. Run CMake:
|
||||||
```sh
|
```sh
|
||||||
cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
|
cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
|
@ -28,7 +28,7 @@ function(BuildTSParser)
|
|||||||
${EXTERNALPROJECT_OPTIONS})
|
${EXTERNALPROJECT_OPTIONS})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
foreach(lang c lua vim vimdoc query python bash)
|
foreach(lang c lua vim vimdoc query)
|
||||||
BuildTSParser(LANG ${lang})
|
BuildTSParser(LANG ${lang})
|
||||||
endforeach()
|
endforeach()
|
||||||
BuildTSParser(LANG markdown CMAKE_FILE MarkdownParserCMakeLists.txt)
|
BuildTSParser(LANG markdown CMAKE_FILE MarkdownParserCMakeLists.txt)
|
||||||
|
@ -54,10 +54,6 @@ TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v3.0.
|
|||||||
TREESITTER_VIMDOC_SHA256 a639bf92bf57bfa1cdc90ca16af27bfaf26a9779064776dd4be34c1ef1453f6c
|
TREESITTER_VIMDOC_SHA256 a639bf92bf57bfa1cdc90ca16af27bfaf26a9779064776dd4be34c1ef1453f6c
|
||||||
TREESITTER_QUERY_URL https://github.com/tree-sitter-grammars/tree-sitter-query/archive/v0.4.0.tar.gz
|
TREESITTER_QUERY_URL https://github.com/tree-sitter-grammars/tree-sitter-query/archive/v0.4.0.tar.gz
|
||||||
TREESITTER_QUERY_SHA256 d3a423ab66dc62b2969625e280116678a8a22582b5ff087795222108db2f6a6e
|
TREESITTER_QUERY_SHA256 d3a423ab66dc62b2969625e280116678a8a22582b5ff087795222108db2f6a6e
|
||||||
TREESITTER_PYTHON_URL https://github.com/tree-sitter/tree-sitter-python/archive/v0.21.0.tar.gz
|
|
||||||
TREESITTER_PYTHON_SHA256 720304a603271fa89e4430a14d6a81a023d6d7d1171b1533e49c0ab44f1e1c13
|
|
||||||
TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.21.0.tar.gz
|
|
||||||
TREESITTER_BASH_SHA256 f0515efda839cfede851adb24ac154227fbc0dfb60c6c11595ecfa9087d43ceb
|
|
||||||
TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.3.tar.gz
|
TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.3.tar.gz
|
||||||
TREESITTER_MARKDOWN_SHA256 4909d6023643f1afc3ab219585d4035b7403f3a17849782ab803c5f73c8a31d5
|
TREESITTER_MARKDOWN_SHA256 4909d6023643f1afc3ab219585d4035b7403f3a17849782ab803c5f73c8a31d5
|
||||||
TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.22.6.tar.gz
|
TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.22.6.tar.gz
|
||||||
|
@ -347,8 +347,8 @@ The following new features were added.
|
|||||||
|default-autocmds|
|
|default-autocmds|
|
||||||
|
|
||||||
• Treesitter:
|
• Treesitter:
|
||||||
• Bundled parsers and queries (highlight, folds) for Markdown, Python, and
|
• Bundled parser and queries (highlight, folds) for Markdown (used for LSP
|
||||||
Bash.
|
hover).
|
||||||
• |:InspectTree| shows root nodes.
|
• |:InspectTree| shows root nodes.
|
||||||
• |:InspectTree| now supports |folding|.
|
• |:InspectTree| now supports |folding|.
|
||||||
• |:InspectTree| shows node ranges in 0-based instead of 1-based indexing.
|
• |:InspectTree| shows node ranges in 0-based instead of 1-based indexing.
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
[
|
|
||||||
(function_definition)
|
|
||||||
(if_statement)
|
|
||||||
(case_statement)
|
|
||||||
(for_statement)
|
|
||||||
(while_statement)
|
|
||||||
(c_style_for_statement)
|
|
||||||
(heredoc_redirect)
|
|
||||||
] @fold
|
|
@ -1,232 +0,0 @@
|
|||||||
[
|
|
||||||
"("
|
|
||||||
")"
|
|
||||||
"{"
|
|
||||||
"}"
|
|
||||||
"["
|
|
||||||
"]"
|
|
||||||
"[["
|
|
||||||
"]]"
|
|
||||||
"(("
|
|
||||||
"))"
|
|
||||||
] @punctuation.bracket
|
|
||||||
|
|
||||||
[
|
|
||||||
";"
|
|
||||||
";;"
|
|
||||||
";&"
|
|
||||||
";;&"
|
|
||||||
"&"
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
[
|
|
||||||
">"
|
|
||||||
">>"
|
|
||||||
"<"
|
|
||||||
"<<"
|
|
||||||
"&&"
|
|
||||||
"|"
|
|
||||||
"|&"
|
|
||||||
"||"
|
|
||||||
"="
|
|
||||||
"+="
|
|
||||||
"=~"
|
|
||||||
"=="
|
|
||||||
"!="
|
|
||||||
"&>"
|
|
||||||
"&>>"
|
|
||||||
"<&"
|
|
||||||
">&"
|
|
||||||
">|"
|
|
||||||
"<&-"
|
|
||||||
">&-"
|
|
||||||
"<<-"
|
|
||||||
"<<<"
|
|
||||||
".."
|
|
||||||
"!"
|
|
||||||
] @operator
|
|
||||||
|
|
||||||
; Do *not* spell check strings since they typically have some sort of
|
|
||||||
; interpolation in them, or, are typically used for things like filenames, URLs,
|
|
||||||
; flags and file content.
|
|
||||||
[
|
|
||||||
(string)
|
|
||||||
(raw_string)
|
|
||||||
(ansi_c_string)
|
|
||||||
(heredoc_body)
|
|
||||||
] @string
|
|
||||||
|
|
||||||
[
|
|
||||||
(heredoc_start)
|
|
||||||
(heredoc_end)
|
|
||||||
] @label
|
|
||||||
|
|
||||||
(variable_assignment
|
|
||||||
(word) @string)
|
|
||||||
|
|
||||||
(command
|
|
||||||
argument: "$" @string) ; bare dollar
|
|
||||||
|
|
||||||
(concatenation
|
|
||||||
(word) @string)
|
|
||||||
|
|
||||||
[
|
|
||||||
"if"
|
|
||||||
"then"
|
|
||||||
"else"
|
|
||||||
"elif"
|
|
||||||
"fi"
|
|
||||||
"case"
|
|
||||||
"in"
|
|
||||||
"esac"
|
|
||||||
] @keyword.conditional
|
|
||||||
|
|
||||||
[
|
|
||||||
"for"
|
|
||||||
"do"
|
|
||||||
"done"
|
|
||||||
"select"
|
|
||||||
"until"
|
|
||||||
"while"
|
|
||||||
] @keyword.repeat
|
|
||||||
|
|
||||||
[
|
|
||||||
"declare"
|
|
||||||
"typeset"
|
|
||||||
"export"
|
|
||||||
"readonly"
|
|
||||||
"local"
|
|
||||||
"unset"
|
|
||||||
"unsetenv"
|
|
||||||
] @keyword
|
|
||||||
|
|
||||||
"function" @keyword.function
|
|
||||||
|
|
||||||
(special_variable_name) @constant
|
|
||||||
|
|
||||||
; trap -l
|
|
||||||
((word) @constant.builtin
|
|
||||||
(#any-of? @constant.builtin
|
|
||||||
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1"
|
|
||||||
"SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP"
|
|
||||||
"SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH"
|
|
||||||
"SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4"
|
|
||||||
"SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11"
|
|
||||||
"SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13"
|
|
||||||
"SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6"
|
|
||||||
"SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX"))
|
|
||||||
|
|
||||||
((word) @boolean
|
|
||||||
(#any-of? @boolean "true" "false"))
|
|
||||||
|
|
||||||
(comment) @comment @spell
|
|
||||||
|
|
||||||
(test_operator) @operator
|
|
||||||
|
|
||||||
(command_substitution
|
|
||||||
"$(" @punctuation.special
|
|
||||||
")" @punctuation.special)
|
|
||||||
|
|
||||||
(process_substitution
|
|
||||||
[
|
|
||||||
"<("
|
|
||||||
">("
|
|
||||||
] @punctuation.special
|
|
||||||
")" @punctuation.special)
|
|
||||||
|
|
||||||
(arithmetic_expansion
|
|
||||||
[
|
|
||||||
"$(("
|
|
||||||
"(("
|
|
||||||
] @punctuation.special
|
|
||||||
"))" @punctuation.special)
|
|
||||||
|
|
||||||
(arithmetic_expansion
|
|
||||||
"," @punctuation.delimiter)
|
|
||||||
|
|
||||||
(ternary_expression
|
|
||||||
[
|
|
||||||
"?"
|
|
||||||
":"
|
|
||||||
] @keyword.conditional.ternary)
|
|
||||||
|
|
||||||
(binary_expression
|
|
||||||
operator: _ @operator)
|
|
||||||
|
|
||||||
(unary_expression
|
|
||||||
operator: _ @operator)
|
|
||||||
|
|
||||||
(postfix_expression
|
|
||||||
operator: _ @operator)
|
|
||||||
|
|
||||||
(function_definition
|
|
||||||
name: (word) @function)
|
|
||||||
|
|
||||||
(command_name
|
|
||||||
(word) @function.call)
|
|
||||||
|
|
||||||
(command_name
|
|
||||||
(word) @function.builtin
|
|
||||||
(#any-of? @function.builtin
|
|
||||||
"alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete" "compopt"
|
|
||||||
"continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "fc" "fg" "getopts"
|
|
||||||
"hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf" "pushd" "pwd"
|
|
||||||
"read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time" "times"
|
|
||||||
"trap" "type" "typeset" "ulimit" "umask" "unalias" "wait"))
|
|
||||||
|
|
||||||
(command
|
|
||||||
argument: [
|
|
||||||
(word) @variable.parameter
|
|
||||||
(concatenation
|
|
||||||
(word) @variable.parameter)
|
|
||||||
])
|
|
||||||
|
|
||||||
(number) @number
|
|
||||||
|
|
||||||
((word) @number
|
|
||||||
(#lua-match? @number "^[0-9]+$"))
|
|
||||||
|
|
||||||
(file_redirect
|
|
||||||
destination: (word) @variable.parameter)
|
|
||||||
|
|
||||||
(file_descriptor) @operator
|
|
||||||
|
|
||||||
(simple_expansion
|
|
||||||
"$" @punctuation.special) @none
|
|
||||||
|
|
||||||
(expansion
|
|
||||||
"${" @punctuation.special
|
|
||||||
"}" @punctuation.special) @none
|
|
||||||
|
|
||||||
(expansion
|
|
||||||
operator: _ @punctuation.special)
|
|
||||||
|
|
||||||
(expansion
|
|
||||||
"@"
|
|
||||||
.
|
|
||||||
operator: _ @character.special)
|
|
||||||
|
|
||||||
((expansion
|
|
||||||
(subscript
|
|
||||||
index: (word) @character.special))
|
|
||||||
(#any-of? @character.special "@" "*"))
|
|
||||||
|
|
||||||
"``" @punctuation.special
|
|
||||||
|
|
||||||
(variable_name) @variable
|
|
||||||
|
|
||||||
((variable_name) @constant
|
|
||||||
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
|
||||||
|
|
||||||
(case_item
|
|
||||||
value: (word) @variable.parameter)
|
|
||||||
|
|
||||||
[
|
|
||||||
(regex)
|
|
||||||
(extglob_pattern)
|
|
||||||
] @string.regexp
|
|
||||||
|
|
||||||
((program
|
|
||||||
.
|
|
||||||
(comment) @keyword.directive @nospell)
|
|
||||||
(#lua-match? @keyword.directive "^#!/"))
|
|
@ -1,3 +0,0 @@
|
|||||||
(heredoc_redirect
|
|
||||||
(heredoc_body) @injection.content
|
|
||||||
(heredoc_end) @injection.language)
|
|
@ -1,28 +0,0 @@
|
|||||||
[
|
|
||||||
(function_definition)
|
|
||||||
(class_definition)
|
|
||||||
(while_statement)
|
|
||||||
(for_statement)
|
|
||||||
(if_statement)
|
|
||||||
(with_statement)
|
|
||||||
(try_statement)
|
|
||||||
(match_statement)
|
|
||||||
(import_from_statement)
|
|
||||||
(parameters)
|
|
||||||
(argument_list)
|
|
||||||
(parenthesized_expression)
|
|
||||||
(generator_expression)
|
|
||||||
(list_comprehension)
|
|
||||||
(set_comprehension)
|
|
||||||
(dictionary_comprehension)
|
|
||||||
(tuple)
|
|
||||||
(list)
|
|
||||||
(set)
|
|
||||||
(dictionary)
|
|
||||||
(string)
|
|
||||||
] @fold
|
|
||||||
|
|
||||||
[
|
|
||||||
(import_statement)
|
|
||||||
(import_from_statement)
|
|
||||||
]+ @fold
|
|
@ -1,457 +0,0 @@
|
|||||||
; From tree-sitter-python licensed under MIT License
|
|
||||||
; Copyright (c) 2016 Max Brunsfeld
|
|
||||||
; Variables
|
|
||||||
(identifier) @variable
|
|
||||||
|
|
||||||
; Reset highlighting in f-string interpolations
|
|
||||||
(interpolation) @none
|
|
||||||
|
|
||||||
; Identifier naming conventions
|
|
||||||
((identifier) @type
|
|
||||||
(#lua-match? @type "^[A-Z].*[a-z]"))
|
|
||||||
|
|
||||||
((identifier) @constant
|
|
||||||
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
|
||||||
|
|
||||||
((identifier) @constant.builtin
|
|
||||||
(#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
|
|
||||||
|
|
||||||
((identifier) @constant.builtin
|
|
||||||
(#any-of? @constant.builtin
|
|
||||||
; https://docs.python.org/3/library/constants.html
|
|
||||||
"NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license"))
|
|
||||||
|
|
||||||
"_" @constant.builtin ; match wildcard
|
|
||||||
|
|
||||||
((attribute
|
|
||||||
attribute: (identifier) @variable.member)
|
|
||||||
(#lua-match? @variable.member "^[%l_].*$"))
|
|
||||||
|
|
||||||
((assignment
|
|
||||||
left: (identifier) @type.definition
|
|
||||||
(type
|
|
||||||
(identifier) @_annotation))
|
|
||||||
(#eq? @_annotation "TypeAlias"))
|
|
||||||
|
|
||||||
((assignment
|
|
||||||
left: (identifier) @type.definition
|
|
||||||
right: (call
|
|
||||||
function: (identifier) @_func))
|
|
||||||
(#any-of? @_func "TypeVar" "NewType"))
|
|
||||||
|
|
||||||
; Function calls
|
|
||||||
(call
|
|
||||||
function: (identifier) @function.call)
|
|
||||||
|
|
||||||
(call
|
|
||||||
function: (attribute
|
|
||||||
attribute: (identifier) @function.method.call))
|
|
||||||
|
|
||||||
((call
|
|
||||||
function: (identifier) @constructor)
|
|
||||||
(#lua-match? @constructor "^%u"))
|
|
||||||
|
|
||||||
((call
|
|
||||||
function: (attribute
|
|
||||||
attribute: (identifier) @constructor))
|
|
||||||
(#lua-match? @constructor "^%u"))
|
|
||||||
|
|
||||||
; Decorators
|
|
||||||
((decorator
|
|
||||||
"@" @attribute)
|
|
||||||
(#set! "priority" 101))
|
|
||||||
|
|
||||||
(decorator
|
|
||||||
(identifier) @attribute)
|
|
||||||
|
|
||||||
(decorator
|
|
||||||
(attribute
|
|
||||||
attribute: (identifier) @attribute))
|
|
||||||
|
|
||||||
(decorator
|
|
||||||
(call
|
|
||||||
(identifier) @attribute))
|
|
||||||
|
|
||||||
(decorator
|
|
||||||
(call
|
|
||||||
(attribute
|
|
||||||
attribute: (identifier) @attribute)))
|
|
||||||
|
|
||||||
((decorator
|
|
||||||
(identifier) @attribute.builtin)
|
|
||||||
(#any-of? @attribute.builtin "classmethod" "property" "staticmethod"))
|
|
||||||
|
|
||||||
; Builtin functions
|
|
||||||
((call
|
|
||||||
function: (identifier) @function.builtin)
|
|
||||||
(#any-of? @function.builtin
|
|
||||||
"abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr"
|
|
||||||
"classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec"
|
|
||||||
"filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id"
|
|
||||||
"input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview"
|
|
||||||
"min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed"
|
|
||||||
"round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type"
|
|
||||||
"vars" "zip" "__import__"))
|
|
||||||
|
|
||||||
; Function definitions
|
|
||||||
(function_definition
|
|
||||||
name: (identifier) @function)
|
|
||||||
|
|
||||||
(type
|
|
||||||
(identifier) @type)
|
|
||||||
|
|
||||||
(type
|
|
||||||
(subscript
|
|
||||||
(identifier) @type)) ; type subscript: Tuple[int]
|
|
||||||
|
|
||||||
((call
|
|
||||||
function: (identifier) @_isinstance
|
|
||||||
arguments: (argument_list
|
|
||||||
(_)
|
|
||||||
(identifier) @type))
|
|
||||||
(#eq? @_isinstance "isinstance"))
|
|
||||||
|
|
||||||
; Normal parameters
|
|
||||||
(parameters
|
|
||||||
(identifier) @variable.parameter)
|
|
||||||
|
|
||||||
; Lambda parameters
|
|
||||||
(lambda_parameters
|
|
||||||
(identifier) @variable.parameter)
|
|
||||||
|
|
||||||
(lambda_parameters
|
|
||||||
(tuple_pattern
|
|
||||||
(identifier) @variable.parameter))
|
|
||||||
|
|
||||||
; Default parameters
|
|
||||||
(keyword_argument
|
|
||||||
name: (identifier) @variable.parameter)
|
|
||||||
|
|
||||||
; Naming parameters on call-site
|
|
||||||
(default_parameter
|
|
||||||
name: (identifier) @variable.parameter)
|
|
||||||
|
|
||||||
(typed_parameter
|
|
||||||
(identifier) @variable.parameter)
|
|
||||||
|
|
||||||
(typed_default_parameter
|
|
||||||
name: (identifier) @variable.parameter)
|
|
||||||
|
|
||||||
; Variadic parameters *args, **kwargs
|
|
||||||
(parameters
|
|
||||||
(list_splat_pattern ; *args
|
|
||||||
(identifier) @variable.parameter))
|
|
||||||
|
|
||||||
(parameters
|
|
||||||
(dictionary_splat_pattern ; **kwargs
|
|
||||||
(identifier) @variable.parameter))
|
|
||||||
|
|
||||||
; Typed variadic parameters
|
|
||||||
(parameters
|
|
||||||
(typed_parameter
|
|
||||||
(list_splat_pattern ; *args: type
|
|
||||||
(identifier) @variable.parameter)))
|
|
||||||
|
|
||||||
(parameters
|
|
||||||
(typed_parameter
|
|
||||||
(dictionary_splat_pattern ; *kwargs: type
|
|
||||||
(identifier) @variable.parameter)))
|
|
||||||
|
|
||||||
; Lambda parameters
|
|
||||||
(lambda_parameters
|
|
||||||
(list_splat_pattern
|
|
||||||
(identifier) @variable.parameter))
|
|
||||||
|
|
||||||
(lambda_parameters
|
|
||||||
(dictionary_splat_pattern
|
|
||||||
(identifier) @variable.parameter))
|
|
||||||
|
|
||||||
; Literals
|
|
||||||
(none) @constant.builtin
|
|
||||||
|
|
||||||
[
|
|
||||||
(true)
|
|
||||||
(false)
|
|
||||||
] @boolean
|
|
||||||
|
|
||||||
((identifier) @variable.builtin
|
|
||||||
(#eq? @variable.builtin "self"))
|
|
||||||
|
|
||||||
((identifier) @variable.builtin
|
|
||||||
(#eq? @variable.builtin "cls"))
|
|
||||||
|
|
||||||
(integer) @number
|
|
||||||
|
|
||||||
(float) @number.float
|
|
||||||
|
|
||||||
(comment) @comment @spell
|
|
||||||
|
|
||||||
((module
|
|
||||||
.
|
|
||||||
(comment) @keyword.directive @nospell)
|
|
||||||
(#lua-match? @keyword.directive "^#!/"))
|
|
||||||
|
|
||||||
(string) @string
|
|
||||||
|
|
||||||
[
|
|
||||||
(escape_sequence)
|
|
||||||
(escape_interpolation)
|
|
||||||
] @string.escape
|
|
||||||
|
|
||||||
; doc-strings
|
|
||||||
(module
|
|
||||||
.
|
|
||||||
(comment)*
|
|
||||||
.
|
|
||||||
(expression_statement
|
|
||||||
(string) @string.documentation))
|
|
||||||
|
|
||||||
(class_definition
|
|
||||||
body: (block
|
|
||||||
.
|
|
||||||
(expression_statement
|
|
||||||
(string) @string.documentation)))
|
|
||||||
|
|
||||||
(function_definition
|
|
||||||
body: (block
|
|
||||||
.
|
|
||||||
(expression_statement
|
|
||||||
(string) @string.documentation)))
|
|
||||||
|
|
||||||
(module
|
|
||||||
.
|
|
||||||
(comment)*
|
|
||||||
.
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_content) @spell)))
|
|
||||||
|
|
||||||
(class_definition
|
|
||||||
body: (block
|
|
||||||
.
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_content) @spell))))
|
|
||||||
|
|
||||||
(function_definition
|
|
||||||
body: (block
|
|
||||||
.
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_content) @spell))))
|
|
||||||
|
|
||||||
; Tokens
|
|
||||||
[
|
|
||||||
"-"
|
|
||||||
"-="
|
|
||||||
":="
|
|
||||||
"!="
|
|
||||||
"*"
|
|
||||||
"**"
|
|
||||||
"**="
|
|
||||||
"*="
|
|
||||||
"/"
|
|
||||||
"//"
|
|
||||||
"//="
|
|
||||||
"/="
|
|
||||||
"&"
|
|
||||||
"&="
|
|
||||||
"%"
|
|
||||||
"%="
|
|
||||||
"^"
|
|
||||||
"^="
|
|
||||||
"+"
|
|
||||||
"+="
|
|
||||||
"<"
|
|
||||||
"<<"
|
|
||||||
"<<="
|
|
||||||
"<="
|
|
||||||
"<>"
|
|
||||||
"="
|
|
||||||
"=="
|
|
||||||
">"
|
|
||||||
">="
|
|
||||||
">>"
|
|
||||||
">>="
|
|
||||||
"@"
|
|
||||||
"@="
|
|
||||||
"|"
|
|
||||||
"|="
|
|
||||||
"~"
|
|
||||||
"->"
|
|
||||||
] @operator
|
|
||||||
|
|
||||||
; Keywords
|
|
||||||
[
|
|
||||||
"and"
|
|
||||||
"in"
|
|
||||||
"is"
|
|
||||||
"not"
|
|
||||||
"or"
|
|
||||||
"is not"
|
|
||||||
"not in"
|
|
||||||
"del"
|
|
||||||
] @keyword.operator
|
|
||||||
|
|
||||||
[
|
|
||||||
"def"
|
|
||||||
"lambda"
|
|
||||||
] @keyword.function
|
|
||||||
|
|
||||||
[
|
|
||||||
"assert"
|
|
||||||
"exec"
|
|
||||||
"global"
|
|
||||||
"nonlocal"
|
|
||||||
"pass"
|
|
||||||
"print"
|
|
||||||
"with"
|
|
||||||
"as"
|
|
||||||
] @keyword
|
|
||||||
|
|
||||||
[
|
|
||||||
"type"
|
|
||||||
"class"
|
|
||||||
] @keyword.type
|
|
||||||
|
|
||||||
[
|
|
||||||
"async"
|
|
||||||
"await"
|
|
||||||
] @keyword.coroutine
|
|
||||||
|
|
||||||
[
|
|
||||||
"return"
|
|
||||||
"yield"
|
|
||||||
] @keyword.return
|
|
||||||
|
|
||||||
(yield
|
|
||||||
"from" @keyword.return)
|
|
||||||
|
|
||||||
(future_import_statement
|
|
||||||
"from" @keyword.import
|
|
||||||
"__future__" @constant.builtin)
|
|
||||||
|
|
||||||
(import_from_statement
|
|
||||||
"from" @keyword.import)
|
|
||||||
|
|
||||||
"import" @keyword.import
|
|
||||||
|
|
||||||
(aliased_import
|
|
||||||
"as" @keyword.import)
|
|
||||||
|
|
||||||
[
|
|
||||||
"if"
|
|
||||||
"elif"
|
|
||||||
"else"
|
|
||||||
"match"
|
|
||||||
"case"
|
|
||||||
] @keyword.conditional
|
|
||||||
|
|
||||||
[
|
|
||||||
"for"
|
|
||||||
"while"
|
|
||||||
"break"
|
|
||||||
"continue"
|
|
||||||
] @keyword.repeat
|
|
||||||
|
|
||||||
[
|
|
||||||
"try"
|
|
||||||
"except"
|
|
||||||
"except*"
|
|
||||||
"raise"
|
|
||||||
"finally"
|
|
||||||
] @keyword.exception
|
|
||||||
|
|
||||||
(raise_statement
|
|
||||||
"from" @keyword.exception)
|
|
||||||
|
|
||||||
(try_statement
|
|
||||||
(else_clause
|
|
||||||
"else" @keyword.exception))
|
|
||||||
|
|
||||||
[
|
|
||||||
"("
|
|
||||||
")"
|
|
||||||
"["
|
|
||||||
"]"
|
|
||||||
"{"
|
|
||||||
"}"
|
|
||||||
] @punctuation.bracket
|
|
||||||
|
|
||||||
(interpolation
|
|
||||||
"{" @punctuation.special
|
|
||||||
"}" @punctuation.special)
|
|
||||||
|
|
||||||
(type_conversion) @function.macro
|
|
||||||
|
|
||||||
[
|
|
||||||
","
|
|
||||||
"."
|
|
||||||
":"
|
|
||||||
";"
|
|
||||||
(ellipsis)
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
; Class definitions
|
|
||||||
(class_definition
|
|
||||||
name: (identifier) @type)
|
|
||||||
|
|
||||||
(class_definition
|
|
||||||
body: (block
|
|
||||||
(function_definition
|
|
||||||
name: (identifier) @function.method)))
|
|
||||||
|
|
||||||
(class_definition
|
|
||||||
superclasses: (argument_list
|
|
||||||
(identifier) @type))
|
|
||||||
|
|
||||||
((class_definition
|
|
||||||
body: (block
|
|
||||||
(expression_statement
|
|
||||||
(assignment
|
|
||||||
left: (identifier) @variable.member))))
|
|
||||||
(#lua-match? @variable.member "^[%l_].*$"))
|
|
||||||
|
|
||||||
((class_definition
|
|
||||||
body: (block
|
|
||||||
(expression_statement
|
|
||||||
(assignment
|
|
||||||
left: (_
|
|
||||||
(identifier) @variable.member)))))
|
|
||||||
(#lua-match? @variable.member "^[%l_].*$"))
|
|
||||||
|
|
||||||
((class_definition
|
|
||||||
(block
|
|
||||||
(function_definition
|
|
||||||
name: (identifier) @constructor)))
|
|
||||||
(#any-of? @constructor "__new__" "__init__"))
|
|
||||||
|
|
||||||
((identifier) @type.builtin
|
|
||||||
(#any-of? @type.builtin
|
|
||||||
; https://docs.python.org/3/library/exceptions.html
|
|
||||||
"BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError"
|
|
||||||
"AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError"
|
|
||||||
"ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError"
|
|
||||||
"NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError"
|
|
||||||
"StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError"
|
|
||||||
"SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError"
|
|
||||||
"UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError"
|
|
||||||
"IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError"
|
|
||||||
"BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError"
|
|
||||||
"FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError"
|
|
||||||
"NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
|
|
||||||
"UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
|
|
||||||
"FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
|
|
||||||
; https://docs.python.org/3/library/stdtypes.html
|
|
||||||
"bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview"
|
|
||||||
"set" "frozenset" "dict" "type" "object"))
|
|
||||||
|
|
||||||
; Regex from the `re` module
|
|
||||||
(call
|
|
||||||
function: (attribute
|
|
||||||
object: (identifier) @_re)
|
|
||||||
arguments: (argument_list
|
|
||||||
.
|
|
||||||
(string
|
|
||||||
(string_content) @string.regexp))
|
|
||||||
(#eq? @_re "re"))
|
|
@ -408,15 +408,15 @@ t3]])
|
|||||||
|
|
||||||
it('handles quantified patterns', function()
|
it('handles quantified patterns', function()
|
||||||
insert([[
|
insert([[
|
||||||
import hello
|
-- hello
|
||||||
import hello
|
-- hello
|
||||||
import hello
|
-- hello
|
||||||
import hello
|
-- hello
|
||||||
import hello
|
-- hello
|
||||||
import hello]])
|
-- hello]])
|
||||||
|
|
||||||
exec_lua([[vim.treesitter.query.set('python', 'folds', '(import_statement)+ @fold')]])
|
exec_lua([[vim.treesitter.query.set('lua', 'folds', '(comment)+ @fold')]])
|
||||||
parse('python')
|
parse('lua')
|
||||||
|
|
||||||
eq({
|
eq({
|
||||||
[1] = '>1',
|
[1] = '>1',
|
||||||
|
Reference in New Issue
Block a user