Skip to content

Commit

Permalink
This allows this plugin to work with codeium enterprise (#36)
Browse files Browse the repository at this point in the history
* fix(server): pass enterprise args correctly to language server

* fix(binary): typo

* fix(binary): fixes #35

Fallback to the GitHub url if the url formed with the given portal is
not valid.

* docs: added instructions for codeium enterprise users
  • Loading branch information
LeonardoMor authored Sep 16, 2024
1 parent 8608ec3 commit 1ad72b9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ a different plugin manager, please refer to its documentation for installation i

Now you can use `Alt-f` in insert mode to accept codeium suggestions.

Enterprise users: you should receive portal and API URLs for Codeium from your company.
Once you get them, add them to your config. This way `:NeoCodeium auth` will authenticate you on the right portal. For example,

````lua
{
"monkoose/neocodeium",
event = "VeryLazy",
opts = {
server = {
api_url = 'https://codeium.company.net/_route/api_server',
portal_url = 'https://codeium.company.net',
},
}
}

**Note:** To obtain an API token, youll need to run `:NeoCodeium auth`.
On Windows WSL `wslview` `(sudo apt install wslu)` should be installed to properly open the browser.

Expand Down
5 changes: 1 addition & 4 deletions lua/neocodeium/binary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ end
---@param callback fun()
function Bin:download(callback)
local base_url = "https://github.com/Exafunction/codeium/releases/download"
if options.server.portal_url then
base_url = options.server.portal_url:gsub("/$", "")
end
---@type url
local url = string.format(
"%s/language-server-v%s/language_server_%s.gz",
Expand All @@ -93,7 +90,7 @@ function Bin:download(callback)
)
end

---Expands langauge server binary from compressed file.
---Expands language server binary from compressed file.
---Returns `true` on success and `false` on failure.
---@return boolean
function Bin:expand()
Expand Down
11 changes: 10 additions & 1 deletion lua/neocodeium/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,20 @@ function Server:start()

local args = {
"--api_server_url",
api_url and api_url .. " --enterprise_mode" or "https://server.codeium.com",
api_url or "https://server.codeium.com",
"--manager_dir",
manager_dir,
}

if options.server.api_url and options.server.api_url ~= "" then
table.insert(args, "--enterprise_mode")
end

if options.server.portal_url and options.server.portal_url ~= "" then
table.insert(args, "--portal_url")
table.insert(args, options.server.portal_url)
end

if self.chat_enabled then
table.insert(args, "--enable_local_search")
table.insert(args, "--enable_index_service")
Expand Down

0 comments on commit 1ad72b9

Please sign in to comment.