Skip to content

Commit

Permalink
Show color diagnostic information.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Jun 11, 2023
1 parent 0ea5408 commit 69f4364
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
8 changes: 7 additions & 1 deletion lsp-bridge-diagnostic.el
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ You can set this value with `(2 3 4) if you just need render error diagnostic."
(2 'lsp-bridge-diagnostics-warning-face)
(3 'lsp-bridge-diagnostics-info-face)
(4 'lsp-bridge-diagnostics-hint-face))))
(overlay-put overlay 'color (plist-get (face-attribute overlay-face :underline) :color))
(overlay-put overlay 'face overlay-face)
(overlay-put overlay 'message message)
(overlay-put overlay
Expand All @@ -202,6 +203,11 @@ You can set this value with `(2 3 4) if you just need render error diagnostic."

(defvar lsp-bridge-diagnostic-frame nil)

(defun lsp-bridge-diagnostic-insert-colored-string (color text)
"Insert a colored string at point in the current buffer."
(let ((colored-text (propertize text 'face `(:foreground ,color))))
(insert colored-text)))

(defun lsp-bridge-diagnostic-show-tooltip (diagnostic-overlay &optional goto-beginning)
(let* ((diagnostic-display-message (overlay-get diagnostic-overlay 'display-message))
(diagnostic-message (overlay-get diagnostic-overlay 'message))
Expand All @@ -221,7 +227,7 @@ You can set this value with `(2 3 4) if you just need render error diagnostic."

(with-current-buffer (get-buffer-create lsp-bridge-diagnostic-buffer)
(erase-buffer)
(insert diagnostic-display-message)
(lsp-bridge-diagnostic-insert-colored-string (overlay-get diagnostic-overlay 'color) diagnostic-display-message)
(setq-local lsp-bridge-diagnostic-message diagnostic-message))

(cond
Expand Down
19 changes: 1 addition & 18 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,6 @@ Setting this to nil or 0 will turn off the indicator."
:type 'string
:group 'lsp-bridge)

(defcustom lsp-bridge-lookup-doc-tooltip-border-width 20
"The border width of lsp-bridge hover tooltip, in pixels."
:type 'integer
:group 'lsp-bridge)

(defcustom lsp-bridge-lookup-doc-tooltip-max-width 150
"The max width of lsp-bridge hover tooltip."
:type 'integer
:group 'lsp-bridge)

(defcustom lsp-bridge-lookup-doc-tooltip-max-height 20
"The max width of lsp-bridge hover tooltip."
:type 'integer
:group 'lsp-bridge)

(defcustom lsp-bridge-disable-backup t
"Default disable backup feature, include `make-backup-files' `auto-save-default' and `create-lockfiles'."
:type 'boolean
Expand Down Expand Up @@ -1641,9 +1626,7 @@ So we build this macro to restore postion after code format."

(acm-frame-new lsp-bridge-popup-documentation-frame
lsp-bridge-popup-documentation-buffer
"lsp bridge popup documentation frame"
lsp-bridge-lookup-doc-tooltip-max-width
lsp-bridge-lookup-doc-tooltip-max-height))
"lsp bridge popup documentation frame"))

(defun lsp-bridge-hide-doc-tooltip ()
(acm-frame-hide-frame lsp-bridge-popup-documentation-frame))
Expand Down

0 comments on commit 69f4364

Please sign in to comment.