-
Notifications
You must be signed in to change notification settings - Fork 204
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
support copilot #688
Merged
Merged
support copilot #688
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
;;; acm-backend-copilot.el --- Description -*- lexical-binding: t; -*- | ||
;; | ||
;; Copyright (C) 2023 royokong | ||
;; | ||
;; Author: royokong <[email protected]> | ||
;; Maintainer: royokong <[email protected]> | ||
;; Created: 七月 22, 2023 | ||
;; Modified: 七月 22, 2023 | ||
;; Version: 0.0.1 | ||
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp | ||
;; Homepage: https://github.com/royokong/acm-backend-copilot | ||
;; Package-Requires: ((emacs "24.3")) | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; Commentary: | ||
;; | ||
;; Description | ||
;; | ||
;;; Code: | ||
|
||
(defcustom acm-enable-copilot nil | ||
"Enable copilot support." | ||
:type 'boolean | ||
:group 'acm-backend-copilot) | ||
|
||
(defcustom acm-backend-copilot-node-path "node" | ||
"The path to store Codeium API Key." | ||
:type 'string | ||
:group 'acm-backend-copilot) | ||
|
||
(defcustom acm-backend-copilot-accept nil | ||
"Send accept request." | ||
:type 'boolean | ||
:group 'acm-backend-copilot) | ||
|
||
(defcustom acm-backend-copilot-network-proxy nil | ||
" from `copilot.el' | ||
Network proxy to use for Copilot. Nil means no proxy. | ||
Format: '(:host \"127.0.0.1\" :port 80 :username \"username\" :password \"password\") | ||
Username and password are optional. | ||
|
||
If you are using a MITM proxy which intercepts TLS connections, you may need to disable | ||
TLS verification. This can be done by setting a pair ':rejectUnauthorized :json-false' | ||
in the proxy plist. For example: | ||
|
||
(:host \"127.0.0.1\" :port 80 :rejectUnauthorized :json-false) | ||
" | ||
:type '(plist :tag "Uncheck all to disable proxy" :key-type symbol) | ||
:options '((:host string) (:port integer) (:username string) (:password string)) | ||
:group 'acm-backend-copilot) | ||
|
||
|
||
(defvar-local acm-backend-copilot-items nil) | ||
|
||
(defun acm-backend-copilot-check-node-version () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个函数好像没用到?建议在 Python 里检查 node 版本。 |
||
(and (locate-file acm-backend-copilot-node-path exec-path) | ||
;; following copilot.el to check node version only >= 16 | ||
(>= (->> (with-output-to-string | ||
(call-process acm-backend-copilot-node-path nil standard-output nil "--version")) | ||
(s-trim) | ||
(s-chop-prefix "v") | ||
(string-to-number)) 16))) | ||
|
||
(defun acm-backend-copilot-candidates (keyword) | ||
acm-backend-copilot-items) | ||
|
||
|
||
(defun acm-backend-copilot-candidate-expand (candidate-info bound-start &optional preview) | ||
;; We need replace whole area with copilot label. | ||
(let ((end-position (line-end-position))) | ||
(forward-line (- (plist-get candidate-info :line) (count-lines (point-min) (line-beginning-position)))) | ||
(if preview | ||
(acm-preview-create-overlay (point) end-position (plist-get candidate-info :label)) | ||
(delete-region (point) end-position) | ||
(insert (plist-get candidate-info :label)) | ||
(when acm-backend-copilot-accept | ||
(lsp-bridge-call-async | ||
"copilot_completion_accept" (plist-get candidate-info :id)))))) | ||
|
||
(defun acm-backend-copilot-candidate-doc (candidate) | ||
(plist-get candidate :documentation)) | ||
|
||
(provide 'acm-backend-copilot) | ||
;;; acm-backend-copilot.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释忘记改了?