diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-12-31 20:10:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-31 20:10:35 +0100 |
commit | b218d02c442ebacba1fdef0cca9e40315a46aedd (patch) | |
tree | 0780d3d7eed40aff1e94347922dc7d5b0ca23107 /src/nvim/normal.c | |
parent | 5c1b8b77c59d06f80368784f0eac92d6a331a313 (diff) | |
parent | b411f436d3e2e8a902dbf879d00fc5ed0fc436d3 (diff) | |
download | rneovim-b218d02c442ebacba1fdef0cca9e40315a46aedd.tar.gz rneovim-b218d02c442ebacba1fdef0cca9e40315a46aedd.tar.bz2 rneovim-b218d02c442ebacba1fdef0cca9e40315a46aedd.zip |
Merge pull request #16594 from shadmansaleh/feat/api/lua_keymaps
feat(api): add support for lua function & description in keymap
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3246596f16..60bf393085 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -334,6 +334,7 @@ static const struct nv_cmd { { K_SELECT, nv_select, 0, 0 }, { K_EVENT, nv_event, NV_KEEPREG, 0 }, { K_COMMAND, nv_colon, 0, 0 }, + { K_LUA, nv_colon, 0, 0 }, }; // Number of commands in nv_cmds[]. @@ -4043,21 +4044,22 @@ static void nv_regreplay(cmdarg_T *cap) } } -/// Handle a ":" command and <Cmd>. +/// Handle a ":" command and <Cmd> or Lua keymaps. static void nv_colon(cmdarg_T *cap) { int old_p_im; bool cmd_result; bool is_cmdkey = cap->cmdchar == K_COMMAND; + bool is_lua = cap->cmdchar == K_LUA; - if (VIsual_active && !is_cmdkey) { + if (VIsual_active && !is_cmdkey && !is_lua) { nv_operator(cap); } else { if (cap->oap->op_type != OP_NOP) { // Using ":" as a movement is charwise exclusive. cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = false; - } else if (cap->count0 && !is_cmdkey) { + } else if (cap->count0 && !is_cmdkey && !is_lua) { // translate "count:" into ":.,.+(count - 1)" stuffcharReadbuff('.'); if (cap->count0 > 1) { @@ -4073,9 +4075,13 @@ static void nv_colon(cmdarg_T *cap) old_p_im = p_im; + if (is_lua) { + cmd_result = map_execute_lua(); + } else { // get a command line and execute it - cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL, - cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0); + cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL, + cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0); + } // If 'insertmode' changed, enter or exit Insert mode if (p_im != old_p_im) { |