Skip to content

Commit

Permalink
Add new variable: g:codeium_filetypes_disabled_by_default. (#252)
Browse files Browse the repository at this point in the history
* Add new variable: `g:codeium_filetypes_disabled_by_default`.

Enables finer control of when to enable codeium.

* Add a note on ´CycleOrComplete()` in the README.
  • Loading branch information
zArubaru committed Mar 27, 2024
1 parent 82f2ba0 commit 3cc779d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ let g:codeium_filetypes = {

Codeium is enabled by default for most filetypes.

You can also _disable_ codeium by default with the `g:codeium_enabled`
variable:
You can also _disable_ codeium by default with the `g:codeium_enabled` variable,
and enable it manually per buffer by running `:CodeiumEnable`:

```vim
let g:codeium_enabled = v:false
Expand All @@ -127,11 +127,28 @@ or in Neovim:
vim.g.codeium_enabled = false
```

Instead, if you would like to just disable the automatic triggering of
completions:
Or you can disable codeium for _all filetypes_ with the `g:codeium_filetypes_disabled_by_default` variable,
and use the `g:codeium_filetypes` variable to selectively enable codeium for specified filetypes:

```vim
" let g:codeium_enabled = v:true
let g:codeium_filetypes_disabled_by_default = v:true
let g:codeium_filetypes = {
\ "rust": v:true,
\ "typescript": v:true,
\ }
```

If you would like to just disable the automatic triggering of completions:

```vim
let g:codeium_manual = v:true
" You might want to use `CycleOrComplete()` instead of `CycleCompletions(1)`.
" This will make the forward cycling of suggestions also trigger the first
" suggestion manually.
imap <C-;> <Cmd>call codeium#CycleOrComplete()<CR>
```

To disable automatic text rendering of suggestions (the gray text that appears for a suggestion):
Expand Down
8 changes: 7 additions & 1 deletion autoload/codeium.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ function! codeium#Enabled() abort

let codeium_filetypes = s:default_codeium_enabled
call extend(codeium_filetypes, get(g:, 'codeium_filetypes', {}))
if !get(codeium_filetypes, &filetype, 1)
" The `''` filetype should be forced to `1`, otherwise codeium may be unable start.
" This is related to the default new empty file not setting a filetype.
call extend(codeium_filetypes, {'': 1})

let codeium_filetypes_disabled_by_default = get(g:, 'codeium_filetypes_disabled_by_default') || get(b:, 'codeium_filetypes_disabled_by_default')

if !get(codeium_filetypes, &filetype, !codeium_filetypes_disabled_by_default)
return v:false
endif

Expand Down

0 comments on commit 3cc779d

Please sign in to comment.