1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 09:30:04 +08:00
SpaceVim/bundle/nvim-treesitter/queries/lua/injections.scm

60 lines
1.9 KiB
Scheme

((function_call
name: [
(identifier) @_cdef_identifier
(_ _ (identifier) @_cdef_identifier)
]
arguments: (arguments (string content: _ @c)))
(#eq? @_cdef_identifier "cdef"))
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments . (string content: _ @vim)))
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_exec2"))
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments (string content: _ @query) .))
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse_query" "vim.treesitter.query.parse"))
; vim.rcprequest(123, "nvim_exec_lua", "return vim.api.nvim_buf_get_lines(0, 0, -1, false)", false)
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @lua)))
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
(#eq? @_method "nvim_exec_lua"))
; highlight string as query if starts with `;; query`
(string content: _ @query (#lua-match? @query "^%s*;+%s?query"))
((comment) @luadoc
(#lua-match? @luadoc "[-][-][-][%s]*@")
(#offset! @luadoc 0 3 0 0))
; string.match("123", "%d+")
(function_call
(dot_index_expression
field: (identifier) @_method
(#any-of? @_method "find" "match"))
arguments: (arguments (_) . (string content: _ @luap)))
(function_call
(dot_index_expression
field: (identifier) @_method
(#any-of? @_method "gmatch" "gsub"))
arguments: (arguments (_) (string content: _ @luap)))
; ("123"):match("%d+")
(function_call
(method_index_expression
method: (identifier) @_method
(#any-of? @_method "find" "match"))
arguments: (arguments . (string content: _ @luap)))
(function_call
(method_index_expression
method: (identifier) @_method
(#any-of? @_method "gmatch" "gsub"))
arguments: (arguments (string content: _ @luap)))
(comment) @comment