Exafunction / codeium.vim

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

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

Closed naquad closed 1 year ago

naquad commented 1 year ago

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.

nyngwang commented 1 year ago

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.

naquad commented 1 year ago

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.

nyngwang commented 1 year ago

@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.

Zundrium commented 1 year ago

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.

pqn commented 1 year ago

@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.

nyngwang commented 1 year ago

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

Yes, I haven't finished it yet.

pqn commented 1 year ago

@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.

nyngwang commented 1 year ago

@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:

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)

pqn commented 1 year ago

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

Zundrium commented 1 year ago

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.

pqn commented 1 year ago

@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).

AnoRebel commented 1 year ago

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.

Zundrium commented 1 year ago

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

AnoRebel commented 1 year ago

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

naquad commented 1 year ago

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

Zundrium commented 1 year ago

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

naquad commented 1 year ago

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.

jclsn commented 1 year ago

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

yingmanwumen commented 1 year ago

Hello, is anyone working on coc.nvim support?

Shougo commented 1 year ago

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

I have added ddc.vim completion engine support.

chunxuan-hs commented 1 year ago

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

I have added ddc.vim completion engine support.

Shougo commented 1 year ago

I have added it.

ms-jpq commented 1 year ago

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.

caheredia commented 1 year ago

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

pqn commented 1 year ago

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 commented 1 year ago

@jcdickinson would you be open to such an arrangement?

jcdickinson commented 1 year ago

I have stopped using nvim due to configuration burnout.

pqn commented 1 year ago

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?

jcdickinson commented 1 year ago

@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 commented 1 year ago

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

pqn commented 1 year ago

Thank you! I've completed the transfer to https://github.com/Exafunction/codeium.nvim, and will begin making changes soon.

I'll close this issue, as any further usability issues/bug reports can be sent to the new repo.