|
37 | 37 | (defun eca-editor--flymake-to-eca-severity (severity) |
38 | 38 | "Convert flymake SEVERITY to eca one." |
39 | 39 | (pcase severity |
40 | | - ('flymake-error "error") |
41 | | - (':error "error") |
42 | | - ('flymake-warning "warning") |
43 | | - (':warning "warning") |
44 | | - ('flymake-note "information") |
45 | | - (':note "information") |
| 40 | + ((or 'flymake-error ':error 'eglot-error) "error") |
| 41 | + ((or 'flymake-warning ':warning 'eglot-warning) "warning") |
| 42 | + ((or 'flymake-note ':note 'eglot-note) "information") |
46 | 43 | (_ "unknown"))) |
47 | 44 |
|
48 | 45 | (defun eca-editor--lsp-mode-diagnostics (uri workspace) |
@@ -83,35 +80,36 @@ If URI is nil find all diagnostics otherwise filter to that uri." |
83 | 80 | diagnostics)) |
84 | 81 | eca-diagnostics)) |
85 | 82 |
|
86 | | -(defun eca-editor--flymake-diagnostics (_uri workspace) |
| 83 | +(defun eca-editor--flymake-diagnostics (uri workspace) |
87 | 84 | "Find all flymake diagnostics found for WORKSPACE. |
88 | 85 | If URI is nil find all diagnostics otherwise filter to that uri." |
89 | | - (with-current-buffer (find-file-noselect workspace) |
90 | | - (--map |
91 | | - (with-current-buffer (flymake-diagnostic-buffer it) |
92 | | - (save-excursion |
93 | | - (let* ((beg (flymake-diagnostic-beg it)) |
94 | | - (end (flymake-diagnostic-end it)) |
95 | | - (beg-line (progn (goto-char beg) |
96 | | - (line-number-at-pos))) |
97 | | - (beg-col (current-column)) |
98 | | - (end-line (progn (goto-char end) |
99 | | - (line-number-at-pos))) |
100 | | - (end-col (current-column))) |
101 | | - (list :uri (eca--path-to-uri (buffer-file-name (flymake-diagnostic-buffer it))) |
| 86 | + (let ((default-directory workspace)) |
| 87 | + (--keep |
| 88 | + (let* ((locus (flymake-diagnostic-buffer it)) |
| 89 | + (buffer-p (bufferp locus)) |
| 90 | + (file-path (if buffer-p (buffer-file-name locus) locus)) |
| 91 | + (diag-uri (eca--path-to-uri file-path)) |
| 92 | + (beg (flymake-diagnostic-beg it)) |
| 93 | + (end (flymake-diagnostic-end it))) |
| 94 | + (when (or (null uri) (string= uri diag-uri)) |
| 95 | + (let ((range (if buffer-p |
| 96 | + (with-current-buffer locus |
| 97 | + (save-excursion |
| 98 | + (list :start (list :line (progn (goto-char beg) (line-number-at-pos)) |
| 99 | + :character (current-column)) |
| 100 | + :end (list :line (progn (goto-char (or end beg)) (line-number-at-pos)) |
| 101 | + :character (current-column))))) |
| 102 | + ;; file path locus - beg/end are already (line . col) |
| 103 | + (list :start (list :line (car beg) :character (cdr beg)) |
| 104 | + :end (list :line (if end (car end) (car beg)) |
| 105 | + :character (if end (cdr end) (cdr beg))))))) |
| 106 | + (list :uri diag-uri |
102 | 107 | :severity (eca-editor--flymake-to-eca-severity (flymake-diagnostic-type it)) |
103 | 108 | :code (when-let ((code (flymake-diagnostic-code it))) |
104 | | - (if (symbolp code) |
105 | | - (symbol-name code) |
106 | | - (format "%s" code))) |
107 | | - :range (list :start (list :line beg-line |
108 | | - :character beg-col) |
109 | | - :end (list :line end-line |
110 | | - :character end-col)) |
| 109 | + (if (symbolp code) (symbol-name code) (format "%s" code))) |
| 110 | + :range range |
111 | 111 | :source (when-let ((backend (flymake-diagnostic-backend it))) |
112 | | - (if (symbolp backend) |
113 | | - (symbol-name backend) |
114 | | - (format "%s" backend))) |
| 112 | + (if (symbolp backend) (symbol-name backend) (format "%s" backend))) |
115 | 113 | :message (flymake-diagnostic-text it))))) |
116 | 114 | (flymake--project-diagnostics)))) |
117 | 115 |
|
|
0 commit comments