From 8e7a75944c88c166cc3c0fcec0221da0057aab3d Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 2 Jul 2023 13:41:55 +0800 Subject: [PATCH] fix(cmp): fix key binding `ctrl-n/p` --- lua/config/nvim-cmp.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua index 23abbdbcb..64a8ae50a 100644 --- a/lua/config/nvim-cmp.lua +++ b/lua/config/nvim-cmp.lua @@ -56,6 +56,15 @@ local function enter(f) -- {{{ end -- }}} +local function ctrl_p(f) -- {{{ + if cmp.visible() then + cmp.select_prev_item() + else + pcall(f) + end +end +-- }}} + local function ctrl_n(f) -- {{{ if cmp.visible() then cmp.select_next_item() @@ -93,7 +102,8 @@ cmp.setup({ fallback() end end, - [''] = ctrl_n, + [''] = ctrl_p, [''] = enter, }, sources = cmp.config.sources({