mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-08 06:20:01 -04:00
injections(lua): add vim highlights to api funcs (#5404)
Add vim injections for `vim.api.nvim[_buf]_create_user_command` and `vim.api.nvim_create_autocmd`
This commit is contained in:
parent
c617560e1b
commit
794266a4ed
1 changed files with 70 additions and 0 deletions
|
|
@ -28,6 +28,76 @@
|
|||
(#eq? @_method "nvim_exec_lua")
|
||||
(#set! injection.language "lua"))
|
||||
|
||||
; vim.api.nvim_create_autocmd("FileType", { command = "injected here" })
|
||||
(function_call
|
||||
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
|
||||
(#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd")
|
||||
(#eq? @_command "command")
|
||||
(#set! injection.language "vim"))
|
||||
|
||||
|
||||
(function_call
|
||||
name: (_) @_user_cmd
|
||||
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
|
||||
. (_)
|
||||
. (_)
|
||||
.
|
||||
(string
|
||||
content: (_) @injection.content)
|
||||
. (_) .) ; 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
|
||||
; (function_call
|
||||
; name: (_) @_map
|
||||
; arguments:
|
||||
; (arguments
|
||||
; . (_)
|
||||
; . (_)
|
||||
; .
|
||||
; (string
|
||||
; content: (_) @injection.content))
|
||||
; (#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set")
|
||||
; (#set! injection.language "vim"))
|
||||
;
|
||||
; (function_call
|
||||
; name: (_) @_map
|
||||
; arguments:
|
||||
; (arguments
|
||||
; . (_)
|
||||
; . (_)
|
||||
; . (_)
|
||||
; .
|
||||
; (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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue