Skip to content

Commit

Permalink
Add copilot to readme and remove copilot agent
Browse files Browse the repository at this point in the history
  • Loading branch information
kongds committed Jul 27, 2023
1 parent f2665bf commit 71827bc
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 652,012 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ lsp-bridge first looks for the content of the first *.pub file in the `~/.ssh` d
- `acm-enable-icon`: Whether the completion menu displays icons (Many macOS users have reported that emacs-plus28 cannot display icons properly, showing colored squares instead. There are two ways to solve this: install Emacs Mac Port or add the `--with-rsvg` option to the brew command when compiling Emacs yourself)
- `acm-enable-tabnine`: Enable tabnine support, enable by default, when enable need execute `lsp-bridge-install-tabnine` command to install TabNine, and it can be used. TabNine will consume huge CPUs, causing your entire computer to be slow. If the computer performance is not good, it is not recommended to enable this option
- `acm-enable-codeium`: Enable Codeium support, when enable need execute `lsp-bridge-install-update-codeium` command to install Codeium, then execute `lsp-bridge-codeium-auth` command to get auth token and execute `lsp-bridge-codeium-input-auth-token` command to get API Key, and it can be used.
- `acm-enable-copilot`: Enable copilot support, when enable need install agent first `npm install -g copilot-node-server`, then execute `lsp-bridge-copilot-auth` command to login, and it can be used.
- `acm-enable-search-file-words`: Whether the complete menu display the word of the file, enable by default
- `acm-enable-quick-access`: Whether to display an index after the icon, quickly select candidate words using Alt + Number, default is off
- `acm-quick-access-use-number-select`: Whether to use number keys for quick selection of candidate words, default is off, turning on this option may sometimes interfere with number input or accidentally select candidate words
Expand Down Expand Up @@ -368,6 +369,7 @@ The following is the directory structure of the lsp-bridge project:
| core/hanlder/ | Implementation of LSP message sending and receiving, where `__init__.py` is the base class. |
| core/tabnine.py | The backend searches and completes with TabNine. |
| core/codeium.py | The backend searches and completes with Codeium. |
| core/copilot.py | The backend searches and completes with Copilot. |
| core/search_file_words.py | Asynchronous search backend for file words. |
| core/search_paths.py | Asynchronous search backend for file paths. |
| core/search_sdcv_words.py | English word search backend, interchangeable with other language’s StarDict dictionaries. |
Expand Down
2 changes: 1 addition & 1 deletion acm/acm.el
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@
(defcustom acm-completion-backend-merge-order '("mode-first-part-candidates"
"template-first-part-candidates"
"tabnine-candidates"
"codeium-candidates"
"copilot-candidates"
"codeium-candidates"
"template-second-part-candidates"
"mode-second-part-candidates")
"The merge order for completion backend."
Expand Down
7 changes: 4 additions & 3 deletions core/copilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def __init__(self):

(self.node_path, ) = get_emacs_vars(["acm-backend-copilot-node-path"])

self.agent_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "resources", "copilot/dist/agent.js")
npm_prefix = subprocess.check_output(['npm', 'config', 'get', 'prefix'], universal_newlines=True).strip()
self.agent_path = os.path.join(f'{npm_prefix}/lib/node_modules', "copilot-node-server", "copilot/dist/agent.js")

self.try_completion_timer = None
self.file_versions = {}
self.counter = 1
Expand Down Expand Up @@ -72,7 +74,6 @@ def start_copilot(self):
self.sender.initialized.set()

editor_info = {'editorInfo': {'name': 'Emacs', 'version': '28.0'},

'editorPluginInfo': {'name': 'lsp-bridge', 'version': '0.0.1'},
'networkProxy': epc_arg_transformer(self.proxy)}
self.sender.send_request('setEditorInfo', editor_info, generate_request_id())
Expand Down Expand Up @@ -186,7 +187,7 @@ def complete(self, position, editor_mode, file_path, relative_path, tab_size, t
}
self.file_versions[file_path] += 1

self.try_completion_timer = threading.Timer(0.5, self.do_complete)
self.try_completion_timer = threading.Timer(0.0, self.do_complete)
self.try_completion_timer.start()

def do_complete(self):
Expand Down
63 changes: 31 additions & 32 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -2215,38 +2215,37 @@ We need exclude `markdown-code-fontification:*' buffer in `lsp-bridge-monitor-be

(defun lsp-bridge-copilot-complete ()
(interactive)
(with-current-buffer lsp-bridge--buffer
(setq-local acm-backend-lsp-fetch-completion-item-ticker nil)
(let ((all-text (buffer-substring-no-properties (point-min) (point-max)))
(relative-path
;; from copilot.el
(cond
((not buffer-file-name)
"")
((fboundp 'projectile-project-root)
(file-relative-name buffer-file-name (projectile-project-root)))
((boundp 'vc-root-dir)
(file-relative-name buffer-file-name (vc-root-dir)))
(t
(file-name-nondirectory buffer-file-name)))))
(if (lsp-bridge-is-remote-file)
(lsp-bridge-remote-send-func-request "copilot_complete"
(list
(lsp-bridge--position)
(symbol-name major-mode)
(buffer-file-name)
relative-path
tab-width
all-text
(not indent-tabs-mode)))
(lsp-bridge-call-async "copilot_complete"
(lsp-bridge--position)
(symbol-name major-mode)
(buffer-file-name)
relative-path
tab-width
all-text
(not indent-tabs-mode)))))
(setq-local acm-backend-lsp-fetch-completion-item-ticker nil)
(let ((all-text (buffer-substring-no-properties (point-min) (point-max)))
(relative-path
;; from copilot.el
(cond
((not buffer-file-name)
"")
((fboundp 'projectile-project-root)
(file-relative-name buffer-file-name (projectile-project-root)))
((boundp 'vc-root-dir)
(file-relative-name buffer-file-name (vc-root-dir)))
(t
(file-name-nondirectory buffer-file-name)))))
(if (lsp-bridge-is-remote-file)
(lsp-bridge-remote-send-func-request "copilot_complete"
(list
(lsp-bridge--position)
(symbol-name major-mode)
(buffer-file-name)
relative-path
tab-width
all-text
(not indent-tabs-mode)))
(lsp-bridge-call-async "copilot_complete"
(lsp-bridge--position)
(symbol-name major-mode)
(buffer-file-name)
relative-path
tab-width
all-text
(not indent-tabs-mode)))))

(defun lsp-bridge-search-backend--record-items (backend-name items)
(pcase backend-name
Expand Down
9 changes: 0 additions & 9 deletions resources/copilot/dist/agent.js

This file was deleted.

46 changes: 0 additions & 46 deletions resources/copilot/dist/agent.js.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion resources/copilot/dist/agent.js.map

This file was deleted.

Loading

0 comments on commit 71827bc

Please sign in to comment.