-
Notifications
You must be signed in to change notification settings - Fork 197
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
Kill remote process #953
Kill remote process #953
Changes from 7 commits
0bf8079
4e8b04e
9be39c6
b98661e
d53880b
e20666b
7e5ce49
9baf901
e23f3fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ | |
(require 'subr-x) | ||
(require 'markdown-mode) | ||
(require 'diff) | ||
(require 'xref) | ||
|
||
(defvar acm-library-path (expand-file-name "acm" (if load-file-name | ||
(file-name-directory load-file-name) | ||
|
@@ -165,6 +166,11 @@ Setting this to nil or 0 will turn off the heartbeat mechanism." | |
:type 'boolean | ||
:group 'lsp-bridge) | ||
|
||
(defcustom lsp-bridge-remote-enable-kill-process nil | ||
"Whether kill remote lsp-bridge process when Emacs exit ." | ||
:type 'boolean | ||
:group 'lsp-bridge) | ||
|
||
(defcustom lsp-bridge-completion-stop-commands | ||
'("undo-tree-undo" "undo-tree-redo" | ||
"kill-region" "delete-block-backward" | ||
|
@@ -997,6 +1003,11 @@ So we build this macro to restore postion after code format." | |
(lsp-bridge-deferred-chain | ||
(lsp-bridge-epc-call-deferred lsp-bridge-epc-process (read method) args))) | ||
|
||
(defun lsp-bridge-call-sync (method &rest args) | ||
"Call Python EPC function METHOD and ARGS synchronously." | ||
(lsp-bridge-deferred-chain | ||
(lsp-bridge-epc-call-sync lsp-bridge-epc-process (read method) args))) | ||
|
||
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. Don't use this function, it will block Emacs |
||
(defvar-local lsp-bridge-buffer-file-deleted nil) | ||
|
||
(defun lsp-bridge-process-live-p () | ||
|
@@ -1123,6 +1134,8 @@ So we build this macro to restore postion after code format." | |
(defun lsp-bridge--kill-python-process () | ||
"Kill LSP-Bridge background python process." | ||
(when (lsp-bridge-process-live-p) | ||
(when lsp-bridge-remote-enable-kill-process | ||
(lsp-bridge-call-sync "close_client")) | ||
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. Shoud remove those code if code of close_client move to "cleanup" function. And don't use lsp-bridge-call-sync, it will block Emacs. |
||
;; Cleanup before exit LSP-Bridge server process. | ||
(lsp-bridge-call-async "cleanup") | ||
;; Delete LSP-Bridge server process. | ||
|
@@ -1630,8 +1643,9 @@ So we build this macro to restore postion after code format." | |
(list | ||
current-word | ||
(tramp-file-local-name lsp-bridge-remote-file-path) | ||
acm-backend-ctags-max-candidates | ||
(1- (point))))) | ||
(lsp-bridge-call-async "ctags_complete" current-word (buffer-file-name) (1- (point)))))) | ||
(lsp-bridge-call-async "ctags_complete" current-word (buffer-file-name) acm-backend-ctags-max-candidates (1- (point)))))) | ||
|
||
;; Search sdcv dictionary. | ||
(when acm-enable-search-sdcv-words | ||
|
@@ -2132,6 +2146,39 @@ Default is `bottom-right', you can choose other value: `top-left', `top-right', | |
(post-self-insert-hook lsp-bridge-monitor-post-self-insert 90 t) | ||
)) | ||
|
||
(defface lsp-bridge-tag-annotation-face | ||
'((((background light)) | ||
:foreground "#666666" :slant italic) | ||
(t | ||
:foreground "#c0c0c0" :slant italic)) | ||
"Face used for annotations when presenting a tag. | ||
Annotations include kind, type, etc.") | ||
|
||
(defun lsp-bridge-xref--make-object (tag) | ||
"Make xref object of TAG." | ||
(let* ((path (plist-get tag :ext-abspath)) | ||
(line (plist-get tag :line)) | ||
(str (plist-get tag :str)) | ||
(annotation (plist-get tag :annotation))) | ||
(xref-make | ||
(if annotation | ||
(concat (propertize (concat "(" annotation ") ") 'face 'lsp-bridge-tag-annotation-face) str) | ||
str) | ||
(xref-make-file-location path line 0)))) | ||
|
||
(defun lsp-bridge-xref-callback (tags) | ||
(let ((fetcher (lambda () (mapcar #'lsp-bridge-xref--make-object tags)))) | ||
(xref-show-xrefs fetcher nil))) | ||
|
||
(defun lsp-bridge-ctags-find-def-at-point () | ||
(interactive) | ||
(if (lsp-bridge-is-remote-file) | ||
(lsp-bridge-remote-send-func-request "ctags_find_def" | ||
(list | ||
(symbol-at-point) | ||
(file-local-name (buffer-file-name)))) | ||
(lsp-bridge-call-async "ctags_find_def" (symbol-at-point) (buffer-file-name)))) | ||
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. Those code should move to file acm-backend-ctags.el , and rename with acm-backend-ctags-* |
||
|
||
(defvar lsp-bridge-mode-map (make-sparse-keymap)) | ||
|
||
(defvar lsp-bridge-signature-help-timer nil) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -793,12 +793,17 @@ def tabnine_complete(self, before, after, filename, region_includes_beginning, r | |
self.tabnine.complete(before, after, filename, region_includes_beginning, region_includes_end, max_num_results) | ||
|
||
@threaded | ||
def ctags_complete(self, symbol, filename, cursor_offset): | ||
self.ctags.make_complete(symbol, filename, cursor_offset) | ||
def ctags_complete(self, symbol, filename, max_lines, cursor_offset): | ||
self.ctags.make_complete(symbol, filename, max_lines, cursor_offset) | ||
|
||
@threaded | ||
def ctags_find_def(self, symbol, filename): | ||
self.ctags.find_definition(symbol, filename) | ||
|
||
def copilot_complete(self, position, editor_mode, file_path, relative_path, tab_size, text, insert_spaces): | ||
self.copilot.complete(position, editor_mode, file_path, relative_path, tab_size, text, insert_spaces) | ||
|
||
@threaded | ||
def codeium_complete(self, cursor_offset, editor_language, tab_size, text, insert_spaces, prefix, language): | ||
self.codeium.complete(cursor_offset, editor_language, tab_size, text, insert_spaces, prefix, language) | ||
|
||
|
@@ -828,6 +833,11 @@ def handle_server_process_exit(self, server_name): | |
log_time("Exit server {}".format(server_name)) | ||
del LSP_SERVER_DICT[server_name] | ||
|
||
def close_client(self): | ||
for client in self.client_dict.values(): | ||
if hasattr(client, "kill_lsp_bridge_process"): | ||
client.kill_lsp_bridge_process() | ||
|
||
Comment on lines
+836
to
+840
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. Why not add close_client code to function "cleanup" ? |
||
def cleanup(self): | ||
"""Do some cleanup before exit python process.""" | ||
close_epc_client() | ||
|
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.
Above code fix some bug?