config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-sql.el (1985B)


      1 ;;; lsp-sql.el --- SQL Client settings.  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2024  Shen, Jen-Chieh
      4 
      5 ;; This file is not part of GNU Emacs.
      6 
      7 ;; This program is free software: you can redistribute it and/or modify
      8 ;; it under the terms of the GNU General Public License as published by
      9 ;; the Free Software Foundation, either version 3 of the License, or
     10 ;; (at your option) any later version.
     11 
     12 ;; This program is distributed in the hope that it will be useful,
     13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ;; GNU General Public License for more details.
     16 
     17 ;; You should have received a copy of the GNU General Public License
     18 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
     19 
     20 ;;; Commentary:
     21 ;;
     22 ;; LSP client for SQL.
     23 ;;
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-sql nil
     30   "LSP support for SQL, using sql-language-server."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/joe-re/sql-language-server")
     33   :package-version `(lsp-mode . "9.0.1"))
     34 
     35 (defcustom lsp-sql-server-path nil
     36   "Path points for SQL language server.
     37 
     38 This is only for development use."
     39   :type 'string
     40   :group 'lsp-sql)
     41 
     42 (defun lsp-sql--server-command ()
     43   "Generate startup command for SQL language server."
     44   (list (or lsp-sql-server-path
     45             (lsp-package-path 'sql-ls))
     46         "up" "--method" "stdio"))
     47 
     48 (lsp-dependency 'sql-ls
     49                 '(:system "sql-ls")
     50                 '(:npm :package "sql-language-server"
     51                        :path "sql-language-server"))
     52 
     53 (lsp-register-client
     54  (make-lsp-client
     55   :new-connection (lsp-stdio-connection #'lsp-sql--server-command)
     56   :major-modes '(sql-mode)
     57   :priority -1
     58   :server-id 'sql-ls
     59   :download-server-fn (lambda (_client callback error-callback _update?)
     60                         (lsp-package-ensure 'sql-ls callback error-callback))))
     61 
     62 (lsp-consistency-check lsp-sql)
     63 
     64 (provide 'lsp-sql)
     65 ;;; lsp-sql.el ends here