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-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 5b969846..eda4089e 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))) @@ -107,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 @@ -172,6 +177,5 @@ Both should have the form (FILENAME LINE COLUMN)." (cons idx (length refs))) (cons 0 0)))) - (provide 'lsp-ui) ;;; lsp-ui.el ends here