Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LS port if codeium_port_config is set #469

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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