From 8c2a3d54d15da0e3ca6f09910e7c4a6a4d4a369b Mon Sep 17 00:00:00 2001 From: Jen-Chieh Date: Thu, 17 Jun 2021 12:33:03 +0800 Subject: [PATCH 1/3] Add doc string --- lsp-ui.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsp-ui.el b/lsp-ui.el index 5b969846..2d39c2bc 100644 --- a/lsp-ui.el +++ b/lsp-ui.el @@ -83,6 +83,7 @@ If the PATH is not in the workspace, it returns the original PATH." path))) (defun lsp-ui--toggle (enable) + "Toggle enable for each lsp-ui module." (dolist (feature '(lsp-ui-peek lsp-ui-sideline lsp-ui-doc lsp-ui-imenu)) (let* ((sym (--> (intern-soft (concat (symbol-name feature) "-enable")) (and (boundp it) it))) @@ -172,6 +173,5 @@ Both should have the form (FILENAME LINE COLUMN)." (cons idx (length refs))) (cons 0 0)))) - (provide 'lsp-ui) ;;; lsp-ui.el ends here From 14d7d101cc46526b860c85bf4b13aca5da0215ed Mon Sep 17 00:00:00 2001 From: Jen-Chieh Date: Thu, 17 Jun 2021 13:01:32 +0800 Subject: [PATCH 2/3] Add global entry --- lsp-ui-doc.el | 10 +++++++--- lsp-ui-imenu.el | 3 +++ lsp-ui-peek.el | 3 +++ lsp-ui-sideline.el | 3 +++ lsp-ui.el | 4 ++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lsp-ui-doc.el b/lsp-ui-doc.el index be1d9567..cd4eb8ee 100644 --- a/lsp-ui-doc.el +++ b/lsp-ui-doc.el @@ -1102,6 +1102,9 @@ If nil, do not prevent mouse on prefix keys.") (remove-hook 'post-command-hook 'lsp-ui-doc--make-request t) (remove-hook 'delete-frame-functions 'lsp-ui-doc--on-delete t)))) +(define-global-minor-mode global-lsp-ui-doc-mode lsp-ui-doc-mode + (lambda () (lsp-ui-doc-mode 1))) + (defun lsp-ui-doc-enable (enable) "Enable/disable ‘lsp-ui-doc-mode’. It is supposed to be called from `lsp-ui--toggle'" @@ -1110,9 +1113,10 @@ It is supposed to be called from `lsp-ui--toggle'" (defun lsp-ui-doc-show () "Trigger display hover information popup." (interactive) - (lsp-ui-doc--callback (lsp-request "textDocument/hover" (lsp--text-document-position-params)) - (or (bounds-of-thing-at-point 'symbol) (cons (point) (1+ (point)))) - (current-buffer))) + (when lsp-ui-doc-mode + (lsp-ui-doc--callback (lsp-request "textDocument/hover" (lsp--text-document-position-params)) + (or (bounds-of-thing-at-point 'symbol) (cons (point) (1+ (point)))) + (current-buffer)))) (defun lsp-ui-doc-hide () "Hide hover information popup." diff --git a/lsp-ui-imenu.el b/lsp-ui-imenu.el index 08d85e34..5e4c18fa 100644 --- a/lsp-ui-imenu.el +++ b/lsp-ui-imenu.el @@ -366,6 +366,9 @@ ITEMS are used when the kind position is 'left." (define-derived-mode lsp-ui-imenu-mode special-mode "lsp-ui-imenu" "Mode showing imenu entries.") +(define-global-minor-mode global-lsp-ui-imenu-mode lsp-ui-imenu-mode + (lambda () (lsp-ui-imenu-mode 1))) + (defun lsp-ui-imenu--refresh () "Safe refresh imenu content." (interactive) diff --git a/lsp-ui-peek.el b/lsp-ui-peek.el index f290c877..38f6252b 100644 --- a/lsp-ui-peek.el +++ b/lsp-ui-peek.el @@ -570,6 +570,9 @@ XREFS is a list of references/definitions." (lsp-ui-peek--deactivate-keymap) (lsp-ui-peek--peek-hide))) +(define-global-minor-mode global-lsp-ui-peek-mode lsp-ui-peek-mode + (lambda () (lsp-ui-peek-mode 1))) + (defun lsp-ui-peek--find-xrefs (input method param) "Find INPUT references. METHOD is ‘references’, ‘definitions’, `implementation` or a custom kind. diff --git a/lsp-ui-sideline.el b/lsp-ui-sideline.el index e86df7a4..3b31125f 100644 --- a/lsp-ui-sideline.el +++ b/lsp-ui-sideline.el @@ -709,6 +709,9 @@ This does not toggle display of flycheck diagnostics or code actions." (when lsp-ui-sideline-show-diagnostics (kill-local-variable 'flycheck-display-errors-function))))) +(define-global-minor-mode global-lsp-ui-sideline-mode lsp-ui-sideline-mode + (lambda () (lsp-ui-sideline-mode 1))) + (defun lsp-ui-sideline-enable (enable) "Enable/disable `lsp-ui-sideline-mode'." (lsp-ui-sideline-mode (if enable 1 -1)) diff --git a/lsp-ui.el b/lsp-ui.el index 2d39c2bc..eda4089e 100644 --- a/lsp-ui.el +++ b/lsp-ui.el @@ -108,6 +108,10 @@ omitted or nil, and toggle it if ARG is ‘toggle’." :keymap lsp-ui-mode-map (lsp-ui--toggle lsp-ui-mode)) +;;;###autoload +(define-global-minor-mode global-lsp-ui-mode lsp-ui-mode + (lambda () (lsp-ui-mode 1))) + ;; The request is delegated to xref-backend-apropos defined in lsp-mode. ;; xref-find-apropos does similar job but is less appealing because it splits and ;; regex quotes the pattern. The language server likely knows more about how From 6965159562723ce43d3e9c2e8affdc372a02d280 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Date: Thu, 17 Jun 2021 13:08:35 +0800 Subject: [PATCH 3/3] Remove global entry for imenu --- lsp-ui-imenu.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/lsp-ui-imenu.el b/lsp-ui-imenu.el index 5e4c18fa..08d85e34 100644 --- a/lsp-ui-imenu.el +++ b/lsp-ui-imenu.el @@ -366,9 +366,6 @@ ITEMS are used when the kind position is 'left." (define-derived-mode lsp-ui-imenu-mode special-mode "lsp-ui-imenu" "Mode showing imenu entries.") -(define-global-minor-mode global-lsp-ui-imenu-mode lsp-ui-imenu-mode - (lambda () (lsp-ui-imenu-mode 1))) - (defun lsp-ui-imenu--refresh () "Safe refresh imenu content." (interactive)