Skip to content

Commit 605ab06

Browse files
saranshsainiSaransh Saini
and
Saransh Saini
authored
Fix LS port if codeium_port_config is set (#469)
* remote check * fixes * update doc --------- Co-authored-by: Saransh Saini <[email protected]>
1 parent 8c01979 commit 605ab06

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

autoload/codeium/server.vim

+11-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ if !exists('s:editor_version')
2525
endif
2626

2727
let s:server_port = v:null
28+
if codeium#util#IsUsingRemoteChat()
29+
let s:server_port = 42100
30+
endif
31+
2832
let g:codeium_server_job = v:null
2933

3034
function! s:OnExit(result, status, on_complete_cb) abort
@@ -266,18 +270,19 @@ function! s:ActuallyStart() abort
266270
let chat_ports = get(g:, 'codeium_port_config', {})
267271
let manager_dir = tempname() . '/codeium/manager'
268272
call mkdir(manager_dir, 'p')
269-
270273
let args = [
271274
\ s:bin,
272275
\ '--api_server_url', get(config, 'api_url', 'https://server.codeium.com'),
273-
\ '--manager_dir', manager_dir,
274276
\ '--enable_local_search', '--enable_index_service', '--search_max_workspace_file_count', '5000',
275277
\ '--enable_chat_web_server', '--enable_chat_client'
276278
\ ]
277279
if has_key(config, 'api_url') && !empty(config.api_url)
278280
let args += ['--enterprise_mode']
279281
let args += ['--portal_url', get(config, 'portal_url', 'https://codeium.example.com')]
280282
endif
283+
if !codeium#util#IsUsingRemoteChat()
284+
let args += ['--manager_dir', manager_dir]
285+
endif
281286
" If either of these is set, only one vim window (with any number of buffers) will work with Codeium.
282287
" Opening other vim windows won't be able to use Codeium features.
283288
if has_key(chat_ports, 'web_server') && !empty(chat_ports.web_server)
@@ -298,6 +303,9 @@ function! s:ActuallyStart() abort
298303
\ 'err_cb': { channel, data -> codeium#log#Info('[SERVER] ' . data) },
299304
\ })
300305
endif
301-
call timer_start(500, function('s:FindPort', [manager_dir]), {'repeat': -1})
306+
if !codeium#util#IsUsingRemoteChat()
307+
call timer_start(500, function('s:FindPort', [manager_dir]), {'repeat': -1})
308+
endif
309+
302310
call timer_start(5000, function('s:SendHeartbeat', []), {'repeat': -1})
303311
endfunction

autoload/codeium/util.vim

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ function! codeium#util#HasSupportedVersion() abort
88

99
return s:nvim_virt_text_support || s:vim_virt_text_support
1010
endfunction
11+
12+
function! codeium#util#IsUsingRemoteChat() abort
13+
let chat_ports = get(g:, 'codeium_port_config', {})
14+
return has_key(chat_ports, 'chat_client') && !empty(chat_ports.chat_client) && has_key(chat_ports, 'web_server') && !empty(chat_ports.web_server)
15+
endfunction

doc/codeium.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ g:codeium_port_config
118118
Please note that if this option is set, only one
119119
window will work with codeium.
120120
It is recommended to set both the web_server and chat_client options
121-
if using this.
121+
if using this.
122+
If you are setting this because you are using vim remotely and want chat to work
123+
you will need to forward the two ports you set here, along with port 42100.
122124
That window can have as many buffers within it, but any other
123125
opened windows will not be able to use Codeium's features.
124126
>

0 commit comments

Comments
 (0)