spacemacs/layers/+lang/sql
Kepi 7cb9c1924a sql: support for keywords auto 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
parse the code much more quickly.
2017-05-24 12:08:45 +02:00
..
img
README.org sql: support for keywords auto capitalization 2017-05-24 12:08:45 +02:00
config.el sql: support for keywords auto capitalization 2017-05-24 12:08:45 +02:00
packages.el sql: support for keywords auto capitalization 2017-05-24 12:08:45 +02:00

README.org

SQL layer

/TakeV/spacemacs/media/commit/7cb9c1924a453daf4715c6d3925eb3250ebf1d68/layers/+lang/sql/img/sql.png

Description

This layer adds key bindings and configuration for sql-mode, which manages interactive SQL buffers and highlights a wide range of SQL dialects.

Install

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.

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 parse the code much more quickly.

To install sqlup-mode which enables auto capitalization in sql mode set the variable sql-capitalize-keywords to t.

  (setq-default dotspacemacs-configuration-layers '(
    (sql :variables sql-capitalize-keywords t)))

SQL Interactive Mode

If you want capitalization only in sql-mode and not in sql-interactive-mode you can set the variable sql-capitalize-keywords-disable-interactive to t.

Blacklisting keywords

sqlup-mode can be configured to ignore certain keywords. For example if you use name as column name it would be annoying to have it upcased. You can prevent this behaviour by setting the variable sql-capitalize-keywords-blacklist to string with one keyword (like "name") or to list with multiple keywords (like '("name" "varchar")) to ignore.

This layer is blacklisting name by default as it is very common name for column and NAME is non-reserved SQL keyword.

Key bindings

Highlighting

Key Binding Description
SPC m h k select a SQL dialect to highlight

Inferior Process Interactions (SQLi)

Key Binding Description
SPC m b b show the SQLi buffer name
SPC m b s set the SQLi buffer
SPC m l a List all objects
SPC m l t list all objects in a table

Send SQL queries to SQLi:

Key Binding Description
SPC m s b Send the whole buffer to the SQLi buffer
SPC m s B Send the whole buffer to the SQLi buffer and switch to it in insert state
SPC m s i Start the SQLi process
SPC m s f Send the paragraph around point to the SQLi buffer
SPC m s F Send the paragraph around point to the SQLi buffer and switch to it in insert state
SPC m s q Prompt for a string to send to the SQLi buffer
SPC m s Q Prompt for a string to send to the SQLi buffer and switch to it in insert state
SPC m s r Send the selected region to the SQLi buffer
SPC m s R Send the selected region to the SQLi buffer and switch to it in insert state

SQLi buffer

Key Binding Description
SPC m b r rename buffer (follow up in the SQL buffer with SPC m b s)
SPC m b S save the current connection

Code Formating

SPC m = c capitalize SQL keywords in region (if capitalize is enabled)