Exafunction / codeium.vim

Free, ultrafast Copilot alternative for Vim and Neovim
https://codeium.com
MIT License
3.68k stars 124 forks source link

I got error as a AcceptNextLine in insert mode #381

Closed Kythonlk closed 6 days ago

Kythonlk commented 1 week ago
          I got error for this 

image

in insert mode if i press next arrow key it will enter "-1" then give error msg

This is my lazy vim plugin config to codeium.

return { { "Exafunction/codeium.vim", event = "BufEnter", config = function() vim.keymap.set("i", "", function() return vim.fn["codeium#Accept"]() end, { expr = true, silent = true }) vim.keymap.set("i", "<c-;>", function() return vim.fn"codeium#CycleCompletions" end, { expr = true, silent = true }) vim.keymap.set("i", "<c-,>", function() return vim.fn"codeium#CycleCompletions" end, { expr = true, silent = true }) vim.keymap.set("i", "", function() return vim.fn["codeium#Clear"]() end, { expr = true, silent = true }) end, }, }

os: Manjaro 6.6 (Arch) neovim : v11

Originally posted by @Kythonlk in https://github.com/Exafunction/codeium.vim/issues/380#issuecomment-2164622414

lasypig commented 1 week ago

I got this, too.

samhed commented 1 week ago

Same

samhed commented 1 week ago

Bug caused by 9fa0dee67051d8e5d334f7f607e6bab1d6a46d1a, reverting to decfb541c9fd176f467991dcde8923c7db362e02 fixes things.

LeonardoMor commented 1 week ago

This happens when there are no completions. If there's no ghost text, this error will appear. Will add some guards for that case.

If you see this happening under other conditions, let us know.

daUnknownCoder commented 1 week ago

This happens when there are no completions. If there's no ghost text, this error will appear. Will add some guards for that case.

If you see this happening under other conditions, let us know.

i am not even getting ghost text, pressing the key unnecessarily showed me that the plugin was loaded

LeonardoMor commented 1 week ago

When you get a chance, please pull the repo and test it. Let us know.

cleong14 commented 1 week ago

If you are using the latest commit and are still encountering issues, the workaround of removing the ~/.codeium/code_tracker directory (e.g. rm -rf ~/.codeium/code_tracker) fixes the issues for me.

lasypig commented 1 week ago

make the following changes to file autoload/codeium.vim, works for me now:

function! codeium#Accept() abort
  let current_completion = s:GetCurrentCompletionItem()
  return s:CompletionInserter(current_completion, current_completion is v:null ? '' : current_completion.completion.text) 
endfunction

function! codeium#AcceptNextWord() abort
  let current_completion = s:GetCurrentCompletionItem()
  let completion_parts = current_completion is v:null ? [] : get(current_completion, 'completionParts', [])
  if len(completion_parts) == 0
    return ''
  endif
  let prefix_text = get(completion_parts[0], 'prefix', '')
  let completion_text = get(completion_parts[0], 'text', '')
  let next_word = matchstr(completion_text, '\v^\W*\k*')
  return s:CompletionInserter(current_completion, prefix_text . next_word)
endfunction

function! codeium#AcceptNextLine() abort
  let current_completion = s:GetCurrentCompletionItem()
  let text = current_completion is v:null ? '' : substitute(current_completion.completion.text, '\v\n.*$', '', '')
  return s:CompletionInserter(current_completion, text)
endfunction
LeonardoMor commented 1 week ago

make the following changes to file autoload/codeium.vim, works for me now:

function! codeium#Accept() abort
  let current_completion = s:GetCurrentCompletionItem()
  return s:CompletionInserter(current_completion, current_completion is v:null ? '' : current_completion.completion.text) 
endfunction

function! codeium#AcceptNextWord() abort
  let current_completion = s:GetCurrentCompletionItem()
  let completion_parts = current_completion is v:null ? [] : get(current_completion, 'completionParts', [])
  if len(completion_parts) == 0
    return ''
  endif
  let prefix_text = get(completion_parts[0], 'prefix', '')
  let completion_text = get(completion_parts[0], 'text', '')
  let next_word = matchstr(completion_text, '\v^\W*\k*')
  return s:CompletionInserter(current_completion, prefix_text . next_word)
endfunction

function! codeium#AcceptNextLine() abort
  let current_completion = s:GetCurrentCompletionItem()
  let text = current_completion is v:null ? '' : substitute(current_completion.completion.text, '\v\n.*$', '', '')
  return s:CompletionInserter(current_completion, text)
endfunction

Would you send a pull request?

LeonardoMor commented 1 week ago

@fortenforge This one was also be fixed

Kythonlk commented 6 days ago

This error fixed and now working well