feat(suggestion): operate accept when is_visible#258
feat(suggestion): operate accept when is_visible#258AntoineGS merged 3 commits intozbirenbaum:masterfrom
Conversation
|
If this PR is accepted, could I apply it to the other keymaps? |
This comment was marked as resolved.
This comment was marked as resolved.
|
@zbirenbaum apologies for a direct ping and thanks for your work! Can we merge this? It removes a need for users to look up things to use tab to accept suggestions. This makes the setup experience notably smoother. |
|
I'd like to test this to merge it but I can't figure out what it is solving (sorry!) |
|
this PR makes sure that the keymap used to accept suggestion is still fed to neovim if there is no completion. This is useful when you want to use for completion. Currently if you use require('copilot').setup({
suggestion = {
keymap = {
accept = '<tab>',
},
},
})You will be able to use to accept completions, but you won't be able to indent code when there's no suggested completion. To work around this currently you have to do extra steps such as require('copilot').setup({
suggestion = {
keymap = {
accept = false,
},
},
})
vim.keymap.set('i', '<tab>', function()
if require('copilot.suggestion').is_visible() then
require('copilot.suggestion').accept()
return '<Ignore>'
end
return '<tab>'
end, { expr = true, noremap = true })This PR makes the first example work with out needing to make a custom keymap for it work. |
|
Thank you I understand now :) |
|
Yes, this is what I was looking for |
|
I will update the PR to match the new refactor and integrate this change (with a configuration) shortly |
Same as #192 but applied to keymap.accept