Skip to content

Instantly share code, notes, and snippets.

@haandol
Created September 21, 2024 07:38
Show Gist options
  • Save haandol/c2ff89706fa8af6edf1bb2bb0c1fe3ba to your computer and use it in GitHub Desktop.
Save haandol/c2ff89706fa8af6edf1bb2bb0c1fe3ba to your computer and use it in GitHub Desktop.
copilot on lazyvim use tab to accept suggestion instead of enter, just like vscode
-- ~/.config/nvim/lua/plugins/cmp.lua
return {
{
"hrsh7th/nvim-cmp",
opts = function(_, opts)
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ select = true })
else
fallback()
end
end, { "i", "s" }),
["<CR>"] = cmp.mapping.abort(),
})
end,
},
}
-- ~/.config/nvim/lua/plugins/copilot.lua
return {
{
"zbirenbaum/copilot.lua",
opts = {
suggestion = {
keymap = {
accept = "<Tab>",
accept_word = false,
accept_line = false,
},
},
},
},
}
-- ~/.config/nvim/config/keymaps.lua
vim.keymap.set("i", "<CR>", "<CR>", { noremap = true, silent = true })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment