codeium.vim
codeium.vim copied to clipboard
nvim-cmp, coc.nvim, coq.nvim and other completion engines
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.
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:
![](https://user-images.githubusercontent.com/24765272/213326686-609a1539-8d4d-4242-9ec1-cc1c0b94b2a7.jpg)
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.
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:
As you can see the multiline snippet is simply displayed aside from the option.
@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.
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.
@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 are you taking a look at nvim-cmp right now?
Yes, I haven't finished it yet.
@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 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:
- hrsh7th/cmp-path
- tzachar/cmp-tabnine
- zbirenbaum/copilot-cmp (mentioned in the comment above)
and these are my observations:
-
[hrsh7th/cmp-path]
is a good starting point to understand how to create a source forhrsh7th/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 ofhrsh7th/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)
- we can (as these seem to be optional) provide both
- 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 optionrun_on_every_keystroke
to decide "whether to request the server on every keystroke" (it'strue
by default for better UX, according to the author). And it can show the strength of prediction(confidence on the output?) by optionshow_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 tovim.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 Appreciate the notes. Sounds like maybe it's best that this fall to us.
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 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).
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.
Seems to work for single line suggestions, nice catch @AnoRebel!
@Zundrium Thanks, the author says it supports multiline too. 🤔 See this comment
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.
@naquad and @AnoRebel, You're both right, depends on the language it seems.
Indeed. I was barely able to squeeze out the multiline for JS after a bunch of tries:
Multiline completions are VERY context-dependent and sometimes even give you results from the other languages.
I think the ticket can be closed.
I think COC support would be needed as well to also support Vim and not just Neovim
Hello, is anyone working on coc.nvim support?
https://github.com/Shougo/ddc-source-codeium
I have added ddc.vim
completion engine support.
@Shougo Thanks! Could you add ddc-vim tag so it's easier to find it?
I have added
ddc.vim
completion engine support.
I have added it.
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.
Can we re-open this? https://github.com/jcdickinson/codeium.nvim was deprecated today
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.
@jcdickinson would you be open to such an arrangement?
I have stopped using nvim due to configuration burnout.
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 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.
Feel free to change the copyright and anything else you want.