|
30 | 30 | ;;; Code: |
31 | 31 |
|
32 | 32 | (require 'lsp-mode) |
33 | | -(require 'flycheck) |
| 33 | +(require 'flycheck nil 'noerror) |
34 | 34 | (require 'dash) |
35 | 35 |
|
36 | 36 | (defgroup lsp-ui-sideline nil |
|
61 | 61 | :type 'boolean |
62 | 62 | :group 'lsp-ui-sideline) |
63 | 63 |
|
64 | | -(defcustom lsp-ui-sideline-show-flycheck t |
65 | | - "Whether to show flycheck messages in sideline." |
| 64 | +(defcustom lsp-ui-sideline-show-diagnostics t |
| 65 | + "Whether to show diagnostics messages in sideline." |
66 | 66 | :type 'boolean |
67 | 67 | :group 'lsp-ui-sideline) |
68 | 68 |
|
@@ -299,28 +299,29 @@ CURRENT is non-nil when the point is on the symbol." |
299 | 299 | (when (overlay-get ov 'current) |
300 | 300 | (lsp-ui-sideline--toggle-current ov nil)))))) |
301 | 301 |
|
302 | | -(defun lsp-ui-sideline--flycheck () |
303 | | - "Show flycheck message(s)." |
| 302 | +(defun lsp-ui-sideline--diagnostics () |
| 303 | + "Show diagnostics on the current line." |
304 | 304 | (let ((bol (line-beginning-position)) |
305 | 305 | (eol (line-end-position))) |
306 | | - (dolist (e (flycheck-overlay-errors-in bol (1+ eol))) |
307 | | - (let* ((message (--> (flycheck-error-format-message-and-id e) |
308 | | - (car (split-string it "\n")) |
309 | | - (replace-regexp-in-string "[\n\t ]+" " " it))) |
310 | | - (len (length message)) |
311 | | - (level (flycheck-error-level e)) |
312 | | - (face (if (eq level 'info) 'success level)) |
313 | | - (margin (lsp-ui-sideline--margin-width)) |
314 | | - (message (progn (add-face-text-property 0 len 'lsp-ui-sideline-global nil message) |
315 | | - (add-face-text-property 0 len face nil message) |
316 | | - message)) |
317 | | - (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(lsp-ui-sideline--align len margin)))) |
318 | | - message)) |
319 | | - (pos-ov (lsp-ui-sideline--find-line len t)) |
320 | | - (ov (and pos-ov (make-overlay pos-ov pos-ov)))) |
321 | | - (when pos-ov |
322 | | - (overlay-put ov 'after-string string) |
323 | | - (push ov lsp-ui-sideline--ovs)))))) |
| 306 | + (when (bound-and-true-p 'flycheck-mode) |
| 307 | + (dolist (e (flycheck-overlay-errors-in bol (1+ eol))) |
| 308 | + (let* ((message (--> (flycheck-error-format-message-and-id e) |
| 309 | + (car (split-string it "\n")) |
| 310 | + (replace-regexp-in-string "[\n\t ]+" " " it))) |
| 311 | + (len (length message)) |
| 312 | + (level (flycheck-error-level e)) |
| 313 | + (face (if (eq level 'info) 'success level)) |
| 314 | + (margin (lsp-ui-sideline--margin-width)) |
| 315 | + (message (progn (add-face-text-property 0 len 'lsp-ui-sideline-global nil message) |
| 316 | + (add-face-text-property 0 len face nil message) |
| 317 | + message)) |
| 318 | + (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(lsp-ui-sideline--align len margin)))) |
| 319 | + message)) |
| 320 | + (pos-ov (lsp-ui-sideline--find-line len t)) |
| 321 | + (ov (and pos-ov (make-overlay pos-ov pos-ov)))) |
| 322 | + (when pos-ov |
| 323 | + (overlay-put ov 'after-string string) |
| 324 | + (push ov lsp-ui-sideline--ovs))))))) |
324 | 325 |
|
325 | 326 | (defvar-local lsp-ui-sideline--code-actions nil) |
326 | 327 |
|
@@ -384,8 +385,8 @@ to the language server." |
384 | 385 | (setq lsp-ui-sideline--occupied-lines nil |
385 | 386 | lsp-ui-sideline--tag tag |
386 | 387 | lsp-ui-sideline--last-width (window-text-width)) |
387 | | - (when lsp-ui-sideline-show-flycheck |
388 | | - (lsp-ui-sideline--flycheck)) |
| 388 | + (when lsp-ui-sideline-show-diagnostics |
| 389 | + (lsp-ui-sideline--diagnostics)) |
389 | 390 | (when (and lsp-ui-sideline-show-code-actions (or (lsp--capability "codeActionProvider") |
390 | 391 | (lsp--registered-capability "textDocument/codeAction"))) |
391 | 392 | (lsp--send-request-async (lsp--make-request |
@@ -480,15 +481,15 @@ This does not toggle display of flycheck diagnostics or code actions." |
480 | 481 | (add-hook 'post-command-hook 'lsp-ui-sideline nil t) |
481 | 482 | (advice-add 'company-pseudo-tooltip-frontend :before 'lsp-ui-sideline--hide-before-company) |
482 | 483 | (add-hook 'lsp-after-diagnostics-hook 'lsp-ui-sideline--diagnostics-changed nil t) |
483 | | - (when lsp-ui-sideline-show-flycheck |
| 484 | + (when lsp-ui-sideline-show-diagnostics |
484 | 485 | (setq-local flycheck-display-errors-function nil))) |
485 | 486 | (t |
486 | 487 | (setq lsp-ui-sideline--tag nil) |
487 | 488 | (advice-remove 'company-pseudo-tooltip-frontend 'lsp-ui-sideline--hide-before-company) |
488 | 489 | (lsp-ui-sideline--delete-ov) |
489 | 490 | (remove-hook 'lsp-after-diagnostics-hook 'lsp-ui-sideline--diagnostics-changed) |
490 | 491 | (remove-hook 'post-command-hook 'lsp-ui-sideline t) |
491 | | - (when lsp-ui-sideline-show-flycheck |
| 492 | + (when lsp-ui-sideline-show-diagnostics |
492 | 493 | (kill-local-variable 'flycheck-display-errors-function))))) |
493 | 494 |
|
494 | 495 | (defun lsp-ui-sideline-enable (enable) |
|
0 commit comments