Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions lsp-mssql.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

(require 'lsp-mode)
(require 'lsp-treemacs)
(require 'lsp-treemacs-generic)
(require 'gnutls)

(defgroup lsp-mssql nil
Expand All @@ -46,7 +47,7 @@
:type 'number)

(defconst lsp-mssql-server-download-url
"https://download.microsoft.com/download/c/2/f/c9857f58-e569-4677-ad24-f180e83a8252/microsoft.sqltools.servicelayer-%s")
"https://github.com/microsoft/sqltoolsservice/releases/download/5.0.20250910.2/Microsoft.SqlTools.ServiceLayer-%s")

(defconst lsp-mssql-executable-files
'("MicrosoftSqlToolsServiceLayer.exe" "MicrosoftSqlToolsServiceLayer" "MicrosoftSqlToolsServiceLayer.dll"))
Expand Down Expand Up @@ -111,9 +112,9 @@ Will not do anything should the file exist already."
"Download mssql server.
Uses `powershell' on windows and `tar' on Linux to extract the server binary."
(interactive)
(let* ((result (cond ((eq system-type 'darwin) "osx-x64-netcoreapp2.2.tar.gz")
((eq system-type 'gnu/linux) "rhel-x64-netcoreapp2.2.tar.gz")
((eq system-type 'windows-nt) "win-x64-netcoreapp2.2.zip")
(let* ((result (cond ((eq system-type 'darwin) "osx-arm64-net8.0.tar.gz")
((eq system-type 'gnu/linux) "linux-x64-net8.0.tar.gz")
((eq system-type 'windows-nt) "win-x64-net8.0.zip")
(t (error (format "Unsupported system: %s" system-type)))))
Comment on lines +115 to 118
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded ARM64 architecture for macOS may not work on Intel-based Macs. Consider detecting the actual architecture or providing both x64 and arm64 options for macOS.

Suggested change
(let* ((result (cond ((eq system-type 'darwin) "osx-arm64-net8.0.tar.gz")
((eq system-type 'gnu/linux) "linux-x64-net8.0.tar.gz")
((eq system-type 'windows-nt) "win-x64-net8.0.zip")
(t (error (format "Unsupported system: %s" system-type)))))
(let* ((result (cond
((eq system-type 'darwin)
(if (or (string-match "arm64" system-configuration)
(string-match "aarch64" system-configuration))
"osx-arm64-net8.0.tar.gz"
"osx-x64-net8.0.tar.gz"))
((eq system-type 'gnu/linux) "linux-x64-net8.0.tar.gz")
((eq system-type 'windows-nt) "win-x64-net8.0.zip")
(t (error (format "Unsupported system: %s" system-type)))))

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a valid concern, but I have no way to verify the values of system-configuration on a mac as I don't have one or anyone who could check. The variable does exist though and on my linux system it has value "x86_64-pc-linux-gnu" so it seems legit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's pretty safe to do it this way. I have several packages that do this, and I have no issues with them.

Examples:

I'm running both packages on macOS M3.

(download-location (f-join temporary-file-directory result))
(url (format lsp-mssql-server-download-url result)))
Expand Down Expand Up @@ -205,7 +206,7 @@ PARAMS Session created handler."
(prog1 (save-excursion
(let ((inhibit-read-only t))
,@body))
(org-show-all '(headings blocks)))))
(org-fold-show-all '(headings blocks)))))

(defun lsp-mssql--connection-complete (_workspace params)
"Connection completed handler.
Expand Down Expand Up @@ -367,7 +368,7 @@ PARAMS the params."
"Hanler for batch complete.")

(defun lsp-mssql--complete (_workspace _params)
"Hanler for complete."
"Handler for complete."
(lsp-mssql-with-result-buffer))

(defvar-local lsp-mssql--markers (ht))
Expand Down Expand Up @@ -663,14 +664,19 @@ NODES - all nodes."
"Show explorer.
TREE is the data to display, TITLE will be used for the
modeline in the result buffer."
(with-current-buffer (get-buffer-create "*SQL Object explorer*")
(lsp-treemacs-initialize)
(setq-local lsp-treemacs-tree tree)
(setq-local face-remapping-alist '((button . default)))
(lsp-treemacs-generic-refresh)
(display-buffer-in-side-window (current-buffer) '((side . right)))
(setq-local mode-name title)
(lsp-mssql-object-explorer-mode)))
(lsp-treemacs-render tree title 0
"*SQL Object explorer*" nil)
(with-current-buffer "*SQL Object explorer*"
(display-buffer-in-side-window (current-buffer) '((side . right)))
(lsp-mssql-object-explorer-mode)))
Comment on lines +667 to +671
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation uses tabs instead of spaces, which is inconsistent with Emacs Lisp conventions. Use consistent space-based indentation.

Copilot uses AI. Check for mistakes.


;; - (with-current-buffer (get-buffer-create "*SQL Object explorer*")
;; - (lsp-treemacs-initialize)
;; - (setq-local lsp-treemacs-tree tree)
;; - (setq-local face-remapping-alist '((button . default)))
;; - (lsp-treemacs-generic-refresh);; -
;; - (setq-local mode-name title)




Comment on lines +673 to 682
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed rather than left in the source. If this code might be needed for reference, consider documenting the migration in a commit message instead.

Suggested change
;; - (with-current-buffer (get-buffer-create "*SQL Object explorer*")
;; - (lsp-treemacs-initialize)
;; - (setq-local lsp-treemacs-tree tree)
;; - (setq-local face-remapping-alist '((button . default)))
;; - (lsp-treemacs-generic-refresh);; -
;; - (setq-local mode-name title)

Copilot uses AI. Check for mistakes.

Expand Down