1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 20:10:05 +08:00

feat(sql): improve lang#sql layer

This commit is contained in:
Eric Wong 2024-03-12 01:19:02 +08:00
parent 681fe2f16d
commit dcfc4b0404
2 changed files with 106 additions and 35 deletions

View File

@ -6,12 +6,62 @@
" License: GPLv3 " 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_formater`: set the default formatter for sql, default is ['sqlfmtorg']
" https://github.com/sql-formatter-org/sql-formatter
" 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.
"
if exists('s:enabled_formater')
finish
endif
let s:enabled_formater = ['sqlfmtorg']
let s:sql_formatter_command = 'sql-formatter'
let s:sql_dialect = 'sql'
let s:sql_formatter_config = ''
function! SpaceVim#layers#lang#sql#plugins() abort function! SpaceVim#layers#lang#sql#plugins() abort
let plugins = [] let plugins = []
call add(plugins, ['tpope/vim-dadbod', {'merged' : 0}]) call add(plugins, ['tpope/vim-dadbod', {'merged' : 0}])
return plugins return plugins
endfunction endfunction
function! SpaceVim#layers#lang#sql#set_variable(opt) abort
let s:enabled_formater = get(a:opt, 'enabled_formater', s:enabled_formater)
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)
endfunction
function! SpaceVim#layers#lang#sql#config() abort
let g:neoformat_enabled_sql = s:enabled_formater
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,
\ }
endfunction
function! SpaceVim#layers#lang#sql#health() abort function! SpaceVim#layers#lang#sql#health() abort
call SpaceVim#layers#lang#sql#plugins() call SpaceVim#layers#lang#sql#plugins()
return 1 return 1

View File

@ -208,41 +208,42 @@ CONTENTS *SpaceVim-contents*
109. lang#sh...................................|SpaceVim-layers-lang-sh| 109. lang#sh...................................|SpaceVim-layers-lang-sh|
110. lang#smalltalk.....................|SpaceVim-layers-lang-smalltalk| 110. lang#smalltalk.....................|SpaceVim-layers-lang-smalltalk|
111. lang#sml.................................|SpaceVim-layers-lang-sml| 111. lang#sml.................................|SpaceVim-layers-lang-sml|
112. lang#swift.............................|SpaceVim-layers-lang-swift| 112. lang#sql.................................|SpaceVim-layers-lang-sql|
113. lang#swig...............................|SpaceVim-layers-lang-swig| 113. lang#swift.............................|SpaceVim-layers-lang-swift|
114. lang#tcl.................................|SpaceVim-layers-lang-tcl| 114. lang#swig...............................|SpaceVim-layers-lang-swig|
115. lang#teal...............................|SpaceVim-layers-lang-teal| 115. lang#tcl.................................|SpaceVim-layers-lang-tcl|
116. lang#toml...............................|SpaceVim-layers-lang-toml| 116. lang#teal...............................|SpaceVim-layers-lang-teal|
117. lang#typescript...................|SpaceVim-layers-lang-typescript| 117. lang#toml...............................|SpaceVim-layers-lang-toml|
118. lang#v.....................................|SpaceVim-layers-lang-v| 118. lang#typescript...................|SpaceVim-layers-lang-typescript|
119. lang#vala...............................|SpaceVim-layers-lang-vala| 119. lang#v.....................................|SpaceVim-layers-lang-v|
120. lang#vbnet.............................|SpaceVim-layers-lang-vbnet| 120. lang#vala...............................|SpaceVim-layers-lang-vala|
121. lang#verilog.........................|SpaceVim-layers-lang-verilog| 121. lang#vbnet.............................|SpaceVim-layers-lang-vbnet|
122. lang#vim.................................|SpaceVim-layers-lang-vim| 122. lang#verilog.........................|SpaceVim-layers-lang-verilog|
123. lang#vue.................................|SpaceVim-layers-lang-vue| 123. lang#vim.................................|SpaceVim-layers-lang-vim|
124. lang#wdl.................................|SpaceVim-layers-lang-wdl| 124. lang#vue.................................|SpaceVim-layers-lang-vue|
125. lang#wolfram.........................|SpaceVim-layers-lang-wolfram| 125. lang#wdl.................................|SpaceVim-layers-lang-wdl|
126. lang#xml.................................|SpaceVim-layers-lang-xml| 126. lang#wolfram.........................|SpaceVim-layers-lang-wolfram|
127. lang#xquery...........................|SpaceVim-layers-lang-xquery| 127. lang#xml.................................|SpaceVim-layers-lang-xml|
128. lang#yang...............................|SpaceVim-layers-lang-yang| 128. lang#xquery...........................|SpaceVim-layers-lang-xquery|
129. lang#zig.................................|SpaceVim-layers-lang-zig| 129. lang#yang...............................|SpaceVim-layers-lang-yang|
130. language server protocol......................|SpaceVim-layers-lsp| 130. lang#zig.................................|SpaceVim-layers-lang-zig|
131. leaderf...................................|SpaceVim-layers-leaderf| 131. language server protocol......................|SpaceVim-layers-lsp|
132. mail.........................................|SpaceVim-layers-mail| 132. leaderf...................................|SpaceVim-layers-leaderf|
133. operator.................................|SpaceVim-layers-operator| 133. mail.........................................|SpaceVim-layers-mail|
134. shell.......................................|SpaceVim-layers-shell| 134. operator.................................|SpaceVim-layers-operator|
135. ssh...........................................|SpaceVim-layers-ssh| 135. shell.......................................|SpaceVim-layers-shell|
136. telescope...............................|SpaceVim-layers-telescope| 136. ssh...........................................|SpaceVim-layers-ssh|
137. test.........................................|SpaceVim-layers-test| 137. telescope...............................|SpaceVim-layers-telescope|
138. tmux.........................................|SpaceVim-layers-tmux| 138. test.........................................|SpaceVim-layers-test|
139. tools#dash.............................|SpaceVim-layers-tools-dash| 139. tmux.........................................|SpaceVim-layers-tmux|
140. tools#mpv...............................|SpaceVim-layers-tools-mpv| 140. tools#dash.............................|SpaceVim-layers-tools-dash|
141. tools#screensaver...............|SpaceVim-layers-tools-screensaver| 141. tools#mpv...............................|SpaceVim-layers-tools-mpv|
142. tools#zeal.............................|SpaceVim-layers-tools-zeal| 142. tools#screensaver...............|SpaceVim-layers-tools-screensaver|
143. treesitter.............................|SpaceVim-layers-treesitter| 143. tools#zeal.............................|SpaceVim-layers-tools-zeal|
144. ui.............................................|SpaceVim-layers-ui| 144. treesitter.............................|SpaceVim-layers-treesitter|
145. unite.......................................|SpaceVim-layers-unite| 145. ui.............................................|SpaceVim-layers-ui|
146. xmake.......................................|SpaceVim-layers-xmake| 146. unite.......................................|SpaceVim-layers-unite|
147. xmake.......................................|SpaceVim-layers-xmake|
7. Usage....................................................|SpaceVim-usage| 7. Usage....................................................|SpaceVim-usage|
1. alternate file........................|SpaceVim-usage-alternate-file| 1. alternate file........................|SpaceVim-usage-alternate-file|
2. buffers-and-files..................|SpaceVim-usage-buffers-and-files| 2. buffers-and-files..................|SpaceVim-usage-buffers-and-files|
@ -5172,6 +5173,26 @@ Here is an example how to use above options:
auto_create_def_use = 'always' auto_create_def_use = 'always'
< <
==============================================================================
LANG#SQL *SpaceVim-layers-lang-sql*
This layer is for sql development, disabled by default, to enable this layer,
add following snippet to your |SpaceVim-options| file.
>
[[layers]]
name = 'lang#sql'
<
OPTIONS
1. `enabled_formater`: set the default formatter for sql, default is
['sqlfmtorg'] https://github.com/sql-formatter-org/sql-formatter
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.
============================================================================== ==============================================================================
LANG#SWIFT *SpaceVim-layers-lang-swift* LANG#SWIFT *SpaceVim-layers-lang-swift*