@@ -83,6 +83,24 @@ in your default browser using the xdg-open command.
8383- ` enterprise_mode ` : enable enterprise mode
8484- ` detect_proxy ` : enable or disable proxy detection
8585- ` enable_chat ` : enable chat functionality
86+ - ` enable_cmp_source ` : defaults to true. Set ` false ` to disable registering a ` cmp ` source
87+ - ` virtual_text ` : configuration for showing completions in virtual text
88+ - ` enabled ` : defaults to ` false ` . Set ` true ` to enable the virtual text feature
89+ - ` filetypes ` : A mapping of filetype to true or false, to enable virtual text
90+ - ` default_filetype_enabled ` : Whether to enable virtual text of not for types not listed in ` filetypes ` .
91+ - ` manual ` : Set ` true ` to only trigger Codeium using a manual Lua function call
92+ - ` idle_delay ` : defaults to ` 75 ` . Time in ms to wait before requesting completions after typing stops.
93+ - ` virtual_text_priority ` : defaults to ` 65535 ` . Priority of the virtual text
94+ - ` map_keys ` : defaults to ` true ` . Set ` false ` to not set any key bindings for completions
95+ - ` accept_fallback ` : Emulate pressing this key when using the accept key binding but there is no completion. Defaults
96+ to "\t"
97+ - ` key_bindings ` : key bindings for accepting and cycling through completions
98+ - ` accept ` : key binding for accepting a completion, default is ` <Tab> `
99+ - ` accept_word ` : key binding for accepting only the next word, default is not set
100+ - ` accept_line ` : key binding for accepting only the next line, default is not set
101+ - ` clear ` : key binding for clearing the virtual text, default is not set
102+ - ` next ` : key binding for cycling to the next completion, default is ` <M-]> `
103+ - ` prev ` : key binding for cycling to the previous completion, default is ` <M-[> `
86104- ` workspace_root ` :
87105 - ` use_lsp ` : Use Neovim's LSP support to find the workspace root, if possible.
88106 - ` paths ` : paths to files that indicate a workspace root when not using the LSP support
@@ -133,6 +151,143 @@ cmp.setup({
133151})
134152```
135153
154+ ### Virtual Text
155+
156+ The plugin supports showing completions in virtual text. Set ` virtual_text.enabled ` in the options to ` true ` to enable it.
157+
158+ ``` lua
159+ require (" codeium" ).setup ({
160+ -- Optionally disable cmp source if using virtual text only
161+ enable_cmp_source = false ,
162+ virtual_text = {
163+ enabled = true ,
164+
165+ -- These are the defaults
166+
167+ -- Set to true if you never want completions to be shown automatically.
168+ manual = false ,
169+ -- A mapping of filetype to true or false, to enable virtual text.
170+ filetypes = {},
171+ -- Whether to enable virtual text of not for filetypes not specifically listed above.
172+ default_filetype_enabled = true ,
173+ -- How long to wait (in ms) before requesting completions after typing stops.
174+ idle_delay = 75 ,
175+ -- Priority of the virtual text. This usually ensures that the completions appear on top of
176+ -- other plugins that also add virtual text, such as LSP inlay hints, but can be modified if
177+ -- desired.
178+ virtual_text_priority = 65535 ,
179+ -- Set to false to disable all key bindings for managing completions.
180+ map_keys = true ,
181+ -- The key to press when hitting the accept keybinding but no completion is showing.
182+ -- Defaults to \t normally or <c-n> when a popup is showing.
183+ accept_fallback = nil ,
184+ -- Key bindings for managing completions in virtual text mode.
185+ key_bindings = {
186+ -- Accept the current completion.
187+ accept = " <Tab>" ,
188+ -- Accept the next word.
189+ accept_word = false ,
190+ -- Accept the next line.
191+ accept_line = false ,
192+ -- Clear the virtual text.
193+ clear = false ,
194+ -- Cycle to the next completion.
195+ next = " <M-]>" ,
196+ -- Cycle to the previous completion.
197+ prev = " <M-[>" ,
198+ }
199+ }
200+ })
201+ ```
202+
203+ #### Virtual Text Keybindings
204+
205+ The plugin defines a number of key bindings for managing completion in virtual text mode. You can override these by
206+ setting ` virtual_text.key_bindings ` . If you don't want any key bindings, set ` virtual_text.map_keys ` to ` false ` , or
207+ you can set specific bindings to ` false ` .
208+
209+ When ` manual ` mode is enabled, you can call any of these functions to show completions:
210+
211+ ``` lua
212+ -- Request completions immediately.
213+ require (' codeium.virtual_text' ).complete ()
214+
215+ -- Request a completion, or cycle to the next if we already have some
216+ require (' codeium.virtual_text' ).cycle_or_complete ()
217+
218+ -- Complete only after idle_delay has passed with no other calls to debounced_complete().
219+ require (' codeium.virtual_text' ).debounced_complete ()
220+ ```
221+
222+ #### Virtual Text Filetypes
223+
224+ You can set the ` filetypes ` and ` default_filetype_enabled ` options in the ` virtual_text ` table to configure which filetypes
225+ should use virtual text.
226+
227+ ``` lua
228+ require (' codeium.virtual_text' ).setup ({
229+ virtual_text = {
230+ filetypes = {
231+ python = true ,
232+ markdown = false
233+ },
234+ default_filetype_enabled = true
235+ }
236+ })
237+ ```
238+
239+ ### Show Codeium status in statusline
240+
241+ When using virtual text, Codeium status can be generated by calling ` require('codeium.virtual_text').status_string() ` .
242+ It produces a 3 char long string with Codeium status:
243+
244+ - ` '3/8' ` - third suggestion out of 8
245+ - ` '0' ` - Codeium returned no suggestions
246+ - ` '*' ` - waiting for Codeium response
247+
248+ In order to show it in status line add following line to your ` .vimrc ` :
249+
250+ ``` set statusline+=%3{v:lua.require('codeium.virtual_text').status_string()} ```
251+
252+ Please check ` :help statusline ` for further information about building statusline in VIM.
253+
254+ The ` status_string ` function can also be used with other statusline plugins.
255+ You can call the ` set_statusbar_refresh ` function to customize how the plugin refreshes the
256+ status bar.
257+
258+ For example, this sets up the plugin with lualine:
259+
260+ ``` lua
261+ require (' codeium.virtual_text' ).set_statusbar_refresh (function ()
262+ require (' lualine' ).refresh ()
263+ end )
264+ ```
265+
266+ For more customization, you can also call the ` status ` function which returns an object that can be used to create a
267+ status string.
268+
269+ ``` lua
270+ function custom_status ()
271+ local status = require (' codeium.virtual_text' ).status ()
272+
273+ if status .state == ' idle' then
274+ -- Output was cleared, for example when leaving insert mode
275+ return ' '
276+ end
277+
278+ if status .state == ' waiting' then
279+ -- Waiting for response
280+ return " Waiting..."
281+ end
282+
283+ if status .state == ' completions' and status .total > 0 then
284+ return string.format (' %d/%d' , status .current , status .total )
285+ end
286+
287+ return ' 0 '
288+ end
289+ ```
290+
136291### Workspace Root Directory
137292
138293The plugin uses a few techniques to find the workspace root directory, which helps to inform the autocomplete and chat context.
@@ -173,8 +328,6 @@ require('codeium').setup({
173328})
174329```
175330
176-
177-
178331## Troubleshooting
179332
180333The plugin log is written to ` ~/.cache/nvim/codeium/codeium.log ` .
0 commit comments