codeium.vim icon indicating copy to clipboard operation
codeium.vim copied to clipboard

nvim-cmp, coc.nvim, coq.nvim and other completion engines

Open naquad opened this issue 1 year ago • 20 comments

NeoVIM, the same as VIM has quite a few completion plugins. It would be great to have nvim-cmp support or even X support.

It would be awesome to get either API or the boilerplate invocation code to integrate Codeium with the other completion plugins.

By boilerplate, I mean a code that would show how to properly setup the prerequisites, start, and interact with Codeium.

Thank you.

naquad avatar Jan 18 '23 22:01 naquad

Hi, I think this plugin can be used without all the plugins you mentioned. That is: Codeium.vim doesn't depend on those plugins. For example, I'm a user of hrsh7th/nvim-cmp, and I can use this plugin without any special setup on the nvim-cmp side:

From my current understanding, nvim-cmp is a plugin to show a menu for completion candidate(s) from specified sources. Given that Codeium is an AI-Completion plugin, the recommendation is almost always very long with respect to the little completion menu. So, your current question doesn't look reasonable to me.

Maybe you could elaborate more on what you want to achieve.

nyngwang avatar Jan 19 '23 00:01 nyngwang

Hi, I think this plugin can be used without all the plugins you mentioned. That is: Codeium.vim doesn't depend on those plugins. Exactly! So instead of a single completion system where all the possible completion options are set one has to figure out how to work with two completions in parallel. This is super inconvenient and kills any usage, at least for me.

It would be great if this plugin would provide an API, so one could integrate other completion engines.

I'm saying this after trying out TabNine with its multiline completion as a virtual text. It was incredibly hard to use as I had two separate sets of keys to confirm the completion and select the options. It makes more sense to have a single completion plugin and everything else should be a source.

Regarding the multiline options and the menu: it actually works ok: image

As you can see the multiline snippet is simply displayed aside from the option.

naquad avatar Jan 19 '23 13:01 naquad

@naquad Hi, thanks for your informative reply. Now I got what you meant and I think it's a good idea to achieve the effect/functionality as your picture shows. I will take a look at how to implement a source for nvim-cmp first, and if it's within my current ability I will try to contribute. After that maybe I can provide practical suggestions for the other plugins you mentioned.

nyngwang avatar Jan 19 '23 13:01 nyngwang

I agree with @naquad here. When I was asked on Discord to test the plugin the first thing that stood out to me was it not being usable as a custom source for nvim-cmp. The nvim-cmp auto-completion plugin comes packed with almost all the popular preconfigured NeoVIM projects here on GitHub.

For GitHub Copilot there are nvim-cmp source projects like zbirenbaum/copilot-cmp and hrsh7th/cmp-copilot.

Having Codeium as a nvim-cmp source not only helps with having a single solution for auto-completion, it also allows for a list of suggestions to scroll through instead of presenting a single one.

Zundrium avatar Jan 19 '23 14:01 Zundrium

@nyngwang are you taking a look at nvim-cmp right now? (cc @sullivan-sean)

IIUC the right interface for coc.nvim/coq.nvim is probably an LSP? We're evaluating this right now.

pqn avatar Jan 24 '23 20:01 pqn

@nyngwang are you taking a look at nvim-cmp right now?

Yes, I haven't finished it yet.

nyngwang avatar Jan 24 '23 20:01 nyngwang

@nyngwang are you taking a look at nvim-cmp right now?

Yes, I haven't finished it yet.

Awesome, feel free to message in our Discord if you have any questions.

pqn avatar Jan 24 '23 20:01 pqn

@pqn In short, I probably cannot help much regarding implementing a Exafunction/codeium.vim source for hrsh7th/nvim-cmp. These are some completion sources for hrsh7th/nvim-cmp that I used as references to understand its complexity:

