-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement Super Tab like behavior? #91
Comments
For super tab like mapping, disable the built-in mapping: require("copilot").setup({
suggestion = {
accept = false,
},
}) and define the mapping yourself: vim.keymap.set("i", '<Tab>', function()
if require("copilot.suggestion").is_visible() then
require("copilot.suggestion").accept()
else
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, false, true), "n", false)
end
end, {
silent = true,
}) or if you're using cmp.setup({
-- ...
mapping = {
-- ...
["<Tab>"] = cmp.mapping(function(fallback)
if require("copilot.suggestion").is_visible() then
require("copilot.suggestion").accept()
elseif cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
elseif luasnip.expandable() then
luasnip.expand()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, {
"i",
"s",
}),
-- ...
},
-- ...
}) |
@MunifTanjim That worked for me. Should I close this issue? |
Yep. That is the recommended way of setting up custom keymap behavior. |
MunifTanjim
changed the title
Don't swallow accept key when there aren't any suggestions
How to implement Super Tab like behavior?
Apr 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
issue description
If I enable auto_trigger for suggestions, and have my accept keymap set to , when there are no suggestions, tab key does nothing.
expected behavior
I'd expect the tab key to feed tab to the editor when there are no suggestion.
The text was updated successfully, but these errors were encountered: