Skip to content

Commit 3cc779d

Browse files
authored
Add new variable: g:codeium_filetypes_disabled_by_default. (Exafunction#252)
* 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.
1 parent 82f2ba0 commit 3cc779d

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ let g:codeium_filetypes = {
114114

115115
Codeium is enabled by default for most filetypes.
116116

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

120120
```vim
121121
let g:codeium_enabled = v:false
@@ -127,11 +127,28 @@ or in Neovim:
127127
vim.g.codeium_enabled = false
128128
```
129129

130-
Instead, if you would like to just disable the automatic triggering of
131-
completions:
130+
Or you can disable codeium for _all filetypes_ with the `g:codeium_filetypes_disabled_by_default` variable,
131+
and use the `g:codeium_filetypes` variable to selectively enable codeium for specified filetypes:
132+
133+
```vim
134+
" let g:codeium_enabled = v:true
135+
let g:codeium_filetypes_disabled_by_default = v:true
136+
137+
let g:codeium_filetypes = {
138+
\ "rust": v:true,
139+
\ "typescript": v:true,
140+
\ }
141+
```
142+
143+
If you would like to just disable the automatic triggering of completions:
132144

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

137154
To disable automatic text rendering of suggestions (the gray text that appears for a suggestion):

autoload/codeium.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ function! codeium#Enabled() abort
2121

2222
let codeium_filetypes = s:default_codeium_enabled
2323
call extend(codeium_filetypes, get(g:, 'codeium_filetypes', {}))
24-
if !get(codeium_filetypes, &filetype, 1)
24+
" The `''` filetype should be forced to `1`, otherwise codeium may be unable start.
25+
" This is related to the default new empty file not setting a filetype.
26+
call extend(codeium_filetypes, {'': 1})
27+
28+
let codeium_filetypes_disabled_by_default = get(g:, 'codeium_filetypes_disabled_by_default') || get(b:, 'codeium_filetypes_disabled_by_default')
29+
30+
if !get(codeium_filetypes, &filetype, !codeium_filetypes_disabled_by_default)
2531
return v:false
2632
endif
2733

0 commit comments

Comments
 (0)