Skip to content

Commit 8ad4b2f

Browse files
authored
don't start language server if codeium is disabled (Exafunction#114)
* don't start language server if codeium is disabled * start the server from `Codeium *` commands as well * better looking code * fmt * fix codeium enabled check * restore check
1 parent 477ef8e commit 8ad4b2f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

autoload/codeium/command.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,22 @@ function! s:commands.DisableBuffer(...) abort
115115
let b:codeium_enabled = 0
116116
endfunction
117117

118+
" Run codeium server only if its not already started
119+
function! codeium#command#StartLanguageServer() abort
120+
if !get(g:, 'codeium_server_started', v:false)
121+
call timer_start(0, function('codeium#server#Start'))
122+
let g:codeium_server_started = v:true
123+
endif
124+
endfunction
125+
118126
function! s:commands.Enable(...) abort
119127
let g:codeium_enabled = 1
128+
call codeium#command#StartLanguageServer()
120129
endfunction
121130

122131
function! s:commands.EnableBuffer(...) abort
123132
let b:codeium_enabled = 1
133+
call codeium#command#StartLanguageServer()
124134
endfunction
125135

126136
function! codeium#command#ApiKey() abort

plugin/codeium.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ if !get(g:, 'codeium_disable_bindings')
6060
endif
6161

6262
call s:SetStyle()
63-
call timer_start(0, function('codeium#server#Start'))
63+
64+
if codeium#Enabled()
65+
call codeium#command#StartLanguageServer()
66+
endif
6467

6568
let s:dir = expand('<sfile>:h:h')
6669
if getftime(s:dir . '/doc/codeium.txt') > getftime(s:dir . '/doc/tags')
@@ -69,6 +72,7 @@ endif
6972

7073
function! CodeiumEnable() " Enable Codeium if it is disabled
7174
let g:codeium_enabled = v:true
75+
call codeium#command#StartLanguageServer()
7276
endfun
7377

7478
command! CodeiumEnable :silent! call CodeiumEnable()

0 commit comments

Comments
 (0)