Skip to content

Commit 063809a

Browse files
committed
feat(core): store result set metadata in the result buffer
The variable can be used by other packages or hooks for additional processing of the result buffer, such as fontification or navigation.
1 parent d2ae388 commit 063809a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lsp-mssql.el

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
(defvar-local lsp-mssql-buffer-status nil
6060
"SQL buffer status.")
6161

62+
(defvar-local lsp-mssql-result-metadata nil
63+
"Metadata associated with result set.
64+
65+
This is stored in the result buffer as buffer local value.")
66+
6267
(put 'lsp-mssql-buffer-status 'risky-local-variable t)
6368
(add-to-list 'global-mode-string (list '(t lsp-mssql-buffer-status)))
6469

@@ -243,11 +248,16 @@ PARAMS the params."
243248
"Result set complete handler.
244249
WORKSPACE is the active workspace.
245250
PARAMS the params."
246-
(-let* ((marker (lsp-mssql-with-result-buffer
251+
(-let* ((column-info (gethash "columnInfo" (gethash "resultSetSummary" params)))
252+
(result-metadata (seq-map (-lambda ((&hash "columnName" name "dataTypeName" type))
253+
(list name :name name :type type))
254+
column-info))
255+
(marker (lsp-mssql-with-result-buffer
256+
(setq-local lsp-mssql-result-metadata result-metadata)
247257
(goto-char (point-max))
248258
(insert (format "|%s|\n"(s-join "|" (seq-map (-lambda ((&hash "columnName" name))
249259
name)
250-
(gethash "columnInfo" (gethash "resultSetSummary" params))))))
260+
column-info))))
251261
(insert "|-")
252262
(org-table-align)
253263
(goto-char (point-at-eol))
@@ -306,7 +316,6 @@ PARAMS the params."
306316
(define-key [mouse-2] 'push-button))
307317
'help-echo "mouse-2, M-RET: Load more items."))
308318
(insert "\n\n")
309-
(org-mode)
310319
(goto-char (marker-position marker))
311320
(org-table-align)
312321
(display-buffer (current-buffer))))

0 commit comments

Comments
 (0)