From 872b1e54cd0d192469611a8eb8205b8c83995e89 Mon Sep 17 00:00:00 2001 From: Cthutu Date: Fri, 28 Apr 2023 23:06:17 +0100 Subject: [PATCH] feat(completion): added more mappings for copilot-lua-cmp (#150) * feat: added mappings for Copilot completion pack It is very useful to accept Co-pilot suggestions one word at a time or even a whole line. Copilot offers these features but they have not been exposed. VS Code, by default uses Ctrl+Right to accept a word. I've added similar vim-like controls: * Ctrl+Right/L for accepting a word * Ctrl+Down/J for accepting a line * Ctrl+C to dismiss the suggestion * fix formatting --------- Co-authored-by: Micah Halter --- .../copilot-lua-cmp/copilot-lua-cmp.lua | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lua/astrocommunity/completion/copilot-lua-cmp/copilot-lua-cmp.lua b/lua/astrocommunity/completion/copilot-lua-cmp/copilot-lua-cmp.lua index 9ad9fb596..38e5631a2 100644 --- a/lua/astrocommunity/completion/copilot-lua-cmp/copilot-lua-cmp.lua +++ b/lua/astrocommunity/completion/copilot-lua-cmp/copilot-lua-cmp.lua @@ -39,6 +39,26 @@ return { if copilot.is_visible() then copilot.prev() end end) + opts.mapping[""] = cmp.mapping(function() + if copilot.is_visible() then copilot.accept_word() end + end) + + opts.mapping[""] = cmp.mapping(function() + if copilot.is_visible() then copilot.accept_word() end + end) + + opts.mapping[""] = cmp.mapping(function() + if copilot.is_visible() then copilot.accept_line() end + end) + + opts.mapping[""] = cmp.mapping(function() + if copilot.is_visible() then copilot.accept_line() end + end) + + opts.mapping[""] = cmp.mapping(function() + if copilot.is_visible() then copilot.dismiss() end + end) + return opts end, },