diff --git a/autoload/codeium/server.vim b/autoload/codeium/server.vim index ff9c1c49..7e624783 100644 --- a/autoload/codeium/server.vim +++ b/autoload/codeium/server.vim @@ -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 @@ -266,11 +270,9 @@ 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' \ ] @@ -278,6 +280,9 @@ function! s:ActuallyStart() abort 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) @@ -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 diff --git a/autoload/codeium/util.vim b/autoload/codeium/util.vim index 3d91a446..48eae30b 100644 --- a/autoload/codeium/util.vim +++ b/autoload/codeium/util.vim @@ -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 diff --git a/doc/codeium.txt b/doc/codeium.txt index c87b9122..5c33c70d 100644 --- a/doc/codeium.txt +++ b/doc/codeium.txt @@ -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. >