if exists('g:loaded_codeium')
finish
endif
let g:loaded_codeium = 1
command! -nargs=? -complete=customlist,codeium#command#Complete Codeium exe codeium#command#Command()
if !codeium#util#HasSupportedVersion()
finish
endif
function! s:SetStyle() abort
if &t_Co == 256
hi def CodeiumSuggestion guifg=#808080 ctermfg=244
else
hi def CodeiumSuggestion guifg=#808080 ctermfg=8
endif
hi def link CodeiumAnnotation Normal
endfunction
function! s:MapTab() abort
if !get(g:, 'codeium_no_map_tab', v:false) && !get(g:, 'codeium_disable_bindings')
imap codeium#Accept()
endif
endfunction
augroup codeium
autocmd!
autocmd InsertEnter,CursorMovedI,CompleteChanged * call codeium#DebouncedComplete()
autocmd BufEnter * if codeium#Enabled()|call codeium#command#StartLanguageServer()|endif
autocmd BufEnter * if mode() =~# '^[iR]'|call codeium#DebouncedComplete()|endif
autocmd InsertLeave * call codeium#Clear()
autocmd BufLeave * if mode() =~# '^[iR]'|call codeium#Clear()|endif
autocmd ColorScheme,VimEnter * call s:SetStyle()
" Map tab using vim enter so it occurs after all other sourcing.
autocmd VimEnter * call s:MapTab()
autocmd VimLeave * call codeium#ServerLeave()
augroup END
imap (codeium-dismiss) call codeium#Clear()
imap (codeium-next) call codeium#CycleCompletions(1)
imap (codeium-next-or-complete) call codeium#CycleOrComplete()
imap (codeium-previous) call codeium#CycleCompletions(-1)
imap (codeium-complete) call codeium#Complete()
if !get(g:, 'codeium_disable_bindings')
if empty(mapcheck('', 'i'))
imap codeium#Clear() . "\"
endif
if empty(mapcheck('', 'i'))
imap (codeium-next-or-complete)
endif
if empty(mapcheck('', 'i'))
imap (codeium-previous)
endif
if empty(mapcheck('', 'i'))
imap (codeium-complete)
endif
if empty(mapcheck('', 'i'))
imap codeium#AcceptNextWord()
endif
if empty(mapcheck('', 'i'))
imap codeium#AcceptNextLine()
endif
endif
call s:SetStyle()
let s:dir = expand(':h:h')
if getftime(s:dir . '/doc/codeium.txt') > getftime(s:dir . '/doc/tags')
silent! execute 'helptags' fnameescape(s:dir . '/doc')
endif
function! CodeiumEnable() " Enable Codeium if it is disabled
let g:codeium_enabled = v:true
call codeium#command#StartLanguageServer()
endfun
command! CodeiumEnable :silent! call CodeiumEnable()
function! CodeiumDisable() " Disable Codeium altogether
let g:codeium_enabled = v:false
endfun
command! CodeiumDisable :silent! call CodeiumDisable()
function! CodeiumToggle()
if exists('g:codeium_enabled') && g:codeium_enabled == v:false
call CodeiumEnable()
else
call CodeiumDisable()
endif
endfunction
command! CodeiumToggle :silent! call CodeiumToggle()
function! CodeiumManual() " Disable the automatic triggering of completions
let g:codeium_manual = v:true
endfun
command! CodeiumManual :silent! call CodeiumManual()
function! CodeiumAuto() " Enable the automatic triggering of completions
let g:codeium_manual = v:false
endfun
command! CodeiumAuto :silent! call CodeiumAuto()
:amenu Plugin.Codeium.Enable\ \Codeium\ \(\:CodeiumEnable\) :call CodeiumEnable()
:amenu Plugin.Codeium.Disable\ \Codeium\ \(\:CodeiumDisable\) :call CodeiumDisable()
:amenu Plugin.Codeium.Manual\ \Codeium\ \AI\ \Autocompletion\ \(\:CodeiumManual\) :call CodeiumManual()
:amenu Plugin.Codeium.Automatic\ \Codeium\ \AI\ \Completion\ \(\:CodeiumAuto\) :call CodeiumAuto()
:amenu Plugin.Codeium.Toggle\ \Codeium\ \(\:CodeiumToggle\) :call CodeiumToggle()