|
141 | 141 | "Select the element under cursor." |
142 | 142 | (interactive) |
143 | 143 | (let ((key (button-get (treemacs-node-at-point) :data))) |
144 | | - (if (and (consp key) (lsp-diagnostic-p (cdr key))) |
145 | | - (-let (((file . diag) key) |
| 144 | + (if (and (consp key) (ht? (cdr key))) |
| 145 | + (-let (((file . (&Diagnostic :range (&Range :start))) key) |
146 | 146 | (session (lsp-session))) |
147 | 147 | (with-current-buffer (find-file-noselect file) |
148 | 148 | (with-lsp-workspaces (lsp--try-project-root-workspaces nil nil) |
149 | 149 | (save-excursion |
150 | | - (goto-char (point-min)) |
151 | | - (forward-line (lsp-diagnostic-line diag)) |
| 150 | + (goto-char (lsp--position-to-point :start)) |
152 | 151 | (lsp-execute-code-action-by-kind "quickfix"))))) |
153 | 152 | (user-error "Not on a diagnostic")))) |
154 | 153 |
|
|
174 | 173 | (defun lsp-treemacs-open-error (&rest _) |
175 | 174 | "Open error." |
176 | 175 | (interactive) |
177 | | - (-let [(file . diag) (button-get (treemacs-node-at-point) :data)] |
| 176 | + (-let [(file . (&Diagnostic :range (&Range :start))) (button-get (treemacs-node-at-point) :data)] |
178 | 177 | (find-file-other-window file) |
179 | | - (goto-char (point-min)) |
180 | | - (forward-line (lsp-diagnostic-line diag)) |
181 | | - (forward-char (lsp-diagnostic-column diag)))) |
| 178 | + (goto-char (lsp--position-to-point start)))) |
182 | 179 |
|
183 | 180 | (defun lsp-treemacs--face (root-folder diagnostics) |
184 | 181 | "Calculate ROOT-FOLDER face based on DIAGNOSTICS." |
|
187 | 184 | (-keep (-lambda ((file-name . file-diagnostics)) |
188 | 185 | (when (s-starts-with? root-folder file-name) |
189 | 186 | (lsp-diagnostic-severity |
190 | | - (--min-by (> (lsp-diagnostic-severity it) |
191 | | - (lsp-diagnostic-severity other)) |
192 | | - file-diagnostics)))) |
| 187 | + (-min-by (-lambda ((&Diagnostic :severity? left?) |
| 188 | + (&Diagnostic :severity? right?)) |
| 189 | + (> (or left? 0) (or right? 0))) |
| 190 | + file-diagnostics)))) |
193 | 191 | it) |
194 | 192 | -min |
195 | 193 | (assoc it lsp-treemacs-face-map) |
|
236 | 234 | (->> (lsp-diagnostics) |
237 | 235 | (gethash file-name) |
238 | 236 | (-filter #'lsp-treemacs--match-diagnostic-severity) |
239 | | - (--sort (if (= (lsp-diagnostic-line it) |
240 | | - (lsp-diagnostic-line other)) |
241 | | - (< (lsp-diagnostic-column it) |
242 | | - (lsp-diagnostic-column other)) |
243 | | - (< (lsp-diagnostic-line it) |
244 | | - (lsp-diagnostic-line other)))) |
| 237 | + (-sort (-lambda ((&Diagnostic :range (&Range :start (&Position :character char-a |
| 238 | + :line line-a))) |
| 239 | + (&Diagnostic :range (&Range :start (&Position :character char-b |
| 240 | + :line line-b)))) |
| 241 | + (if (= line-a line-b) |
| 242 | + (< char-a char-b) |
| 243 | + (< line-a line-b)))) |
245 | 244 | (--map (cons file-name it)))) |
246 | 245 |
|
247 | 246 | (defun lsp-treemacs--diagnostic-icon (diagnostic) |
|
259 | 258 | :render-action |
260 | 259 | (treemacs-render-node |
261 | 260 | :icon (treemacs-as-icon ". " 'face 'font-lock-string-face) |
262 | | - :label-form (propertize (lsp-diagnostic-message item) 'face 'default) |
| 261 | + :label-form (propertize (lsp:diagnostic-message item) 'face 'default) |
263 | 262 | :state treemacs-lsp-error-open-state |
264 | 263 | :key-form item)) |
265 | 264 |
|
|
269 | 268 | :query-function (lsp-treemacs--errors (treemacs-button-get node :key)) |
270 | 269 | :ret-action 'lsp-treemacs-open-file |
271 | 270 | :render-action |
272 | | - (let* ((diag (cl-rest item)) |
273 | | - (label (format (propertize "%s %s %s" 'face 'default) |
274 | | - (propertize (format "[%s]" (lsp-diagnostic-source diag)) |
275 | | - 'face 'shadow) |
276 | | - (lsp-diagnostic-message diag) |
277 | | - (propertize (format "(%s:%s)" |
278 | | - (lsp-diagnostic-line diag) |
279 | | - (lsp-diagnostic-column diag)) |
280 | | - 'face 'lsp-lens-face)))) |
| 271 | + (-let* (((&Diagnostic :source? |
| 272 | + :message |
| 273 | + :range (&Range :start (&Position :line :character))) (cl-rest item)) |
| 274 | + (label (format (propertize "%s %s %s" 'face 'default) |
| 275 | + (if source? |
| 276 | + (propertize (format "[%s]" source?) |
| 277 | + 'face 'shadow) |
| 278 | + "") |
| 279 | + message |
| 280 | + (propertize (format "(%s:%s)" line character) |
| 281 | + 'face 'lsp-lens-face)))) |
281 | 282 | (treemacs-render-node |
282 | 283 | :icon (lsp-treemacs--diagnostic-icon (cl-rest item)) |
283 | 284 | :label-form label |
|
670 | 671 |
|
671 | 672 | (defun lsp-treemacs-deps--icon (dep expanded) |
672 | 673 | "Get the symbol for the the kind." |
673 | | - (-let (((&hash "uri" "name" "kind" "entryKind" entry-kind) dep)) |
| 674 | + (-let (((&hash "uri" "kind" "entryKind" entry-kind) dep)) |
674 | 675 | (concat |
675 | 676 | (if expanded " ▾ " " ▸ ") |
676 | 677 | (if (or (= kind 8) |
|
1037 | 1038 | (interactive) |
1038 | 1039 | (lsp-treemacs--open-file-in-mru filename))))) |
1039 | 1040 |
|
1040 | | -(defun lsp-treemacs--extract-line (pos) |
1041 | | - "Return the line pointed to by POS (a Position object) in the current buffer." |
1042 | | - (let* ((point (lsp--position-to-point pos)) |
1043 | | - (inhibit-field-text-motion t)) |
1044 | | - (save-excursion |
1045 | | - (goto-char point) |
1046 | | - (buffer-substring (line-beginning-position) |
1047 | | - (line-end-position))))) |
1048 | | - |
1049 | 1041 | (defun lsp-treemacs--extract-line (point) |
1050 | 1042 | "Return the line pointed to by POS (a Position object) in the current buffer." |
1051 | 1043 | (let* ((inhibit-field-text-motion t)) |
|
0 commit comments