https://github.com/emacs-lsp/lsp-mssql
lsp-mode :heart: MSSQL Server
https://github.com/emacs-lsp/lsp-mssql
emacs-lsp lsp mssql sql
Last synced: 12 months ago
JSON representation
lsp-mode :heart: MSSQL Server
- Host: GitHub
- URL: https://github.com/emacs-lsp/lsp-mssql
- Owner: emacs-lsp
- License: mit
- Created: 2019-12-01T20:43:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-04-23T00:28:39.000Z (about 1 year ago)
- Last Synced: 2025-06-01T07:12:44.858Z (about 1 year ago)
- Topics: emacs-lsp, lsp, mssql, sql
- Language: Emacs Lisp
- Homepage: https://emacs-lsp.github.io/lsp-mssql
- Size: 1.53 MB
- Stars: 34
- Watchers: 6
- Forks: 7
- Open Issues: 11
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
[[https://melpa.org/#/lsp-mssql][file:https://melpa.org/packages/lsp-mssql-badge.svg]]
[[https://github.com/emacs-lsp/lsp-mssql/actions/workflows/test.yml][file:https://github.com/emacs-lsp/lsp-mssql/actions/workflows/test.yml/badge.svg]]
* lsp-mode mssql client
Emacs client for [[https://github.com/microsoft/sqltoolsservice][sqltoolsservice]] (port of [[https://github.com/microsoft/vscode-mssql/][vscode-mssql]])
** Demo
[[file:screenshots/demo.gif]]
** Installation
*** Melpa (TBD)
*** Manual
Install =lsp-mode= and =lsp-treemacs= clone the repo and add the following lines in your config:
#+BEGIN_SRC elisp
(add-to-load-path ".../lsp-mssql/")
(require 'lsp-mssql)
(add-hook 'sql-mode-hook 'lsp)
#+END_SRC
** Configuration
Confgure the connections.
#+BEGIN_SRC emacs-lisp
(setq lsp-mssql-connections
[(:server "localhost"
:database ""
:user "SA"
:password "demoPWD2")])
#+END_SRC
Open a =*.sql= file and do =M-x lsp=. On the first run, it will ask you
whether to install the language server. Then when you are in the =sql= buffer
do =M-x lsp-mssql-connect= which will ask you to select connection. After the
connection is established the current buffer will be associated with the SQL
Server and the completion and the query exection will be performed against
that server.
=lsp-mssql= also supports Azure MSSQL. To connect using Service
Principals, you need to use raw connection string:
#+begin_src emacs-lisp
(setq lsp-mssql-connections
[(:server "SERVER-NAME.database.windows.net"
:connectionString "SERVER=SERVER-NAME.database.windows.net;DATABASE=...;UID=...;PWD=...;AUTHENTICATION=ActiveDirectoryServicePrincipal")])
#+end_src
** Commands
- Editor
- =lsp-mssql-connect= - connect the editor to =MSSQL server=.
- =lsp-mssql-disconnect= - disconnect the editor =MSSQL server=.
- =lsp-mssql-execute-buffer= - execute current buffer
- =lsp-mssql-execute-region= - execute selected region.
- MSSQL Object Explorer
- =lsp-mssql-object-explorer= - display =MSSQL= object explorer to the right.
- =lsp-mssql-object-explorer-connect= - connect the connection under point. Bound to =C= in the object explorer.
- =lsp-mssql-object-explorer-refresh= - refresh the node. Bound to =R= in the object explorer.
** Run mssql in docker
#+BEGIN_SRC bash
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=demoPWD2" \
-p 1433:1433 --name sql1 \
-d mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
#+END_SRC
** Snippets
=snippets= directory contains the snippets from [[https://github.com/microsoft/vscode-mssql/][vscode-mssql]].
#+BEGIN_SRC emacs-lisp
(add-to-list 'yas-snippets-dir "path to stippets dir.")
#+END_SRC
** TBD
- Implement disconnect.
- Implement cancel query
- Provide options to customize the output