Skip to content
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

Add global entry #626

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lsp-ui-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will prevent the user from using ui-doc without enabling lsp-ui-doc, right? I think this is the goal of lsp-ui-doc-show

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it make sense it shows only when the lsp-ui-doc is enabled. So yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of lsp-ui-doc-show is to be used when automatic lsp-ui-doc is off. This change will allow showing the doc manually only when the automatic popup is enabled which does not make sense.

(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."
Expand Down
3 changes: 3 additions & 0 deletions lsp-ui-peek.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions lsp-ui-sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion lsp-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
Expand Down Expand Up @@ -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