Skip to content

neovim Copilot inserts weird character sometimes #29817

Answered by torarvid
Jacfger asked this question in Copilot
Discussion options

You must be logged in to vote

I tried understanding why @ArtursTimofejevs's suggestion worked, and I think I might have found something in the help for vim.keymap.set when looking at the {opts} (the {noremap = true, silent = true, expr=true } in the example)

Accepts options accepted by the {opts} parameter in
|nvim_set_keymap()|, with the following notable differences:
• replace_keycodes: Defaults to true if "expr" is true.

So I was able to fix it by keeping the use of vim.keymap.set but just adding , replace_keycodes = false:

local map = vim.keymap.set
map("i", "<C-j>", "copilot#Accept('<CR>')", {noremap = true, silent = true, expr=true, replace_keycodes = false })

I believe this fixed the issue for me.

Replies: 5 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pidgeon777
Comment options

Comment options

You must be logged in to vote
1 reply
@Leixb
Comment options

Comment options

You must be logged in to vote
1 reply
@nklsla
Comment options

Comment options

You must be logged in to vote
10 replies
@nburnett
Comment options

@efficacy38
Comment options

@phrmendes
Comment options

@paulo-granthon
Comment options

@gmtborges
Comment options

Answer selected by Jacfger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Neovim Autocomplete style suggestions with GitHub Copilot within a Neovim IDE Copilot Code accurately and faster with your AI powered pair-programmer. Product Feedback