exafunction / codeium.el Goto Github PK
View Code? Open in Web Editor NEWFree, ultrafast Copilot alternative for Emacs
Home Page: https://www.codeium.com
License: MIT License
Free, ultrafast Copilot alternative for Emacs
Home Page: https://www.codeium.com
License: MIT License
We've had several reports on the Discord and in #20 about this. Currently our theory is that some other completion function is running on non-comment code.
Here are some of the logs in codeium-log
E0322 08:17:09.691283 30886 prompt.go:142] Error checking for empty block node start: UseTreeSitter: astNodeCaseUnspecified or node is null
E0322 08:17:09.691296 30886 prompt.go:150] Failed to determine if multiline completions should be requested.
E0322 08:17:26.507256 30886 prompt.go:478] Error getting sibling functions: UseTreeSitter: no function parent found at offset 26
Is this expected behaviour?
These three errors pretty consistent in my case.
The Emacs package is setup and ready to go. Except, I need to build the codeium language server for my BSD system. Where is it? Or is it closed source?
Unless a user sets tab-width
to 4, codeium autocomplete will mess up the indentation.
Not sure what the optimal fix is, whether dynamically binding tab-width to 4 when on python mode, or using some other mechanism to get the indentation right.
I believe this can be used effectively to store the API key securely: https://www.gnu.org/software/emacs/manual/html_node/auth/Secret-Service-API.html
Hi,
I read the issues and there similar cases to mine like, I can see the completions only in commented line. Those issues are closed but this bug or feature still exist. Is there any solution for this? Thank you!
I use spacemacs, auto-completions, lsp-mode with company. I tried with corfu, cape and it didn't work, not even with commented line. Below is my config.
;; Codeium config stats
;; we recommend using use-package to organize your init.el
(use-package codeium
;; if you use straight
;; :straight '(:type git :host github :repo "Exafunction/codeium.el")
;; otherwise, make sure that the codeium.el file is on load-path
:init
;; use globally
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; or on a hook
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions '(codeium-completion-at-point))))
;; if you want multiple completion backends, use cape (https://github.com/minad/cape):
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions
;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point)))))
;; an async company-backend is coming soon!
;; codeium-completion-at-point is autoloaded, but you can
;; optionally set a timer, which might speed up things as the
;; codeium local language server takes ~0.2s to start up
;; (add-hook 'emacs-startup-hook
;; (lambda () (run-with-timer 0.1 nil #'codeium-init)))
;; :defer t ;; lazy loading, if you want
:config
(setq use-dialog-box nil) ;; do not use popup boxes
;; if you don't want to use customize to save the api-key
(setq codeium/metadata/api_key "--------------------------------------------------------")
;; get codeium status in the modeline
(setq codeium-mode-line-enable
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; alternatively for a more extensive mode-line
;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; you can also set a config for a single buffer like this:
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local codeium/editor_options/tab_size 4)))
;; You can overwrite all the codeium configs!
;; for example, we recommend limiting the string sent to codeium for better performance
(defun my-codeium/document/text ()
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
;; if you change the text, you should also change the cursor_offset
;; warning: this is measured by UTF-8 encoded bytes
(defun my-codeium/document/cursor_offset ()
(codeium-utf8-byte-length
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
(setq codeium/document/text 'my-codeium/document/text)
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset))
;;;
;;;
(use-package company
:diminish
:bind (("C-M-i" . company-complete)
:map company-mode-map
("<backtab>" . company-yasnippet))
:bind (:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous)
("C-s" . company-filter-candidates)
("<tab>" . company-complete-selection))
:bind (:map company-search-map
("C-n" . company-select-next)
("C-p" . company-select-previous))
:hook (after-init . global-company-mode)
:init
;;:config
(global-company-mode t)
(setq company-tooltip-align-annotations t
company-tooltip-limit 12
company-idle-delay 0.05
company-echo-delay (if (display-graphic-p) nil 0)
company-minimum-prefix-length 0
company-icon-margin 3
company-require-match nil
company-dabbrev-ignore-case nil
company-dabbrev-downcase nil
;;; get only preview
company-frontends '(company-preview-frontend)
;;; also get a drop down
company-frontends '(company-pseudo-tooltip-frontend company-preview-frontend)
company-global-modes '(not erc-mode message-mode help-mode
gud-mode eshell-mode shell-mode)
company-backends '((company-capf :with company-yasnippet)
''(company-dabbrev-code company-keywords company-files)
company-dabbrev)))
;;;
How can I use use-package
to install this package?
I don't have any information yet on how to reproduce this other than leave VSCode open with 2 or 3 windows for ~30 minutes and observe 100% memory usage from language_server_windows_x64.exe.
Latest version of Codeium for VSCode.
Version: 1.84.2 (system setup)
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:51:52.184Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
To obtain a token from password store, you can use the following snippet of code:
(with-eval-after-load 'codeium
(require 'auth-source)
(setq-default
codeium/metadata/api_key
(funcall (plist-get
(nth 0 (auth-source-search :host "codeium.ai"))
:secret))))
Probably it should be a better implementation or support on codeium side.
I don't know if this is an issue that I should open at corfu
, but at my end every now and then I get a popup with "no match" and have to manually "C-g" to make the suggestion window disappear.
I wonder if there is a way to not have completions be triggered unless there are actually completions available?
I've been struggling to get this running with the setup mentioned in the README.
I use Doom Emacs with Company.
(package! codeium :recipe (:host github :repo "Exafunction/codeium.el"))
Added the above line in my packages.el
Copy pasted the configuration present in the README
Codeium-install
-> entered key
I0414 14:55:36.426776 76025 main.go:357] Starting language server manager with pid 76025
I0414 14:55:36.427200 76025 main.go:84] Manager acquired its lock file /var/folders/1l/5st2hg4d5sd9khj60jw4z7gr0000gp/T/codeium_pUPOXk/locks/manager.lock
I0414 14:55:36.428929 76025 main.go:199] Waiting for random port file in /var/folders/1l/5st2hg4d5sd9khj60jw4z7gr0000gp/T/codeium_pUPOXk/child_random_port_1681476936427253000_3120209764782295776 to be created
I0414 14:55:36.457829 76026 main.go:351] Starting language server process with pid 76026
I0414 14:55:36.470939 76026 proxy.go:42] proxyplease.proxy> No proxy provided. Attempting to infer from system.
2023/04/14 14:55:36 [proxy.Provider.readDarwinNetworkSettingProxy]: Automatic proxy is not enabled.
2023/04/14 14:55:36 [proxy.Provider.readDarwinNetworkSettingProxy]: https proxy is not enabled.
I0414 14:55:36.489102 76026 proxy.go:42] proxyplease.proxy> No proxy could be determined. Assuming a direct connection.
I0414 14:55:36.489130 76026 api_server_client.go:78] Successfully dialed proxy
I0414 14:55:36.489186 76026 server.go:244] Successfully created API server client
I0414 14:55:36.495830 76026 server.go:251] Successfully initialized tokenizer
I0414 14:55:36.495864 76026 server.go:258] Successfully created completion provider
I0414 14:55:36.495885 76026 server.go:356] Child process attempting to acquire lock file /var/folders/1l/5st2hg4d5sd9khj60jw4z7gr0000gp/T/codeium_pUPOXk/locks/child_lock_1681476936427326000_3231162659028036798
I0414 14:55:36.495909 76026 unleash.go:58] Initializing Unleash with production environment
I0414 14:55:36.496017 76026 server.go:366] Child process acquired lock file /var/folders/1l/5st2hg4d5sd9khj60jw4z7gr0000gp/T/codeium_pUPOXk/locks/child_lock_1681476936427326000_3231162659028036798
I0414 14:55:36.496214 76026 server.go:136] Language server will attempt to listen on host 127.0.0.1
I0414 14:55:36.496367 76026 server.go:172] Language server listening on random port at 56343
I0414 14:55:36.530251 76025 main.go:230] Language server manager found random port 56343
I0414 14:55:36.530276 76025 main.go:237] Language server manager attempting to connect to language server at 127.0.0.1:56343
I0414 14:55:36.543575 76025 main.go:118] Fixing language server port at 56343
I0414 14:55:36.543588 76025 main.go:283] Language server manager successfully connected to new language server at 127.0.0.1:56343
http://localhost:56343/exa.language_server_pb.LanguageServerService/Heartbeat 0.04 secs status: 200
I0414 14:55:36.904152 76026 unleash.go:73] Successfully initialized unleash
http://localhost:56343/exa.language_server_pb.LanguageServerService/Heartbeat 0.00 secs status: 200
https://github.com/Exafunction/codeium/releases/download/language-server-v1.1.60/language_server_macos_arm.gz 2.47 secs status: 200
http://localhost:56343/exa.language_server_pb.LanguageServerService/Heartbeat 0.00 secs status: 200
http://localhost:56343/exa.language_server_pb.LanguageServerService/Heartbeat 0.00 secs status: 200
codeium state: default
command:
/Users/surya/.emacs.d/.local/cache/codeium/codeium_language_server --api_server_host server.codeium.com --api_server_port 443 --manager_dir /var/folders/1l/5st2hg4d5sd9khj60jw4z7gr0000gp/T/codeium_59agcQ
GetCompletions
http://localhost:57191/exa.language_server_pb.LanguageServerService/GetCompletions
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.60"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id 2
codeium/metadata/api_key "232f6ce9-211d-40bb-ae8c-3d1a5528218c"
codeium/document/text "I0414 14:55:36.426776 76025 main.go:357] Starting language server manager with pid 76025\nI0414 14:55..."
codeium/document/cursor_offset 0
codeium/document/editor_language "special-mode"
codeium/document/language 0
codeium/document/line_ending "\n"
codeium/editor_options/tab_size 4
codeium/editor_options/insert_spaces t
Heartbeat
http://localhost:57191/exa.language_server_pb.LanguageServerService/Heartbeat
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.60"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id nil
codeium/metadata/api_key "232f6ce9-211d-40bb-ae8c-3d1a5528218c"
CancelRequest
http://localhost:57191/exa.language_server_pb.LanguageServerService/CancelRequest
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.60"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id nil
codeium/request_id nil
codeium/metadata/api_key "232f6ce9-211d-40bb-ae8c-3d1a5528218c"
GetAuthToken
http://localhost:57191/exa.language_server_pb.LanguageServerService/GetAuthToken
RegisterUser
http://localhost:57191/exa.language_server_pb.LanguageServerService/RegisterUser
codeium/firebase_id_token nil
auth-redirect
http://localhost:57191/auth
AcceptCompletion
http://localhost:57191/exa.language_server_pb.LanguageServerService/AcceptCompletion
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.60"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id nil
codeium/completion_id nil
codeium/metadata/api_key "232f6ce9-211d-40bb-ae8c-3d1a5528218c"
Start seeing suggestions as I type code.
side by side view of the code and the codeium-logs
When using an OS like Guix or Nix, the downloaded "codeium_language_server" binary cannot execute due to libraries not being stored in /lib. I can run the local binary in a container where the libraries do exist in /lib with guix shell -CNF nss-certs -- ./codeium_language_server
. (This command places glibc in /lib and allows the container to share the parent environment's networking setup.)
However, I cannot feed this shell command into the codeium-command-executable
variable, as it results in an error saying it is "not a valid executable."
I've tried making a launcher shell script with this command and passing it to the codeium-command-executable
variable, and I no longer receive any errors, but I do not see any sign of any completions, the package working, or any log messages. I would expect for the auth process to begin, but nothing ever appears in the message buffer. If I examine ps aux | grep cod
, I can see the process is running somewhere.
Any thoughts about how to successfully authenticate with the binary running in this manner?
--
I get this output in stdout when running my launcher script:
I0217 22:06:39.515235 1 main.go:346] Starting language server manager with pid 1
I0217 22:06:39.515841 1 main.go:228] Language server manager attempting to connect to language server at 127.0.0.1:42100
I0217 22:06:39.540629 13 main.go:340] Starting language server process with pid 13
I0217 22:06:39.541218 13 server.go:190] Successfully created API server client
I0217 22:06:39.549482 13 server.go:197] Successfully initialized tokenizer
I0217 22:06:39.549507 13 server.go:204] Successfully created completion provider
I0217 22:06:39.549512 13 server.go:217] Child process attempting to acquire lock file /tmp/child_lock_1676671599515472344_173301945805043158
I0217 22:06:39.549537 13 server.go:227] Child process acquired lock file /tmp/child_lock_1676671599515472344_173301945805043158
I0217 22:06:39.549657 13 server.go:106] Language server will attempt to listen on host 127.0.0.1
I0217 22:06:39.549774 13 server.go:129] Language server listening on fixed port at 42100
I0217 22:06:39.549616 13 unleash.go:58] proxyplease.proxy> No proxy provided. Attempting to infer from system.
I0217 22:06:39.549811 13 unleash.go:58] proxyplease.proxy> No proxy could be determined. Assuming a direct connection.
I0217 22:06:39.549821 13 unleash.go:61] Initializing Unleash with production environment
I0217 22:06:39.559114 1 main.go:274] Language server manager successfully connected to new language server at 127.0.0.1:42100
I0217 22:06:39.765435 13 unleash.go:76] Successfully initialized unleash
This looks good, right?
Linux 6.6.1-artix1-1
GNU Emacs 29.1
Language Server 1.6.9
After setting up with company
, and obtaining the API token, each autocomplete attempt yields a
Username [for http://127.0.0.1:37621/exa.language_server_pb.LanguageServerService/GetCompletions]:
and subsequent password prompt.
Using the codeium.com credentials does not work.
What am I supposed to enter here?
I believe that I successfully followed the clear installation instructions. I did no custom configuration.
I tested the installation by grabbing the Python and C++ cases from the online Codeium playground.
I found that:
Is there something that I need to configure here?
I use emacs in WSL and get:
Error running timer ‘codeium-defer-until-no-input’: (error "No usable browser found")
Any way to go around it?
It would be a nice feature to have
I use this on linux with vscode and it rocks, but would like to have it run on my desktop which is OpenBSD. Any chance of providing support for it?
I use Emacs in WSL2 with Ubuntu, and I follow the README to config codeium.
Here is my config:
;;; init-codeium.el --- codeium config
;;; Commentary:
;;; Code:
(push (expand-file-name "lisp/my-lisp/codeium" user-emacs-directory) load-path)
(require 'codeium)
(with-eval-after-load 'codeium
;; codeium-completion-at-point is autoloaded, but you can
;; optionally set a timer, which might speed up things as the
;; codeium local language server takes ~0.2s to start up
(add-hook 'emacs-startup-hook
(lambda () (run-with-timer 0.1 nil #'codeium-init)))
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; get codeium status in the modeline
(setq codeium-mode-line-enable
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; alternatively for a more extensive mode-line
;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; You can overwrite all the codeium configs!
;; for example, we recommend limiting the string sent to codeium for better performance
(defun my-codeium/document/text ()
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
(setq codeium/document/text 'my-codeium/document/text))
(provide 'init-codeium)
;;; init-codeium.el ends here
and my Emacs version:
GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2022-12-13
In Emacs, when I call codeium-init
, it will open Chrome and visit codeium try to get auth_token
.
But after I call codeium-init
, it shows an error message immediately :
you can also use M-x codeium-kill-last-auth-url to copy the codeium login url
Error running timer ‘codeium-defer-until-no-input’: (error "cannot get auth_token from res")
For everytime call codeium-init
, there is a log said: 'no status available' :
After removing http_proxy and https_proxy, it keeps waiting for a response:
It will open chrome installed on windows, and codeium is installed in WSL, is there some communication issue between chrome and codeium ?
Or Is something wrong with the network? Or can I visit the auth URL and set auth_token
manually ?
windows11,idea2023.2.3,codeium 1.2.4
I found the target file on the disk "C:\Users\user1\AppData\Roaming\JetBrains\IntelliJIdea2023.2\plugins\codeium\a3052dba993afbbe90c01c0591b1f5dc198b5158\language_server_windows_x64.exe"
But the plugin alerted me that Language server port file not found after 60 seconds
I'm using doom emacs.
packages.el
:
(package! codeium :recipe (:host github :repo "Exafunction/codeium.el"))
config.el
:
;; we recommend using use-package to organize your init.el
(use-package codeium
;; if you use straight
;; :straight '(:type git :host github :repo "Exafunction/codeium.el")
;; otherwise, make sure that the codeium.el file is on load-path
:init
;; use globally
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; or on a hook
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions '(codeium-completion-at-point))))
;; if you want multiple completion backends, use cape (https://github.com/minad/cape):
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions
;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point)))))
;; an async company-backend is coming soon!
;; codeium-completion-at-point is autoloaded, but you can
;; optionally set a timer, which might speed up things as the
;; codeium local language server takes ~0.2s to start up
;; (add-hook 'emacs-startup-hook
;; (lambda () (run-with-timer 0.1 nil #'codeium-init)))
;; :defer t ;; lazy loading, if you want
:config
(setq use-dialog-box nil) ;; do not use popup boxes
;; if you don't want to use customize to save the api-key
;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
;; get codeium status in the modeline
(setq codeium-mode-line-enable
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; alternatively for a more extensive mode-line
;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; you can also set a config for a single buffer like this:
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local codeium/editor_options/tab_size 4)))
;; You can overwrite all the codeium configs!
;; for example, we recommend limiting the string sent to codeium for better performance
(defun my-codeium/document/text ()
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
;; if you change the text, you should also change the cursor_offset
;; warning: this is measured by UTF-8 encoded bytes
(defun my-codeium/document/cursor_offset ()
(codeium-utf8-byte-length
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
(setq codeium/document/text 'my-codeium/document/text)
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset))
(use-package company
:defer 0.1
:config
(global-company-mode t)
(setq-default
company-idle-delay 0.05
company-require-match nil
company-minimum-prefix-length 0
;; get only preview
company-frontends '(company-preview-frontend)
;; also get a drop down
;; company-frontends '(company-pseudo-tooltip-frontend company-preview-frontend)
))
M-x codeium-install
yields execute-extended-command: Cannot open load file: No such file or directory, codeium
There is no codeium error log.
Codeium Chat thought there already was a codeium chat option in codeium.el!
Human: How can I use Codeium chat inside of Emacs?
Codeium Chat: To use Codeium chat inside of Emacs, you can install the Codeium extension for Emacs. First, make sure you have MELPA set up, then use M-x package-install RET codeium RET to install it. After installation, you can use M-x codeium-chat-start to start the chat interface.
Be nice to make it so Codeium Chat was right and it was part of codeium.el!
Thanks!
Hello all,
trying to play around with this awesome software, bad it doesn't work in C++
mode with lsp
enabled.
A snippet of the .emacs
can be found https://gist.github.com/apmanol/6ab0bb12174d3f1fc9b7b2ff1e4fa909 it's a setup with lsp + company + company lsp
.
The server seems to work as it seems in the logs and in the diagnose
but autocomplete doesn't work.
Furthermore, without lsp mode
i.e. scratch, I can see suggestions and server communication.
completion-at-point-functions is a variable defined in ‘minibuffer.el’.
Its value is
(codeium-completion-at-point tags-completion-at-point-function)
Probably, I miss something, but I can't find out anything.
thanks for any tips.
my config:
(use-package codeium
:ensure nil
:quelpa (codeium :fetcher github :repo "Exafunction/codeium.el")
:init
;; use globally
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
:config
(setq use-dialog-box t ;; do not use popup boxes
codeium-mode-line t)
;; if you don't want to use customize to save the api-key
;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
;; get codeium status in the modeline
(setq codeium-mode-line-enable
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; alternatively for a more extensive mode-line
;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; you can also set a config for a single buffer like this:
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local codeium/editor_options/tab_size 4)))
;; You can overwrite all the codeium configs!
;; for example, we recommend limiting the string sent to codeium for better performance
(defun my-codeium/document/text ()
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
;; if you change the text, you should also change the cursor_offset
;; warning: this is measured by UTF-8 encoded bytes
(defun my-codeium/document/cursor_offset ()
(codeium-utf8-byte-length
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
(setq codeium/document/text 'my-codeium/document/text)
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset))
M-x: codeium-install
M-x: codeium-init
but it's not working.
This is my config:
(use-package codeium
:load-path "~/.emacs.d/lisp/codeium.el"
:init
(add-hook 'prog-mode-hook
(lambda ()
(setq-local completion-at-point-functions '(codeium-completion-at-point))))
:defer t
:config
(setq use-dialog-box nil) ;; do not use popup boxes
;; get codeium status in the modeline
(setq codeium-mode-line-enable
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; alternatively for a more extensive mode-line
;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; You can overwrite all the codeium configs!
;; for example, we recommend limiting the string sent to codeium for better performance
(defun my-codeium/document/text ()
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
;; if you change the text, you should also change the cursor_offset
;; warning: this is measured by UTF-8 encoded bytes
(defun my-codeium/document/cursor_offset ()
(codeium-utf8-byte-length
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
(setq codeium/document/text 'my-codeium/document/text)
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset))
This somehow doesn't load codeium, I had to explicitly require it:
(require 'codeium)
Afterwards I ran M-x codeium-init
and M-x codeium-install
. I never was asked for an API key or was redirected to a URL.
I don't get any completions anymore. Editing a file is incredibly slow, my input is delayed very noticeably.
This error gets printed into *codeium-log*
several times per second:
/snap/emacs/1808/usr/bin/emacs: /home/fap/.emacs.d/codeium/codeium_language_server: No such file or directory
Process codeium exited abnormally with code 127
But the file exists:
$ file ~/.emacs.d/codeium/codeium_language_server
/home/fap/.emacs.d/codeium/codeium_language_server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, interpreter /ld-linux-x86-64.so.2, missing section headers
Output of codeium-diagnose
:
codeium state: default
command:
/home/fap/.emacs.d/codeium/codeium_language_server --api_server_host server.codeium.com --api_server_port 443 --manager_dir /tmp/codeium_hquefa
GetCompletions
http://localhost/exa.language_server_pb.LanguageServerService/GetCompletions
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.38"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id 6
codeium/metadata/api_key nil
codeium/document/text "re t\n :after geiser-mode\n :config (add-hook 'geiser-mode-hook #'macrostep-geiser-setup))\n\n(use-pac..."
codeium/document/cursor_offset 3000
codeium/document/editor_language "emacs-lisp-mode"
codeium/document/language 60
codeium/document/line_ending "\n"
codeium/editor_options/tab_size 4
codeium/editor_options/insert_spaces t
Heartbeat
http://localhost/exa.language_server_pb.LanguageServerService/Heartbeat
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.38"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id nil
codeium/metadata/api_key nil
CancelRequest
http://localhost/exa.language_server_pb.LanguageServerService/CancelRequest
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.38"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id nil
codeium/request_id nil
codeium/metadata/api_key nil
GetAuthToken
http://localhost/exa.language_server_pb.LanguageServerService/GetAuthToken
RegisterUser
http://localhost/exa.language_server_pb.LanguageServerService/RegisterUser
codeium/firebase_id_token nil
auth-redirect
http://localhost/auth
AcceptCompletion
http://localhost/exa.language_server_pb.LanguageServerService/AcceptCompletion
codeium/metadata/ide_name "emacs"
codeium/metadata/extension_version "1.1.38"
codeium/metadata/ide_version "28.2"
codeium/metadata/request_id nil
codeium/completion_id nil
codeium/metadata/api_key nil
Emacs Version:
GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2023-01-30
Let me know if you need any other information.
Using Doom Emacs (latest version using doom upgrade) and Emacs 29.0.91
In packages.el: (package! codeium :recipe (:host github :repo Exafunction/codeium.el"))
In config.el:
;; we recommend using use-package to organize your init.el
(use-package codeium
;; if you use straight
;; :straight '(:type git :host github :repo "Exafunction/codeium.el")
;; otherwise, make sure that the codeium.el file is on load-path
:init
;; use globally
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; or on a hook
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions '(codeium-completion-at-point))))
;; if you want multiple completion backends, use cape (https://github.com/minad/cape):
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions
;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point)))))
;; an async company-backend is coming soon!
;; codeium-completion-at-point is autoloaded, but you can
;; optionally set a timer, which might speed up things as the
;; codeium local language server takes ~0.2s to start up
;; (add-hook 'emacs-startup-hook
;; (lambda () (run-with-timer 0.1 nil #'codeium-init)))
;; :defer t ;; lazy loading, if you want
:config
(setq use-dialog-box nil) ;; do not use popup boxes
;; if you don't want to use customize to save the api-key
;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
;; get codeium status in the modeline
(setq codeium-mode-line-enable
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; alternatively for a more extensive mode-line
;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t)
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; you can also set a config for a single buffer like this:
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local codeium/editor_options/tab_size 4)))
;; You can overwrite all the codeium configs!
;; for example, we recommend limiting the string sent to codeium for better performance
(defun my-codeium/document/text ()
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
;; if you change the text, you should also change the cursor_offset
;; warning: this is measured by UTF-8 encoded bytes
(defun my-codeium/document/cursor_offset ()
(codeium-utf8-byte-length
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
(setq codeium/document/text 'my-codeium/document/text)
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset))
Trying this out, the completion system does something, but I cannot accept it the completion nor can I view it. It only appears in normal mode (nothing during insert mode).
I have tried quite a few keybinds to try and accept the suggestions. Any tips or feedback on anything I did wrong?
Elpy.el is one of the premier Emacs extensions for Python, which a lot of new Python devs in Emacs may be using.
If they, like me, encountered an issue where /when Elpy is enabled, the Codeium.el company integration does not work/, they will need to prevent Elpy from removing their Codeium.el company-capf
backend.
Cause: When Elpy is running, if it has it's "Company Module" enabled, this section of code will remove the company-capf
backend to prevent "unwanted interference" with the elpy-company-backend:
https://github.com/jorgenschaefer/elpy/blob/7ff8ffa918411887d165764f7a5a12bc46646e73/elpy.el#L2820
To avoid this, one can add the company-capf
backend back into their company-backends
buffer-local-variable, in a python hook, at a high-priority (e.g. 99). This way, Elpy will remove the company-capf
, but then the new hook will just add it back. And it will be at the front of the list, so that Codeium.el gets highest company backend priority (runs first). Though I think this will stop most of the elpy suggestions which may not be ideal.
Using the example from the Readme.md of this project:
;; we recommend using use-package to organize your init.el
(use-package codeium
;; if you use straight
;; :straight '(:type git :host github :repo "Exafunction/codeium.el")
;; otherwise, make sure that the codeium.el file is on load-path
:init
;; use globally
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; or on a hook
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions '(codeium-completion-at-point))
;; <---------- Begin modified section ------------>
(setq-local company-backends (cons 'company-capf company-backends))) ;;Add capf to front of company-backends list
99) ;;set the priority to highest.
I hope this helps anyone who may have this issue!
I understand that you can use cape as well and that may be a better solution.
My suggestion is to add a note to this README.md that specifies that this may happen to avoid troubleshooting confusion. Thanks for the awesome emacs extension, Codeium developers!
Not sure if it's my hardware or just the implementation of codeium in emacs but with the default config the completions come in very slowly, and sometimes I feel like if they do come in they never get suggested to me, the issue with speed arose when I saw a friend use codeium in pycharm and it was blazing fast.
Attempting to generate a factorial func:
// Factorial returns an int that equals n!.
func Fact
...returns:
func factorial(n int) int {
}
I've managed to start codeium with company using akhil3417's suggestion in #20
It fails fast though, I've encountered 2 types of errors in log:
E0501 13:29:51.913056 1465117 prompt.go:142] Error checking for empty block node start: UseTreeSitter: no start keyword children found
E0501 13:29:51.913079 1465117 prompt.go:150] Failed to determine if multiline completions should be requested.
And
E0501 13:33:33.260453 1477885 prompt.go:478] Error getting sibling functions: UseTreeSitter: no function parent found at offset 1332
I'm not sure where they come from (are they built-in to emacs in earlier versions of emacs?) or if they came from an outside library, but... Yeah, I can't get the API key right now.
Need to add all the tree-sitter modes as well as many other language modes
I tried to use codeium.el on a python-ts-mode buffer, but no completions show up, and *codeium-log*
contains:
I0218 02:17:23.152879 28034 document.go:89] Unspecified language received enry language
E0218 02:17:23.152896 28034 document.go:94] Unable to resolve enry language
When I turned on python-mode, it works fine. I suppose codeium.el could be amended:
Lines 206 to 212 in 094b3cc
(The default value of this list seems surprisingly limited!)
codeium
cycle completions alongside with GitHub Copilot?I'm using GitHub Copilot right now, and I want to use codeium cycle completions alongside with it.
The Copilot extension I'm using is https://github.com/zerolfx/copilot.el.
How can I make it? Thanks
After installing manually, because MELPA doesn't have Codeium and I am unaware of any other package installation which does, I attempted to perform M-x codeium-install
. Emacs does not recognize codeium-install
.
What are the instructions missing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.