Update tree-sitter-lua and add textobjects for Lua (#3552)

pull/4227/head
Lennard Hofmann 2 years ago committed by GitHub
parent 68909dcef4
commit a24fae3b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,7 +66,7 @@
| llvm | ✓ | ✓ | ✓ | | | llvm | ✓ | ✓ | ✓ | |
| llvm-mir | ✓ | ✓ | ✓ | | | llvm-mir | ✓ | ✓ | ✓ | |
| llvm-mir-yaml | ✓ | | ✓ | | | llvm-mir-yaml | ✓ | | ✓ | |
| lua | ✓ | | ✓ | `lua-language-server` | | lua | ✓ | | ✓ | `lua-language-server` |
| make | ✓ | | | | | make | ✓ | | | |
| markdown | ✓ | | | `marksman` | | markdown | ✓ | | | `marksman` |
| markdown.inline | ✓ | | | | | markdown.inline | ✓ | | | |

@ -667,7 +667,7 @@ language-server = { command = "lua-language-server", args = [] }
[[grammar]] [[grammar]]
name = "lua" name = "lua"
source = { git = "https://github.com/nvim-treesitter/tree-sitter-lua", rev = "6f5d40190ec8a0aa8c8410699353d820f4f7d7a6" } source = { git = "https://github.com/MunifTanjim/tree-sitter-lua", rev = "887dfd4e83c469300c279314ff1619b1d0b85b91" }
[[language]] [[language]]
name = "svelte" name = "svelte"

@ -0,0 +1,10 @@
[
(do_statement)
(while_statement)
(repeat_statement)
(if_statement)
(for_statement)
(function_declaration)
(function_definition)
(table_constructor)
] @fold

@ -1,7 +1,8 @@
;;; Highlighting for lua ;;; Highlighting for lua
;;; Builtins ;;; Builtins
(self) @variable.builtin ((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
;; Keywords ;; Keywords
@ -12,20 +13,20 @@
"end" "end"
] @keyword.control.conditional) ] @keyword.control.conditional)
(elseif_statement
[ [
"else"
"elseif" "elseif"
"then" "then"
] @keyword.control.conditional "end"
] @keyword.control.conditional)
(for_statement (else_statement
[ [
"for" "else"
"do"
"end" "end"
] @keyword.control.repeat) ] @keyword.control.conditional)
(for_in_statement (for_statement
[ [
"for" "for"
"do" "do"
@ -51,21 +52,34 @@
"end" "end"
] @keyword) ] @keyword)
"return" @keyword.control.return
[ [
"in" "in"
"local" "local"
(break_statement) (break_statement)
"goto" "goto"
"return"
] @keyword ] @keyword
(function_declaration
[
"function"
"end"
] @keyword.function)
(function_definition
[
"function"
"end"
] @keyword.function)
;; Operators ;; Operators
[ [
"not" "not"
"and" "and"
"or" "or"
] @operator ] @keyword.operator
[ [
"=" "="
@ -95,6 +109,7 @@
["," "." ":" ";"] @punctuation.delimiter ["," "." ":" ";"] @punctuation.delimiter
;; Brackets ;; Brackets
[ [
"(" "("
")" ")"
@ -110,7 +125,8 @@
(true) (true)
] @constant.builtin.boolean ] @constant.builtin.boolean
(nil) @constant.builtin (nil) @constant.builtin
(spread) @constant ;; "..." (vararg_expression) @constant
((identifier) @constant ((identifier) @constant
(#match? @constant "^[A-Z][A-Z_0-9]*$")) (#match? @constant "^[A-Z][A-Z_0-9]*$"))
@ -119,45 +135,32 @@
(identifier) @variable.parameter) (identifier) @variable.parameter)
; ;; Functions ; ;; Functions
(function [(function_name) (identifier)] @function) (function_declaration name: (identifier) @function)
(function ["function" "end"] @keyword.function) (function_call name: (identifier) @function.call)
(function
(function_name
(function_name_field
(property_identifier) @function .)))
(local_function (identifier) @function)
(local_function ["function" "end"] @keyword.function)
(variable_declaration (function_declaration name: (dot_index_expression field: (identifier) @function))
(variable_declarator (identifier) @function) (function_definition)) (function_call name: (dot_index_expression field: (identifier) @function.call))
(local_variable_declaration
(variable_declarator (identifier) @function) (function_definition))
(function_definition ["function" "end"] @keyword.function) ; TODO: incorrectly highlights variable N in `N, nop = 42, function() end`
(assignment_statement
(variable_list
name: (identifier) @function)
(expression_list
value: (function_definition)))
(function_call (method_index_expression method: (identifier) @function.method)
[
((identifier) @variable (method) @function.method)
((_) (method) @function.method)
(identifier) @function
(field_expression (property_identifier) @function)
]
. (arguments))
;; Nodes ;; Nodes
(table ["{" "}"] @constructor)
(comment) @comment (comment) @comment
(string) @string (string) @string
(number) @constant.numeric.integer (number) @constant.numeric.integer
(label_statement) @label (label_statement) @label
; A bit of a tricky one, this will only match field names ; A bit of a tricky one, this will only match field names
(field . (identifier) @variable.other.member (_)) (field . (identifier) @variable.other.member (_))
(shebang) @comment (hash_bang_line) @comment
;; Property ;; Property
(property_identifier) @variable.other.member (dot_index_expression field: (identifier) @variable.other.member)
;; Variable ;; Variable
(identifier) @variable (identifier) @variable

@ -1,17 +1,13 @@
[ [
(function_definition) (function_definition)
(variable_declaration) (function_declaration)
(local_variable_declaration) (method_index_expression)
(field) (field)
(local_function)
(function)
(if_statement) (if_statement)
(for_statement) (for_statement)
(for_in_statement)
(repeat_statement) (repeat_statement)
(return_statement)
(while_statement) (while_statement)
(table) (table_constructor)
(arguments) (arguments)
(do_statement) (do_statement)
] @indent ] @indent

@ -1,2 +1,3 @@
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment")
(#set! injection.include-children))

@ -0,0 +1,15 @@
(function_definition
body: (_) @function.inside) @function.around
(function_declaration
body: (_) @function.inside) @function.around
(parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)
(arguments
((_) @parameter.inside . ","? @parameter.around) @parameter.around)
(comment) @comment.inside
(comment)+ @comment.around
Loading…
Cancel
Save