Skip to content

Commit

Permalink
Fix LS port if codeium_port_config is set (#469)
Browse files Browse the repository at this point in the history
* remote check

* fixes

* update doc

---------

Co-authored-by: Saransh Saini <saranshsaini@saransh-mac.office.corp.exafunction.com>
  • Loading branch information
saranshsaini and Saransh Saini authored Nov 19, 2024
1 parent 8c01979 commit 605ab06
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
14 changes: 11 additions & 3 deletions autoload/codeium/server.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if !exists('s:editor_version')
endif

let s:server_port = v:null
if codeium#util#IsUsingRemoteChat()
let s:server_port = 42100
endif

let g:codeium_server_job = v:null

function! s:OnExit(result, status, on_complete_cb) abort
Expand Down Expand Up @@ -266,18 +270,19 @@ function! s:ActuallyStart() abort
let chat_ports = get(g:, 'codeium_port_config', {})
let manager_dir = tempname() . '/codeium/manager'
call mkdir(manager_dir, 'p')

let args = [
\ s:bin,
\ '--api_server_url', get(config, 'api_url', 'https://server.codeium.com'),
\ '--manager_dir', manager_dir,
\ '--enable_local_search', '--enable_index_service', '--search_max_workspace_file_count', '5000',
\ '--enable_chat_web_server', '--enable_chat_client'
\ ]
if has_key(config, 'api_url') && !empty(config.api_url)
let args += ['--enterprise_mode']
let args += ['--portal_url', get(config, 'portal_url', 'https://codeium.example.com')]
endif
if !codeium#util#IsUsingRemoteChat()
let args += ['--manager_dir', manager_dir]
endif
" If either of these is set, only one vim window (with any number of buffers) will work with Codeium.
" Opening other vim windows won't be able to use Codeium features.
if has_key(chat_ports, 'web_server') && !empty(chat_ports.web_server)
Expand All @@ -298,6 +303,9 @@ function! s:ActuallyStart() abort
\ 'err_cb': { channel, data -> codeium#log#Info('[SERVER] ' . data) },
\ })
endif
call timer_start(500, function('s:FindPort', [manager_dir]), {'repeat': -1})
if !codeium#util#IsUsingRemoteChat()
call timer_start(500, function('s:FindPort', [manager_dir]), {'repeat': -1})
endif

call timer_start(5000, function('s:SendHeartbeat', []), {'repeat': -1})
endfunction
5 changes: 5 additions & 0 deletions autoload/codeium/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ function! codeium#util#HasSupportedVersion() abort

return s:nvim_virt_text_support || s:vim_virt_text_support
endfunction

function! codeium#util#IsUsingRemoteChat() abort
let chat_ports = get(g:, 'codeium_port_config', {})
return has_key(chat_ports, 'chat_client') && !empty(chat_ports.chat_client) && has_key(chat_ports, 'web_server') && !empty(chat_ports.web_server)
endfunction
4 changes: 3 additions & 1 deletion doc/codeium.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ g:codeium_port_config
Please note that if this option is set, only one
window will work with codeium.
It is recommended to set both the web_server and chat_client options
if using this.
if using this.
If you are setting this because you are using vim remotely and want chat to work
you will need to forward the two ports you set here, along with port 42100.
That window can have as many buffers within it, but any other
opened windows will not be able to use Codeium's features.
>
Expand Down

0 comments on commit 605ab06

Please sign in to comment.