spacevim/autoload/SpaceVim/layers/lang/sql.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

91 lines
3.1 KiB
VimL

"=============================================================================
" sql.vim --- lang#sql layer
" Copyright (c) 2016-2023 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
""
" @section lang#sql, layers-lang-sql
" @parentsection layers
" This layer is for sql development, disabled by default, to enable this
" layer, add following snippet to your @section(options) file.
" >
" [[layers]]
" name = 'lang#sql'
" <
"
" @subsection Options
"
" 1. `enabled_formatters`: set the default formatters for sql, default is ['sqlfmtorg']
" https://github.com/sql-formatter-org/sql-formatter
" you can also use `sqlformat` which is from https://github.com/andialbrecht/sqlparse
" 2. `sql_formatter_command`: Set the command of sql-formatter.
" 3. `sql_dialect`: set the SQL dialect, default is basic sql.
" 4. `sql_formatter_config`: set the path of config path. default is empty
" string.
" 5. `sqlformat_cmd`: set the command for sqlformat.
" 6. `sqlformat_output_encode`: set the output encoding of sqlformat, default
" is `utf-8`. If you are using window, maybe need to change this option to
" `cp936`.
"
"
if exists('s:enabled_formatters')
finish
endif
let s:enabled_formatters = ['sqlfmtorg']
let s:sql_formatter_command = 'sql-formatter'
let s:sql_dialect = 'sql'
let s:sql_formatter_config = ''
let s:sqlformat_cmd = 'sqlformat'
let s:sqlformat_output_encode = 'utf-8'
function! SpaceVim#layers#lang#sql#plugins() abort
let plugins = []
call add(plugins, ['tpope/vim-dadbod', {'merged' : 0}])
return plugins
endfunction
function! SpaceVim#layers#lang#sql#set_variable(opt) abort
" keep compatibility with enabled_formater
let s:enabled_formatters = get(a:opt, 'enabled_formatters', get(a:opt, 'enabled_formater', s:enabled_formatters))
let s:sql_formatter_command = get(a:opt, 'sql_formatter_command', s:sql_formatter_command)
let s:sql_dialect = get(a:opt, 'sql_dialect', s:sql_dialect)
let s:sql_formatter_config = get(a:opt, 'sql_formatter_config', s:sql_formatter_config)
let s:sqlformat_cmd = get(a:opt, 'sqlformat_cmd', s:sqlformat_cmd)
let s:sqlformat_output_encode = get(a:opt, 'sqlformat_output_encode', s:sqlformat_output_encode)
endfunction
function! SpaceVim#layers#lang#sql#config() abort
let g:neoformat_enabled_sql = s:enabled_formatters
let argv = []
if !empty(s:sql_formatter_config)
let argv = ['-c', s:sql_formatter_config]
endif
let g:neoformat_sql_sqlfmtorg = {
\ 'exe': s:sql_formatter_command,
\ 'args': ['-l', s:sql_dialect,] + argv,
\ 'stdin': 1,
\ }
let g:neoformat_sql_sqlformat = {
\ 'exe': s:sqlformat_cmd,
\ 'args': ['--reindent', '-'],
\ 'output_encode': s:sqlformat_output_encode,
\ 'stdin': 1,
\ }
endfunction
function! SpaceVim#layers#lang#sql#health() abort
call SpaceVim#layers#lang#sql#plugins()
return 1
endfunction
function! SpaceVim#layers#lang#sql#loadable() abort
return 1
endfunction