Skip to content
Merged
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
60 changes: 15 additions & 45 deletions lsp-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,8 @@
;;; Code:

(require 'dash)
(require 'find-func)
(require 'face-remap)

(require 'lsp-protocol)

;;
;;; Util

(defmacro lsp-ui--mute-apply (&rest body)
"Execute BODY without message."
(declare (indent 0) (debug t))
`(let (message-log-max)
(with-temp-message (or (current-message) nil)
(let ((inhibit-message t)) ,@body))))

(defmacro lsp-ui--with-no-redisplay (&rest body)
"Execute BODY without any redisplay execution."
(declare (indent 0) (debug t))
`(let ((inhibit-redisplay t)
(inhibit-modification-hooks t)
(inhibit-point-motion-hooks t)
buffer-list-update-hook
display-buffer-alist
window-configuration-change-hook
after-focus-change-function)
,@body))

(defun lsp-ui-kill-timer (timer)
"Safely kill the TIMER."
(when (timerp timer) (cancel-timer timer)))

(defun lsp-ui-delete-overlay (overlay)
"Safely delete the OVERLAY."
(when (overlayp overlay) (delete-overlay overlay)))

(defun lsp-ui-line-number-display-width ()
"Safe way to get value from function `line-number-display-width'."
(if (bound-and-true-p display-line-numbers-mode)
;; For some reason, function `line-number-display-width' gave
;; us error `args-out-of-range' even we do not pass anything towards
;; to it function. See the following links,
;;
;; - https://github.com/emacs-lsp/lsp-ui/issues/294
;; - https://github.com/emacs-lsp/lsp-ui/issues/533 (duplicate)
(+ (or (ignore-errors (line-number-display-width)) 0) 2)
0))
(require 'find-func)

(defconst lsp-ui-resources-dir
(--> (or load-file-name (buffer-file-name))
Expand All @@ -89,6 +45,11 @@
(and (file-directory-p it) it))
"Resource folder for package `lsp-ui'.")

(require 'lsp-ui-sideline)
(require 'lsp-ui-peek)
(require 'lsp-ui-imenu)
(require 'lsp-ui-doc)

(defgroup lsp-ui nil
"‘lsp-ui’ contains a series of useful UI integrations for ‘lsp-mode’."
:group 'tools
Expand All @@ -103,6 +64,14 @@
(when (and (boundp 'winum-ignored-buffers-regexp) lsp-ui-doc-winum-ignore)
(add-to-list 'winum-ignored-buffers-regexp lsp-ui-doc--buffer-prefix)))

(defun lsp-ui-peek--render (major string)
(with-temp-buffer
(insert string)
(delay-mode-hooks
(let ((inhibit-message t)) (funcall major))
(ignore-errors (font-lock-ensure)))
(buffer-string)))

(defun lsp-ui--workspace-path (path)
"Return the PATH relative to the workspace.
If the PATH is not in the workspace, it returns the original PATH."
Expand Down Expand Up @@ -203,5 +172,6 @@ Both should have the form (FILENAME LINE COLUMN)."
(cons idx (length refs)))
(cons 0 0))))


(provide 'lsp-ui)
;;; lsp-ui.el ends here