| Crates.io | tree-sitter-vim-map-side |
| lib.rs | tree-sitter-vim-map-side |
| version | 0.1.3 |
| created_at | 2025-10-28 23:44:59.293081+00 |
| updated_at | 2025-10-28 23:44:59.293081+00 |
| description | Vim's map side (lhs and rhs) grammar for tree-sitter |
| homepage | |
| repository | https://github.com/hdoc1509/tree-sitter-vim-map-side |
| max_upload_size | |
| id | 1905774 |
| size | 101,564 |
Vim's map side (lhs and rhs)
grammar for tree-sitter.
Primaryly intended to be used within lua, but also supports vim mappings
with rhs that starts with : (not supported at the moment).
[!IMPORTANT] ABI version:
15
rhs expressionsprintf()variable-scope: g:, l:, v:[!NOTE] More expressions will be supported in the future if requested.
lua: injection to lsh and rhs of keymap
functions of neovimprintf (optional): injection to first argument of printf()
expression.vim (optional): injection to rhs when it starts with : and to
command nodes of this grammar.Neovim configuration.WIP
WIP
[!NOTE] If you are using Neovim, you can use
lua-match?andnot-lua-match?predicates instead ofmatch?andnot-match?. Be sure to use%sinstead of\sand%Sinstead of\Sin the regexes.
lua parserFor vim.keymap.set(), vim.api.nvim_set_keymap() and
vim.api.nvim_buf_set_keymap() functions of neovim:
; NOTE: for lhs and rhs
(function_call
name: (_) @_fn
arguments: [
; format-ignore
(arguments
. (_) ; -- mode --
.
(string
(string_content) @injection.content))
; format-ignore
(arguments
. (_) ; -- mode --
. (_) ; -- lhs --
(string
(string_content) @injection.content))
]
(#any-of? @_fn "vim.keymap.set" "vim.api.nvim_set_keymap")
(#match? @injection.content "<\S+>")
(#set! injection.language "vim_map_side"))
(function_call
name: (_) @_fn
arguments: [
; format-ignore
(arguments
. (_) ; -- buffer --
. (_) ; -- mode --
.
(string
(string_content) @injeciton.content))
; format-ignore
(arguments
. (_) ; -- buffer --
. (_) ; -- mode --
. (_) ; -- lhs --
.
(string
(string_content) @injeciton.content))
]
(#eq? @_fn "vim.api.nvim_buf_set_keymap")
(#match? @injeciton.content "<\S+>")
(#set! injection.language "vim_map_side"))
; NOTE: for expressions as rhs
(function_call
name: (_) @_fn
; format-ignore
arguments: (arguments
. (_) ; -- mode --
. (_) ; -- lhs --
.
(string
(string_content) @injection.content)
.
(table_constructor) @_options)
(#any-of? @_fn "vim.keymap.set" "vim.api.nvim_set_keymap")
; NOTE: to avoid double injection
(#not-match? @injection.content "<\S+>")
(#match? @_options "expr\s*=\s*true")
(#set! injection.language "vim_map_side"))
(function_call
name: (_) @_fn
; format-ignore
arguments: (arguments
. (_) ; -- buffer --
. (_) ; -- mode --
. (_) ; -- lhs --
.
(string
(string_content) @injection.content)
.
(table_constructor) @_options)
(#eq? @_fn "vim.api.nvim_buf_set_keymap")
; NOTE: to avoid double injection
(#not-match? @injection.content "<\S+>")
(#match? @_options "expr\s*=\s*true")
(#set! injection.language "vim_map_side"))
vim parser(map_statement
rhs: (map_side) @injection.content
(#match? @injection.content "^:")
(#set! injection.include-children)
(#set! injection.language "vim_map_side"))