@@ -8,24 +8,30 @@ if exists("g:vim_mysql_plugin_loaded") || &cp
8
8
endif
9
9
10
10
let g: vim_mysql_plugin_loaded = 1
11
+ let g: vim_mysql_plugin_sqleof = ' ;'
11
12
12
13
fun ! g: RunShellCommand (shell_command)
13
- echohl String | echon ' ¦ $ ' . a: shell_command . ' ...' | echohl None
14
+ echohl String | echon ' $ ' . a: shell_command[ 0 : winwidth ( 0 ) -11 ] . ' ...' | echohl None
14
15
15
16
silent ! exe " noautocmd botright pedit ¦"
16
17
noautocmd wincmd P
18
+ setl stl = Running... please\ wait
19
+ redraw
17
20
setlocal modifiable
18
21
setlocal nowrap
19
22
normal ggdG
20
23
21
24
set buftype = nofile
22
25
silent ! exe " noautocmd .! " . a: shell_command
23
- normal gg
26
+ normal ggG
27
+ let time = getline (" ." )
28
+ exe ' setl stl=Done\ in\ ' . time[6 :]
29
+ normal kdG
24
30
setlocal nomodifiable
25
31
noautocmd wincmd p
26
32
redraw !
27
33
28
- echohl Comment | echon ' Done! ' . a: shell_command | echohl None
34
+ echohl Comment | echon ' $ ' . a: shell_command[ 0 : winwidth ( 0 ) -11 ] . ' ... ' | echohl None
29
35
endfun
30
36
31
37
fun ! g: GetSelection ()
@@ -47,7 +53,7 @@ fun! g:RunArray(sqlarray, timing)
47
53
endif
48
54
49
55
if a: timing
50
- let l: thesql = [' SELECT NOW(3)+0 INTO @startTime;' ] + a: sqlarray + [' ; SELECT CONCAT(ROUND(NOW(3) - @startTime, 3), "s") Took' ]
56
+ let l: thesql = [' SELECT NOW(3)+0 INTO @startTime;' ] + a: sqlarray + [' ; SELECT CONCAT(ROUND(NOW(3) - @startTime, 3), "s") Took\G ' ]
51
57
else
52
58
let l: thesql = a: sqlarray
53
59
endif
@@ -64,27 +70,39 @@ endfun
64
70
65
71
func ! g: SelectCursorTable ()
66
72
let l: Table = expand (' <cword>' )
67
- call RunArray ([' SELECT * FROM `' . l: Table . ' ` LIMIT 100; ' ], 0 )
73
+ call RunArray ([' SELECT * FROM `' . l: Table . ' ` LIMIT 100' . g: vim_mysql_plugin_sqleof ], 0 )
68
74
endfun
69
75
70
76
func ! g: DescriptCursorTable ()
71
77
let l: Table = expand (' <cword>' )
72
- call RunArray ([' SHOW FULL COLUMNS FROM `' . l: Table . ' `;' ], 0 )
78
+ call RunArray ([' SHOW FULL COLUMNS FROM `' . l: Table . ' `' . g: vim_mysql_plugin_sqleof ], 0 )
79
+ endfun
80
+
81
+ fun ! s: SetEosql (line )
82
+ let eosql = getline (a: line )
83
+ let m = matchstr (eosql, ' ;' )
84
+ if (empty (m ))
85
+ let g: vim_mysql_plugin_sqleof = ' \G'
86
+ else
87
+ let g: vim_mysql_plugin_sqleof = ' ;'
88
+ endif
73
89
endfun
74
90
75
91
fun ! s: GetInstruction ()
76
- let l: PrevSemicolon = search (' ;' , ' bnW' )
77
- let l: NextSemicolon = search (' ;' , ' nW' )
92
+ let l: p = ' \(\G\|;\)'
93
+ let l: PrevSemicolon = search (l: p , ' bnW' )
94
+ let l: NextSemicolon = search (l: p , ' cnW' )
95
+ call s: SetEosql (l: NextSemicolon )
78
96
return getline (l: PrevSemicolon , l: NextSemicolon )[1 :]
79
97
endfun
80
98
81
99
fun ! g: RunInstruction ()
82
- let l: Lines = s: GetInstruction ()
100
+ let l: Lines = s: GetInstruction ()
83
101
call g: RunArray (l: Lines , 1 )
84
102
endfun
85
103
86
104
fun ! g: RunExplain ()
87
- let l: Lines = s: GetInstruction ()
105
+ let l: Lines = s: GetInstruction ()
88
106
call g: RunArray ([' explain ' ] + l: Lines , 1 )
89
107
endfun
90
108
0 commit comments