mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
feat(treesitter): use upstream format for injection queries
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
(preproc_arg) @c
|
||||
((preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
|
||||
; (comment) @comment
|
||||
; ((comment) @injection.content
|
||||
; (#set! injection.language "comment"))
|
||||
|
@ -1,3 +1,4 @@
|
||||
(codeblock
|
||||
(language) @language
|
||||
(code) @content)
|
||||
((codeblock
|
||||
(language) @injection.language
|
||||
(code) @injection.content)
|
||||
(#set! injection.include-children))
|
||||
|
@ -3,20 +3,26 @@
|
||||
(identifier) @_cdef_identifier
|
||||
(_ _ (identifier) @_cdef_identifier)
|
||||
]
|
||||
arguments: (arguments (string content: _ @c)))
|
||||
arguments: (arguments (string content: _ @injection.content)))
|
||||
(#set! injection.language "c")
|
||||
(#eq? @_cdef_identifier "cdef"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments (string content: _ @vim)))
|
||||
arguments: (arguments (string content: _ @injection.content)))
|
||||
(#set! injection.language "vim")
|
||||
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_cmd"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments (string content: _ @query) .))
|
||||
arguments: (arguments (string content: _ @injection.content) .))
|
||||
(#set! injection.language "query")
|
||||
(#eq? @_vimcmd_identifier "vim.treesitter.query.set_query"))
|
||||
|
||||
; ;; highlight string as query if starts with `;; query`
|
||||
; ((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?query"))
|
||||
; ((string ("string_content") @injection.content)
|
||||
; (#set! injection.language "query")
|
||||
; (#lua-match? @injection.content "^%s*;+%s?query"))
|
||||
|
||||
; (comment) @comment
|
||||
; ((comment) @injection.content
|
||||
; (#set! injection.language "comment"))
|
||||
|
@ -1,18 +1,33 @@
|
||||
(lua_statement (script (body) @lua))
|
||||
(lua_statement (chunk) @lua)
|
||||
(ruby_statement (script (body) @ruby))
|
||||
(ruby_statement (chunk) @ruby)
|
||||
(python_statement (script (body) @python))
|
||||
(python_statement (chunk) @python)
|
||||
;; If we support perl at some point...
|
||||
;; (perl_statement (script (body) @perl))
|
||||
;; (perl_statement (chunk) @perl)
|
||||
((lua_statement (script (body) @injection.content))
|
||||
(#set! injection.language "lua"))
|
||||
|
||||
(autocmd_statement (pattern) @regex)
|
||||
((lua_statement (chunk) @injection.content)
|
||||
(#set! injection.language "lua"))
|
||||
|
||||
((ruby_statement (script (body) @injection.content))
|
||||
(#set! injection.language "ruby"))
|
||||
|
||||
((ruby_statement (chunk) @injection.content)
|
||||
(#set! injection.language "ruby"))
|
||||
|
||||
((python_statement (script (body) @injection.content))
|
||||
(#set! injection.language "python"))
|
||||
|
||||
((python_statement (chunk) @injection.content)
|
||||
(#set! injection.language "python"))
|
||||
|
||||
;; If we support perl at some point...
|
||||
;; ((perl_statement (script (body) @injection.content))
|
||||
;; (#set! injection.language "perl"))
|
||||
;; ((perl_statement (chunk) @injection.content)
|
||||
;; (#set! injection.language "perl"))
|
||||
|
||||
((autocmd_statement (pattern) @injection.content)
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
((set_item
|
||||
option: (option_name) @_option
|
||||
value: (set_value) @vim)
|
||||
value: (set_value) @injection.content)
|
||||
(#any-of? @_option
|
||||
"includeexpr" "inex"
|
||||
"printexpr" "pexpr"
|
||||
@ -22,7 +37,12 @@
|
||||
"foldexpr" "fde"
|
||||
"diffexpr" "dex"
|
||||
"patchexpr" "pex"
|
||||
"charconvert" "ccv"))
|
||||
"charconvert" "ccv")
|
||||
(#set! injection.language "vim"))
|
||||
|
||||
; (comment) @comment
|
||||
; (line_continuation_comment) @comment
|
||||
|
||||
; ((comment) @injection.content
|
||||
; (#set! injection.language "comment"))
|
||||
|
||||
; ((line_continuation_comment) @injection.content
|
||||
; (#set! injection.language "comment"))
|
||||
|
Reference in New Issue
Block a user