Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add SQL support #4447

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* Changelog
** Unreleased 9.0.1
* Add support for GNAT Project (~gpr-mode~, ~gpr-ts-mode~).

* Add SQL support
** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
* Add new configuration options for lsp-html. Now able to toggle documentation hovers. Custom data is no longer experimental, and is now a vector.
Expand Down
65 changes: 65 additions & 0 deletions clients/lsp-sql.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
;;; lsp-sql.el --- SQL Client settings. -*- lexical-binding: t; -*-

;; Copyright (C) 2024 Shen, Jen-Chieh

;; This file is not part of GNU Emacs.

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:
;;
;; LSP client for SQL.
;;

;;; Code:

(require 'lsp-mode)

(defgroup lsp-sql nil
"LSP support for SQL, using sql-language-server."
:group 'lsp-mode
:link '(url-link "https://github.com/joe-re/sql-language-server")
:package-version `(lsp-mode . "9.0.1"))

(defcustom lsp-sql-server-path nil
"Path points for SQL language server.

This is only for development use."
:type 'string
:group 'lsp-sql)

(defun lsp-sql--server-command ()
"Generate startup command for SQL language server."
(list (or lsp-sql-server-path
(lsp-package-path 'sql-ls))
"up" "--method" "stdio"))

(lsp-dependency 'sql-ls
'(:system "sql-ls")
'(:npm :package "sql-language-server"
:path "sql-language-server"))

(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection #'lsp-sql--server-command)
:major-modes '(sql-mode)
:priority -1
:server-id 'sql-ls
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure 'sql-ls callback error-callback))))

(lsp-consistency-check lsp-sql)

(provide 'lsp-sql)
;;; lsp-sql.el ends here
2 changes: 1 addition & 1 deletion clients/lsp-sqls.el
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ use the current region if set, otherwise the entire buffer."
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection #'lsp-sqls--make-launch-cmd)
:major-modes '(sql-mode)
:priority -1
:priority -2
:action-handlers (ht ("executeParagraph" #'lsp-sql-execute-paragraph)
("executeQuery" #'lsp-sql-execute-query)
("showDatabases" #'lsp-sql-show-databases)
Expand Down
8 changes: 8 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,14 @@
"installation-url": "https://sorbet.org/docs/adopting#step-1-install-dependencies",
"debugger": "Not available"
},
{
"name": "sql",
"full-name": "SQL (sql)",
"server-name": "sql-language-server",
"server-url": "https://github.com/joe-re/sql-language-server",
"installation": "npm i -g sql-language-server",
"debugger": "Not available"
},
{
"name": "sqls",
"full-name": "SQL (sqls)",
Expand Down
10 changes: 5 additions & 5 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ As defined by the Language Server Protocol 3.16."
lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-rubocop lsp-ruby-lsp
lsp-ruby-syntax-tree lsp-ruff-lsp lsp-rust lsp-semgrep lsp-shader
lsp-solargraph lsp-solidity lsp-sonarlint lsp-sorbet lsp-sourcekit lsp-sqls
lsp-steep lsp-svelte lsp-tailwindcss lsp-terraform lsp-tex lsp-tilt
lsp-toml lsp-trunk lsp-ttcn3 lsp-typeprof lsp-v lsp-vala lsp-verilog
lsp-vetur lsp-vhdl lsp-vimscript lsp-volar lsp-wgsl lsp-xml lsp-yaml
lsp-yang lsp-zig)
lsp-solargraph lsp-solidity lsp-sonarlint lsp-sorbet lsp-sourcekit
lsp-sql lsp-sqls lsp-steep lsp-svelte lsp-tailwindcss lsp-terraform
lsp-tex lsp-tilt lsp-toml lsp-trunk lsp-ttcn3 lsp-typeprof lsp-v
lsp-vala lsp-verilog lsp-vetur lsp-vhdl lsp-vimscript lsp-volar lsp-wgsl
lsp-xml lsp-yaml lsp-yang lsp-zig)
"List of the clients to be automatically required."
:group 'lsp-mode
:type '(repeat symbol))
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ nav:
- Scala: https://emacs-lsp.github.io/lsp-metals
- Semgrep: page/lsp-semgrep.md
- ShaderLab: page/lsp-shader.md
- SQL (sql): page/lsp-sql.md
- SQL (sqls): page/lsp-sqls.md
- Standard ML (Millet): page/lsp-sml.md
- Svelte: page/lsp-svelte.md
Expand Down
Loading