mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -1,29 +1,48 @@
|
|||
((function_call
|
||||
name: [
|
||||
(identifier) @_cdef_identifier
|
||||
(_ _ (identifier) @_cdef_identifier)
|
||||
]
|
||||
arguments:
|
||||
(arguments
|
||||
(string content: _ @injection.content)))
|
||||
name:
|
||||
[
|
||||
(identifier) @_cdef_identifier
|
||||
(_
|
||||
_
|
||||
(identifier) @_cdef_identifier)
|
||||
]
|
||||
arguments:
|
||||
(arguments
|
||||
(string
|
||||
content: _ @injection.content)))
|
||||
(#set! injection.language "c")
|
||||
(#eq? @_cdef_identifier "cdef"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments (string content: _ @injection.content)))
|
||||
arguments:
|
||||
(arguments
|
||||
(string
|
||||
content: _ @injection.content)))
|
||||
(#set! injection.language "vim")
|
||||
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments (string content: _ @injection.content) .))
|
||||
arguments:
|
||||
(arguments
|
||||
(string
|
||||
content: _ @injection.content) .))
|
||||
(#set! injection.language "query")
|
||||
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @injection.content)))
|
||||
arguments:
|
||||
(arguments
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(string
|
||||
content: _ @_method)
|
||||
.
|
||||
(string
|
||||
content: _ @injection.content)))
|
||||
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
|
||||
(#eq? @_method "nvim_exec_lua")
|
||||
(#set! injection.language "lua"))
|
||||
|
|
@ -33,46 +52,52 @@
|
|||
name: (_) @_vimcmd_identifier
|
||||
arguments:
|
||||
(arguments
|
||||
. (_)
|
||||
.
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(table_constructor
|
||||
(field
|
||||
name: (identifier) @_command
|
||||
value:
|
||||
(string content: (_) @injection.content)))
|
||||
.) ; limit so only 2-argument functions gets matched before pred handle
|
||||
value:
|
||||
(string
|
||||
content: (_) @injection.content))) .)
|
||||
; limit so only 2-argument functions gets matched before pred handle
|
||||
(#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd")
|
||||
(#eq? @_command "command")
|
||||
(#set! injection.language "vim"))
|
||||
|
||||
|
||||
(function_call
|
||||
name: (_) @_user_cmd
|
||||
arguments:
|
||||
arguments:
|
||||
(arguments
|
||||
. (_)
|
||||
.
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(string
|
||||
content: (_) @injection.content)
|
||||
. (_) .)
|
||||
.
|
||||
(_) .)
|
||||
(#eq? @_user_cmd "vim.api.nvim_create_user_command")
|
||||
(#set! injection.language "vim"))
|
||||
|
||||
(function_call
|
||||
name: (_) @_user_cmd
|
||||
arguments:
|
||||
arguments:
|
||||
(arguments
|
||||
. (_)
|
||||
. (_)
|
||||
.
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(string
|
||||
content: (_) @injection.content)
|
||||
. (_)
|
||||
.) ; Limiting predicate handling to only functions with 4 arguments
|
||||
.
|
||||
(_) .)
|
||||
; Limiting predicate handling to only functions with 4 arguments
|
||||
(#eq? @_user_cmd "vim.api.nvim_buf_create_user_command")
|
||||
(#set! injection.language "vim"))
|
||||
|
||||
;; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap
|
||||
; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap
|
||||
; (function_call
|
||||
; name: (_) @_map
|
||||
; arguments:
|
||||
|
|
@ -92,17 +117,17 @@
|
|||
; . (_)
|
||||
; . (_)
|
||||
; . (_)
|
||||
; .
|
||||
; .
|
||||
; (string
|
||||
; content: (_) @injection.content)
|
||||
; . (_) .)
|
||||
; (#eq? @_map "vim.api.nvim_buf_set_keymap")
|
||||
; (#set! injection.language "vim"))
|
||||
|
||||
;; highlight string as query if starts with `;; query`
|
||||
(string content: _ @injection.content
|
||||
(#lua-match? @injection.content "^%s*;+%s?query")
|
||||
(#set! injection.language "query"))
|
||||
; highlight string as query if starts with `;; query`
|
||||
(string
|
||||
content: _ @injection.content
|
||||
(#lua-match? @injection.content "^%s*;+%s?query")
|
||||
(#set! injection.language "query"))
|
||||
|
||||
(comment
|
||||
content: (_) @injection.content
|
||||
|
|
@ -111,48 +136,56 @@
|
|||
(#offset! @injection.content 0 1 0 0))
|
||||
|
||||
; string.match("123", "%d+")
|
||||
|
||||
(function_call
|
||||
(dot_index_expression
|
||||
field: (identifier) @_method
|
||||
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||
arguments: (arguments
|
||||
. (_)
|
||||
.
|
||||
(string
|
||||
content: (string_content) @injection.content
|
||||
(#set! injection.language "luap")
|
||||
(#set! injection.include-children))))
|
||||
arguments:
|
||||
(arguments
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(string
|
||||
content: (string_content) @injection.content
|
||||
(#set! injection.language "luap")
|
||||
(#set! injection.include-children))))
|
||||
|
||||
;("123"):match("%d+")
|
||||
|
||||
(function_call
|
||||
(method_index_expression
|
||||
method: (identifier) @_method
|
||||
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||
arguments: (arguments
|
||||
. (string
|
||||
content: (string_content) @injection.content
|
||||
(#set! injection.language "luap")
|
||||
(#set! injection.include-children))))
|
||||
arguments:
|
||||
(arguments
|
||||
.
|
||||
(string
|
||||
content: (string_content) @injection.content
|
||||
(#set! injection.language "luap")
|
||||
(#set! injection.include-children))))
|
||||
|
||||
; string.format("pi = %.2f", 3.14159)
|
||||
((function_call
|
||||
(dot_index_expression
|
||||
field: (identifier) @_method)
|
||||
arguments: (arguments
|
||||
. (string (string_content) @injection.content)))
|
||||
(#eq? @_method "format")
|
||||
(#set! injection.language "printf"))
|
||||
arguments:
|
||||
(arguments
|
||||
.
|
||||
(string
|
||||
(string_content) @injection.content)))
|
||||
(#eq? @_method "format")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
; ("pi = %.2f"):format(3.14159)
|
||||
((function_call
|
||||
(method_index_expression
|
||||
table: (_ (string (string_content) @injection.content))
|
||||
table:
|
||||
(_
|
||||
(string
|
||||
(string_content) @injection.content))
|
||||
method: (identifier) @_method))
|
||||
(#eq? @_method "format")
|
||||
(#set! injection.language "printf"))
|
||||
(#eq? @_method "format")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
(comment
|
||||
content: (_) @injection.content
|
||||
content: (_) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue