You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifhas('vim_starting')
setencoding=utf-8endifscriptencoding utf-8if &compatiblesetnocompatibleendiflets:plug_dir=expand('/tmp/plugged/vim-plug')
if!filereadable(s:plug_dir .. '/plug.vim')
executeprintf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
endexecute'set runtimepath+=' . s:plug_dircallplug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
Plug 'zbirenbaum/copilot.lua'callplug#end()
PlugInstall | quit" Setup global configuration. More on configuration below.lua << EOF
require("copilot").setup({
suggestion = {
enabled = true,
auto_trigger = true,
hide_during_completion = false,
debounce =75,
keymap= {
-- Use nvim-cmp
accept = false,
accept_word = false,
accept_line = false,
next= false,
prev= false,
dismiss = false,
},
},
})
local cmp= require "cmp"cmp.setup {
snippet = {
expand=function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping= {
['<CR>'] =cmp.mapping.confirm({ select = true }),
["<Tab>"] =cmp.mapping(function(fallback)
local suggestion =require("copilot.suggestion")
if suggestion.is_visible() andcmp.visible() then
cmp.close()
elseif suggestion.is_visible() then
suggestion.accept()
cmp.abort()
elseifcmp.visible() then
-- You could replace select_next_item() with confirm({ select = true }) toget VS Code autocompletion behavior
cmp.select_next_item()
elseifvim.snippet.active({ direction =1 }) then
vim.schedule(function()
vim.snippet.jump(1)
end)
elsefallback()
endend, { "i", "s" }),
},
sources =cmp.config.sources({
{ name ="nvim_lsp" },
{ name ="buffer" },
}),
}
EOF
lua << EOF
local capabilities =require('cmp_nvim_lsp').default_capabilities()
require'lspconfig'.cssls.setup {
capabilities = capabilities,
}
EOF
Description
I'm using Copilot.lua and trying to use super-tab like mappings so that when I accept a suggestion, it closes the menu as if nvim-cmp finished the completion. Right now, with the above super-tab configuration, once I hit tab to complete using Copilot.lua, nvim-cmp autocomplete feature kicks in and opens the menu as if I was typing.
Steps to reproduce
Write some code.
Press tab to complete using Copilot, the menu opens up
Expected behavior
I want to be able to control the autocomplete feature and perhaps set a buffer flag to disable the next auto complete. So basically make autocomplete take a function that returns a boolean.
Actual behavior
nvim-cmp always opens up the menu event after cmp.abort()
Additional context
As a workaround, I was able to achieve what I'm looking for by wrapping cmp.abort() after accepting a suggestion in a vim.schedule but this feels flaky
["<Tab>"] =cmp.mapping(function(fallback)
localsuggestion=require("copilot.suggestion")
ifsuggestion.is_visible() andcmp.visible() thencmp.close()
elseifsuggestion.is_visible() thensuggestion.accept()
vim.schedule(function()
-- We need to schedule this to close the completion menu after accepting the suggestioncmp.abort()
end)
elseifcmp.visible() then-- You could replace select_next_item() with confirm({ select = true }) to get VS Code autocompletion behaviorcmp.select_next_item()
elseifvim.snippet.active({ direction=1 }) thenvim.schedule(function()
vim.snippet.jump(1)
end)
elsefallback()
endend, { "i", "s" }),
The text was updated successfully, but these errors were encountered:
FAQ
Announcement
Minimal reproducible full config
Description
I'm using Copilot.lua and trying to use super-tab like mappings so that when I accept a suggestion, it closes the menu as if nvim-cmp finished the completion. Right now, with the above super-tab configuration, once I hit tab to complete using Copilot.lua, nvim-cmp autocomplete feature kicks in and opens the menu as if I was typing.
Steps to reproduce
Expected behavior
I want to be able to control the
autocomplete
feature and perhaps set a buffer flag to disable the next auto complete. So basically makeautocomplete
take a function that returns a boolean.Actual behavior
nvim-cmp always opens up the menu event after
cmp.abort()
Additional context
As a workaround, I was able to achieve what I'm looking for by wrapping
cmp.abort()
after accepting a suggestion in avim.schedule
but this feels flakyThe text was updated successfully, but these errors were encountered: