Skip to content

Commit

Permalink
Modify StartLanguageServer to be called conditionally on BufEnter. (
Browse files Browse the repository at this point in the history
#344)

This is related to PR #252

Forcing the filetype `''` to `1` had the side-effect of always enabling
codeium for new empty buffers when using `codeium_filetypes_disabled_by_default`.

Now that we conditionally run `StartLanguageServer` on `BufEnter`, we
don't need to separately call it during startup.
  • Loading branch information
zArubaru authored Mar 28, 2024
1 parent 3cc779d commit bbd6e6f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
3 changes: 0 additions & 3 deletions autoload/codeium.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ function! codeium#Enabled() abort

let codeium_filetypes = s:default_codeium_enabled
call extend(codeium_filetypes, get(g:, 'codeium_filetypes', {}))
" The `''` filetype should be forced to `1`, otherwise codeium may be unable start.
" This is related to the default new empty file not setting a filetype.
call extend(codeium_filetypes, {'': 1})

let codeium_filetypes_disabled_by_default = get(g:, 'codeium_filetypes_disabled_by_default') || get(b:, 'codeium_filetypes_disabled_by_default')

Expand Down
5 changes: 1 addition & 4 deletions plugin/codeium.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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
Expand Down Expand Up @@ -61,10 +62,6 @@ endif

call s:SetStyle()

if codeium#Enabled()
call codeium#command#StartLanguageServer()
endif

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')
Expand Down

0 comments on commit bbd6e6f

Please sign in to comment.