and these are my observations:

  • [hrsh7th/cmp-path] is a good starting point to understand how to create a source for hrsh7th/nvim-cmp.
    • we can (as these seem to be optional) provide both source.get_trigger_characters, source.get_keyword_pattern to decide when to add/trigger a source so those items generated by it will be populated into the completion menu of hrsh7th/nvim-cmp.
    • we can use source.resolve to modify the data of the menu item that is hovered but not yet selected. hrsh7th/cmp-path uses this method to show a preview if the hovered item is a file. (just like the comment above)
  • In short, both [tzachar/cmp-tabnine], [zbirenbaum/copilot-cmp] are beyond my current ability, since many things need to be considered and this is better done by you guys.
    • [tzachar/cmp-tabnine] provides an option run_on_every_keystroke to decide "whether to request the server on every keystroke" (it's true by default for better UX, according to the author). And it can show the strength of prediction(confidence on the output?) by option show_prediction_strength.
    • [zbirenbaum/copilot-cmp] I haven't finished my reading but I have to admit that this is simply beyond my current ability. It has a file to add callbacks to vim.lsp.handlers, and I don't know much about those details regarding LSP on NeoVim currently 🥲.

It will be a good idea to consult these authors instead regarding implementing a source. (I will try my best to create one recently, but it will probably not be robust enough for real use cases)

nyngwang avatar Jan 25 '23 02:01 nyngwang

@nyngwang Appreciate the notes. Sounds like maybe it's best that this fall to us.

pqn avatar Jan 25 '23 02:01 pqn

Thanks for sharing @nyngwang, good stuff. Even a basic implementation with one suggestion at the top of the list would be perfect. Maybe this youtube video can help: https://www.youtube.com/watch?v=gAsYolNrjtQ .

Is there some documentation on how to access the Codeium REST API? I can imagine struggling the most with the authentication if I were to make one of these.

Zundrium avatar Jan 25 '23 07:01 Zundrium

@Zundrium you can see our authentication code here: https://github.com/Exafunction/codeium.vim/blob/5aced5bbb81b89e66a09989fa16484cab2466b65/autoload/codeium/command.vim#L51

We don't have public documentation of the REST protocol right now, not sure if we plan on it soon (cc @fortenforge).

pqn avatar Jan 26 '23 19:01 pqn

I'm not sure if this is relevant but there's a native Neovim extension for Codeium that seems to support passing it as a nvim-cmp source.

AnoRebel avatar Feb 01 '23 11:02 AnoRebel

image Seems to work for single line suggestions, nice catch @AnoRebel!

Zundrium avatar Feb 02 '23 10:02 Zundrium

@Zundrium Thanks, the author says it supports multiline too. 🤔 See this comment

AnoRebel avatar Feb 02 '23 11:02 AnoRebel

I'm using it currently, works great. And yes, it does support multiline completions, although they're somewhat tricky to trigger but that doesn't seem to be plugin-related.

image

naquad avatar Feb 02 '23 11:02 naquad

@naquad and @AnoRebel, You're both right, depends on the language it seems.

Zundrium avatar Feb 02 '23 12:02 Zundrium

Indeed. I was barely able to squeeze out the multiline for JS after a bunch of tries:

image

Multiline completions are VERY context-dependent and sometimes even give you results from the other languages.

I think the ticket can be closed.

naquad avatar Feb 02 '23 21:02 naquad

I think COC support would be needed as well to also support Vim and not just Neovim

jclsn avatar Mar 17 '23 08:03 jclsn

Hello, is anyone working on coc.nvim support?

yingmanwumen avatar Mar 17 '23 15:03 yingmanwumen

https://github.com/Shougo/ddc-source-codeium

I have added ddc.vim completion engine support.

Shougo avatar May 11 '23 23:05 Shougo

@Shougo Thanks! Could you add ddc-vim tag so it's easier to find it?

I have added ddc.vim completion engine support.

chunxuan-hs avatar Jun 19 '23 12:06 chunxuan-hs

I have added it.

Shougo avatar Jun 19 '23 23:06 Shougo

I just heard about this today, and added a codeium -> LSP translation layer.

https://github.com/ms-jpq/coq.thirdparty/tree/3p#codeium

Not sure how well my approach works though, im just spamming the codeium#Complete button as fast as the user is typing.

That seems to be working ok for copilot though. I guess ill keep using it for a while before I put it in the description of my main repo.

ms-jpq avatar Jul 01 '23 02:07 ms-jpq

Can we re-open this? https://github.com/jcdickinson/codeium.nvim was deprecated today

caheredia avatar Sep 11 '23 04:09 caheredia

We'll have to discuss internally if we have the cycles to maintain this repo. At the very least, maybe we can consider a repo transfer to our GitHub organization to keep the issues alive, with the possibility of re-transfer later to a community maintainer who is more knowledgeable about Lua than our team. It's easy enough for us to keep the language server binary up to date if we owned the repo though.

pqn avatar Sep 14 '23 02:09 pqn

@jcdickinson would you be open to such an arrangement?

pqn avatar Sep 18 '23 17:09 pqn

I have stopped using nvim due to configuration burnout.

jcdickinson avatar Sep 18 '23 19:09 jcdickinson

Understood. To clarify, for the continued users of your plugin, would you be open to repository transfer to our GH organization so we can take a stab at the maintenance?

pqn avatar Sep 18 '23 19:09 pqn

@pqn I tried to transfer it to exafunction, but it looks like I would need permissions on your side. I have transferred it to you instead.

jcdickinson avatar Sep 18 '23 21:09 jcdickinson

Feel free to change the copyright and anything else you want.

jcdickinson avatar Sep 18 '23 21:09 jcdickinson