forked from Exafunction/windsurf.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeium.vim
More file actions
66 lines (55 loc) · 2.04 KB
/
codeium.vim
File metadata and controls
66 lines (55 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
if exists('g:loaded_codeium')
finish
endif
let g:loaded_codeium = 1
command! -nargs=? -complete=customlist,codeium#command#Complete Codeium exe codeium#command#Command(<q-args>)
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 <script><silent><nowait><expr> <Tab> codeium#Accept()
endif
endfunction
augroup codeium
autocmd!
autocmd InsertEnter,CursorMovedI,CompleteChanged * call codeium#DebouncedComplete()
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()
augroup END
imap <Plug>(codeium-dismiss) <Cmd>call codeium#Clear()<CR>
imap <Plug>(codeium-next) <Cmd>call codeium#CycleCompletions(1)<CR>
imap <Plug>(codeium-previous) <Cmd>call codeium#CycleCompletions(-1)<CR>
imap <Plug>(codeium-complete) <Cmd>call codeium#Complete()<CR>
if !get(g:, 'codeium_disable_bindings')
if empty(mapcheck('<C-]>', 'i'))
imap <silent><script><nowait><expr> <C-]> codeium#Clear() . "\<C-]>"
endif
if empty(mapcheck('<M-]>', 'i'))
imap <M-]> <Plug>(codeium-next)
endif
if empty(mapcheck('<M-[>', 'i'))
imap <M-[> <Plug>(codeium-previous)
endif
if empty(mapcheck('<M-Bslash>', 'i'))
imap <M-Bslash> <Plug>(codeium-complete)
endif
endif
call s:SetStyle()
call timer_start(0, function('codeium#server#Start'))
let s:dir = expand('<sfile>:h:h')
if getftime(s:dir . '/doc/codeium.txt') > getftime(s:dir . '/doc/tags')
silent! execute 'helptags' fnameescape(s:dir . '/doc')
endif