* SQL
- REPL
- tree-sitter
- Language-Server
- Linter

** Tree-sitter
There is no sql-ts-mode yet.

- moving around: ts-movement
- selections:
  - expreg
  - evil-textobj-tree-sitter
- folding
    
** TODO pgformat
No great value

** sqlfluff
installed as a command line tool

- linter
- formatter
- template engine

unfortunately not working with emacs
    

** Linter
Uses sqlint ruby gem from Steve Purcell

  #+begin_src emacs-lisp
  (require 'sql)
(require 'flycheck)
  #+end_src


** Formatter


  #+begin_src emacs-lisp
  (use-package sqlup-mode)
  #+end_src

  #+begin_src emacs-lisp
(require 'sql-indent)

;; Update indentation rules, select, insert, delete and update keywords
;; are aligned with the clause start

(defvar my-sql-indentation-offsets-alist
  `((select-clause 0)
    (insert-clause 0)
    (delete-clause 0)
    (update-clause 0)
    ,@sqlind-default-indentation-offsets-alist))

(add-hook 'sqlind-minor-mode-hook
	  (lambda ()
	  (setq sqlind-indentation-offsets-alist
		my-sql-indentation-offsets-alist)))
  #+end_src

     
** Konfiguration
  #+begin_src emacs-lisp
  (require 'sql)
  (use-package emacs
    :pin gnu
    :bind (
	   :map sql-mode-map
	   ("C-+"      . expreg-expand)
	   ("C--"      . expreg-contract)
	   ("S-<return>"   . sql-send-string)
	   ("C-<return>"   . sql-send-region)
	   ("M-<return>"   . sql-send-paragraph)
	   )
    :hook
    (sql-mode . yas-minor-mode)
    (sql-mode . flycheck-mode)
    (sql-mode . sqlup-mode)
    :config
    )
  #+end_src

There is a Hydra defined for ts-movement, open with <f5>.

** Language Server

*** void-Linux

*** Windows

Using MSYS2:

#+begin_src sh
#+end_src

** UI

  #+begin_src emacs-lisp
#+end_src

;;   "c"      '(sql-connect                  :wk "connect to database")
;;   "p"        '(python-shell-switch-to-shell :wk "py-shell")
"+"        '(yas-insert-snippet         :wk "code snippets")
"j"        '(hydra-tree-sitter-move/body           :wk "movement hydra")

"x"        '(:ignore t :which-key "execute in REPL")
"xb"       '(sql-send-buffer    :wk "buffer")
"xp"       '(sql-send-paragraph :wk "paragraph")
"xs"       '(sql-send-string    :wk "string")

"m"        '(:ignore t :which-key "mark/select")
"mp"       '(mark-paragraph :wk "paragraph")
"mf"       '(mark-defun     :wk "function")