Closed leitdeux closed 1 year ago
I personally think you are absolutely right. Fortunately, nvim-cmp can be configured to selectively use completion sources by filetype. You don't need to include Codeium for every file. Just omit Codeium from the global completion sources, then additionally do something like this (in this example for Rust files):
cmp.setup.filetype('rust', {
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'codeium' },
}, {
{ name = 'buffer' },
})
})
Thanks for sharing that great tip, @neoeleatic! I hadn't realized nvim-cmp
had that feature. I was able to get things working just as you described. Thanks again
I'm not happy with this solution. I use it everywhere except for latex. I don't want to rewrite the shole nvim-cmp configuration just for Codeium...
@00sapo You don't have to rewrite the whole config, you have to add about 3 lines of code to the nvim-cmp configuration where it belongs. You can save a list of completions in a variable, then copy it to another table and drop the codeium entry, then use one table as the default and the other for latex. Alternatively if you have any plugins that load just for latex, you can also add a lite to their config function that changes the cmp setup for that buffer.
As an example of the latter approach, that's what I do to exclude Codeium and many other completions from running on Ledger files (which have sensitive financial info). I have a default cmp config that includes many completions, then in a plugin config that loads only for Ledger files I setup a new limited set of sources just for those buffers.
This is how these plugins are designed to work together. If you use cmp this is how it expects things to work. This plugin is not expected to re-implement a mechanism that is already there.
Expanding the second solution of @alerque, if you don't have a plugin that loads only for the file you want to disable, you can just create a ftplugin. It's a script that will execute if the filetype of the buffer and the script name matches. In your config, just create a dir and file like this: after/ftplugin/<filetype_you_want_to_disable>.lua
and then exclude the codium in the sources like so:
require("cmp").setup.buffer({
sources = {
{ name = "nvim_lsp" },
{ name = "vsnip" },
{ name = "buffer" },
{ name = "path" },
-- { name = "codeium" },
},
})
but does this solution actually disable codeium from 'reading' files content and sending requests to their servers?
For future reference looks like they have a codeium_filetypes setting (Read about it via :h codeium) that accomplishes this
For future reference looks like they have a codeium_filetypes setting (Read about it via :h codeium) that accomplishes this
yeah, but its quite hard to setup which files to disable\enable using 'filetype', it would be better to have patterns: like in autocmds: disabled = { "*.env", ".git-credentials", ... }
@nfjdu No, filetype definitions are the right way to handle this. Filename globbing is re-inventing the wheel. There are lots of file types that cover multiple possible extensions and use various heuristics to determine the type that go beyond just the filename. Additionally plugins (and plugin managers) are setup to handle lazy loading based on filetype. Bypassing that would mess up all sorts of possible configs. There are more reasons to, but long story short if you want plugins to load ar not load on a subset of files, filetype is the right thing to reach for by default.
@jcdickinson First, thanks so much for producing this great plugin.
It would be great to have more fine-grained control over the kinds of files which should have Codeium completions either enabled or disabled. For example, it would be a good reassurance privacy-wise if
.env
or other filetypes which customarily contain secrets or configuration could be ignored by Codeium.Thanks again for putting your time and effort into this project.