This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/sql
Miciah Dashiel Butler Masters 78297be625 Fix various typos
* Fix various isolated typos

"apppend" -> "append"

"availabe" -> "available"

"Descripti using ternon" -> "Description"

"you have not them" -> "you don't have them"

"new on" -> "new one"

"plained" -> "curved"

"repel" -> "REPL"

"vairable" -> "variable"

* Fix a few errors in the CoffeeScript layer readme

Add a missing "the".

Correct a reference to the layer as "javascript" to "coffeescript".

Fix the syntax on the link to CoffeeLint.

* Fix typos: "dofile" -> "dotfile"

* Fix typos: "formated" and "formating"

"formated" -> "formatted"

"formating" -> "formatting"

* hy: Fix docstrings in funcs.el

Fix copy-and-pasted docstring text for
spacemacs/hy-shell-eval-current-form-and-go and
spacemacs/hy-shell-eval-region-and-go.

* Fix typos: "indendation" -> "indentation"

* Fix typos: "the the", "a a"

Fix duplicated (or misplaced) articles.

* Fix typos: "wether" -> "whether"

* Fix typos: "intialize" -> "initialize"
2018-05-23 22:12:30 -04:00
..
img Use + instead of ! for layer categories 2015-09-11 00:13:51 -04:00
config.el sql: change blacklist to only accept list 2017-05-24 12:13:13 +02:00
funcs.el sql: move function to funcs.el 2018-01-18 01:08:46 -05:00
packages.el Revert "Defer packages by default using use-package-always-defer" 2018-03-03 23:40:10 -05:00
README.org Fix various typos 2018-05-23 22:12:30 -04:00

SQL layer

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

Description

This layer adds support for a wide range of SQL dialects to Spacemacs.

Features:

  • Syntax highlighting for the following SQL dialects

    • ANSI
    • DB2
    • Informix
    • Ingres
    • Interbase
    • Linter
    • Microsoft
    • MySQL
    • Oracle
    • Postgres
    • Solid
    • SQLite
    • Sybase
    • Vertica
  • Syntax-checking via sqlint for ANSI SQL.
  • Snippet insertion for the more general SQL constructs.
  • REPL support via SQLi buffer.
  • Automatic capitalization of keywords.

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.

For syntax-checking you also need to install ruby as well as sqlint.

	gem install sqlint

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 a list with keywords to ignore, e.g.

  (setq-default dotspacemacs-configuration-layers '(
    (sql :variables
         sql-capitalize-keywords t
         sql-capitalize-keywords-blacklist '("name" "varchar"))))

This layer is blacklisting name by default as it is a 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 Formatting

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