[sql] Revise sql-layer
Add installation instruction for `sqlfmt` executable Adapt documentation to be more like the other layers Replace wrong default sqlfmt parameter -u with --use-spaces Make error buffers be reused by default to reduce memory consumption Change prefix for repl keybindings to be conform with the other layers Remove obsolete progn statement
This commit is contained in:
parent
c001159718
commit
903ad8a8e1
|
@ -8,7 +8,7 @@
|
|||
- [[#description][Description]]
|
||||
- [[#features][Features:]]
|
||||
- [[#install][Install]]
|
||||
- [[#external-dependencies][External Dependencies:]]
|
||||
- [[#external-dependencies][External Dependencies]]
|
||||
- [[#sql-keywords-capitalization][SQL Keywords Capitalization]]
|
||||
- [[#sql-interactive-mode][SQL Interactive Mode]]
|
||||
- [[#blacklisting-keywords][Blacklisting keywords]]
|
||||
|
@ -16,7 +16,7 @@
|
|||
- [[#key-bindings][Key bindings]]
|
||||
- [[#highlighting][Highlighting]]
|
||||
- [[#inferior-process-interactions-sqli][Inferior Process Interactions (SQLi)]]
|
||||
- [[#send-sql-queries-to-sqli][Send SQL queries to SQLi:]]
|
||||
- [[#send-sql-queries-to-sqli][Send SQL queries to SQLi]]
|
||||
- [[#sqli-buffer][SQLi buffer]]
|
||||
- [[#code-formatting][Code Formatting]]
|
||||
|
||||
|
@ -50,15 +50,20 @@ To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|||
add =sql= to the existing =dotspacemacs-configuration-layers= list in this
|
||||
file.
|
||||
|
||||
** External Dependencies:
|
||||
Some functionality, like linting, rely on external binaries:
|
||||
- *Syntax Checking*: Install [[https://www.ruby-lang.org/en/about/][ruby]] and the =sqlint= gem.
|
||||
- *Formatting*: Install [[https://github.com/mjibson/sqlfmt][sqlfmt]] and move it into your =$PATH=
|
||||
** External Dependencies
|
||||
Some functionality, like linting, rely on external binaries:
|
||||
- *Syntax Checking*: Install [[https://www.ruby-lang.org/en/about/][ruby]] and the =sqlint= gem.
|
||||
- *Formatting*: Install [[https://github.com/mjibson/sqlfmt][sqlfmt]] and move it into your =$PATH=
|
||||
|
||||
#+BEGIN_SRC ruby
|
||||
gem install sqlint
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
# Download and extract the binary 0.4.0 for linux
|
||||
wget -q -O - https://github.com/mjibson/sqlfmt/releases/latest/download/sqlfmt_0.4.0_linux_amd64.tar.gz | tar -xpvzf - --directory "${installdir}/bin"
|
||||
#+END_SRC
|
||||
|
||||
** SQL Keywords Capitalization
|
||||
SQL, by convention, uses upper-case keywords, although lower-case works just as
|
||||
well. As humans, the separation between upper-case and lower-case helps scan and
|
||||
|
@ -119,7 +124,7 @@ auto-indent by setting the variable =sql-auto-indent= to =nil=.
|
|||
| ~SPC m l a~ | List all objects |
|
||||
| ~SPC m l t~ | list all objects in a table |
|
||||
|
||||
*** Send SQL queries to SQLi:
|
||||
*** Send SQL queries to SQLi
|
||||
|
||||
| Key binding | Description |
|
||||
|-------------+-------------------------------------------------------------------------------------------------------|
|
||||
|
@ -144,8 +149,8 @@ auto-indent by setting the variable =sql-auto-indent= to =nil=.
|
|||
|
||||
** Code Formatting
|
||||
|
||||
| Key binding | Description |
|
||||
|--------------+--------------------------------------------------------------|
|
||||
| ~SPC m = c~ | capitalize SQL keywords in region (if capitalize is enabled) |
|
||||
| ~SPC m = ==~ | ~sqlfmt~ whole buffer |
|
||||
| ~SPC m = r=~ | ~sqlfmt~ active region |
|
||||
| Key binding | Description |
|
||||
|-------------+--------------------------------------------------------------|
|
||||
| ~SPC m = c~ | capitalize SQL keywords in region (if capitalize is enabled) |
|
||||
| ~SPC m = =~ | ~sqlfmt~ whole buffer |
|
||||
| ~SPC m = r~ | ~sqlfmt~ active region |
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
:type 'string)
|
||||
|
||||
(defcustom sqlfmt-options
|
||||
'("-u")
|
||||
'("--use-spaces")
|
||||
"Command line options to pass to sqlfmt."
|
||||
:type '(repeat string))
|
||||
|
||||
(defcustom sqlfmt-reuse-error-buffer
|
||||
nil
|
||||
t
|
||||
"Reuse the same buffer for sqlfmt errors, replacing content on new invocations, or generate new buffers on each invocation"
|
||||
:type 'boolean)
|
||||
|
||||
|
@ -40,15 +40,15 @@
|
|||
(erase-buffer)
|
||||
(setq buffer-read-only t))
|
||||
(apply #'call-process-region start end
|
||||
sqlfmt-executable nil tmpbuf nil
|
||||
sqlfmt-options))))
|
||||
sqlfmt-executable nil tmpbuf nil
|
||||
sqlfmt-options))))
|
||||
(deactivate-mark)
|
||||
(if (eq status-code 0)
|
||||
(progn
|
||||
(with-current-buffer orig-buffer
|
||||
(delete-region start end)
|
||||
(insert-buffer tmpbuf)
|
||||
(kill-buffer tmpbuf)
|
||||
(goto-char orig-point))
|
||||
(delete-region start end)
|
||||
(insert-buffer tmpbuf)
|
||||
(kill-buffer tmpbuf)
|
||||
(goto-char orig-point))
|
||||
(message "sqlfmt applied"))
|
||||
(error "sqlfmt failed, see %s buffer for details." (buffer-name tmpbuf)))))
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
(spacemacs/declare-prefix-for-mode 'sql-mode "mg" "goto")
|
||||
(spacemacs/declare-prefix-for-mode 'sql-mode "mh" "dialects")
|
||||
(spacemacs/declare-prefix-for-mode 'sql-mode "ml" "listing")
|
||||
(spacemacs/declare-prefix-for-mode 'sql-mode "ms" "interactivity")
|
||||
(spacemacs/declare-prefix-for-mode 'sql-mode "ms" "REPL")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'sql-mode
|
||||
"'" 'spacemacs/sql-start
|
||||
|
||||
|
@ -145,7 +145,7 @@
|
|||
;; dialects
|
||||
"hk" 'spacemacs/sql-highlight
|
||||
|
||||
;; interactivity
|
||||
;; repl
|
||||
"sb" 'sql-send-buffer
|
||||
"sB" 'spacemacs/sql-send-buffer-and-focus
|
||||
"si" 'spacemacs/sql-start
|
||||
|
@ -185,11 +185,10 @@
|
|||
(use-package sqlfmt
|
||||
:commands sqlfmt-buffer
|
||||
:init
|
||||
(progn
|
||||
(spacemacs/declare-prefix-for-mode 'sql-mode "mf" "formatting")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'sql-mode
|
||||
"=r" 'sqlfmt-region
|
||||
"==" 'sqlfmt-buffer))))
|
||||
(spacemacs/declare-prefix-for-mode 'sql-mode "m=" "formatting")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'sql-mode
|
||||
"=r" 'sqlfmt-region
|
||||
"==" 'sqlfmt-buffer)))
|
||||
|
||||
(defun sql/init-sqlup-mode ()
|
||||
(use-package sqlup-mode
|
||||
|
|
Loading…
Reference in New Issue