utils 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +3 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/chroot-libs +1 -1
- data/bin/discover +10 -95
- data/bin/edit +53 -38
- data/bin/search +10 -156
- data/bin/strip_spaces +17 -5
- data/bin/xmp +1 -1
- data/lib/utils.rb +3 -0
- data/lib/utils/config/gdb/ruby +1 -15
- data/lib/utils/config/irbrc +5 -3
- data/lib/utils/config/vim/autoload/Align.vim +6 -6
- data/lib/utils/config/vim/autoload/rails.vim +16 -16
- data/lib/utils/config/vim/autoload/sqlcomplete.vim +48 -48
- data/lib/utils/config/vim/autoload/vimball.vim +7 -7
- data/lib/utils/config/vim/ftplugin/xml.vim +26 -26
- data/lib/utils/config/vim/indent/IndentAnything_html.vim +1 -1
- data/lib/utils/config/vim/indent/javascript.vim +4 -4
- data/lib/utils/config/vim/plugin/Decho.vim +14 -14
- data/lib/utils/config/vim/plugin/IndentAnything.vim +26 -26
- data/lib/utils/config/vim/plugin/bufexplorer.vim +16 -16
- data/lib/utils/config/vim/plugin/cecutil.vim +16 -16
- data/lib/utils/config/vim/plugin/rubyextra.vim +11 -11
- data/lib/utils/config/vim/plugin/taglist.vim +4 -4
- data/lib/utils/config/vim/plugin/test/IndentAnything/test.js +2 -2
- data/lib/utils/config/vim/syntax/javascript.vim +2 -2
- data/lib/utils/config/vim/syntax/ragel.vim +3 -3
- data/lib/utils/config/vimrc +1 -1
- data/lib/utils/editor.rb +138 -0
- data/lib/utils/finder.rb +92 -0
- data/lib/utils/grepper.rb +156 -0
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +15 -15
- metadata +67 -93
- data/lib/utils/edit.rb +0 -33
data/bin/strip_spaces
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'spruz/
|
4
|
-
include Spruz::
|
3
|
+
require 'spruz/secure_write'
|
4
|
+
include Spruz::SecureWrite
|
5
|
+
require 'utils'
|
6
|
+
include Utils::Find
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
class ::File
|
9
|
+
include Utils::FileXt
|
10
|
+
end
|
11
|
+
|
12
|
+
argv = ARGV.empty? ? %w[.] : ARGV
|
13
|
+
|
14
|
+
find(*argv) do |path|
|
15
|
+
File.basename(path) =~ /\A\./ and prune
|
16
|
+
File.directory?(path) and next
|
17
|
+
File.ascii?(path) or next
|
18
|
+
STDOUT.puts "Stripping spaces from #{path.inspect}."
|
19
|
+
secure_write(path) do |output|
|
20
|
+
File.open(path) do |file|
|
9
21
|
old_mode = file.stat.mode
|
10
22
|
file.each do |line|
|
11
23
|
line.gsub!(/[ \t\v]+$/, '')
|
data/bin/xmp
CHANGED
data/lib/utils.rb
CHANGED
data/lib/utils/config/gdb/ruby
CHANGED
@@ -53,7 +53,7 @@ define rp
|
|
53
53
|
else
|
54
54
|
set $rbasic = (struct RBasic*)$arg0
|
55
55
|
# output $rbasic
|
56
|
-
# echo \ =\
|
56
|
+
# echo \ =\
|
57
57
|
# output *$rbasic
|
58
58
|
# echo \n
|
59
59
|
set $flags = (*$rbasic).flags & 0x3f
|
@@ -179,32 +179,18 @@ define rp
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
182
|
-
document rp
|
183
|
-
ruby���Ȥ߹��ߥ��֥������Ȥ�ɽ������
|
184
|
-
end
|
185
182
|
|
186
183
|
define nd_type
|
187
184
|
print nodetype($arg0)
|
188
185
|
end
|
189
|
-
document nd_type
|
190
|
-
ruby node �η���ɽ��
|
191
|
-
end
|
192
186
|
|
193
187
|
define nd_file
|
194
188
|
print ((NODE*)$arg0)->nd_file
|
195
189
|
end
|
196
|
-
document nd_file
|
197
|
-
node �Υ������ե�����̾��ɽ��
|
198
|
-
end
|
199
190
|
|
200
191
|
define nd_line
|
201
192
|
print nodeline($arg0)
|
202
193
|
end
|
203
|
-
document nd_line
|
204
|
-
node �ι��ֹ��ɽ��
|
205
|
-
end
|
206
|
-
|
207
|
-
# ruby node �Υ��Ф�ɽ��
|
208
194
|
|
209
195
|
define nd_head
|
210
196
|
print "u1.node"
|
data/lib/utils/config/irbrc
CHANGED
@@ -11,6 +11,8 @@ begin
|
|
11
11
|
require 'ap'
|
12
12
|
rescue LoadError
|
13
13
|
end
|
14
|
+
require 'utils/editor'
|
15
|
+
$editor = Utils::Editor.new
|
14
16
|
|
15
17
|
$pager = ENV['PAGER'] || 'less -r'
|
16
18
|
|
@@ -139,7 +141,7 @@ class WrapperBase
|
|
139
141
|
def hash
|
140
142
|
@name.hash
|
141
143
|
end
|
142
|
-
|
144
|
+
|
143
145
|
def <=>(other)
|
144
146
|
@name <=> other.name
|
145
147
|
end
|
@@ -355,7 +357,7 @@ def irb_load_each(*files)
|
|
355
357
|
end
|
356
358
|
|
357
359
|
def irb_edit(*files)
|
358
|
-
|
360
|
+
$editor.edit(*files)
|
359
361
|
end
|
360
362
|
|
361
363
|
class Regexp
|
@@ -365,7 +367,7 @@ class Regexp
|
|
365
367
|
end
|
366
368
|
end
|
367
369
|
|
368
|
-
if IRB.conf[:PROMPT]
|
370
|
+
if IRB.conf[:PROMPT]
|
369
371
|
IRB.conf[:PROMPT][:CUSTOM] = {
|
370
372
|
:PROMPT_I => ">> ",
|
371
373
|
:PROMPT_N => ">> ",
|
@@ -857,7 +857,7 @@ endfun
|
|
857
857
|
|
858
858
|
" ---------------------------------------------------------------------
|
859
859
|
" Align#AlignReplaceQuotedSpaces: {{{1
|
860
|
-
fun! Align#AlignReplaceQuotedSpaces()
|
860
|
+
fun! Align#AlignReplaceQuotedSpaces()
|
861
861
|
" call Dfunc("AlignReplaceQuotedSpaces()")
|
862
862
|
|
863
863
|
let l:line = getline(line("."))
|
@@ -875,7 +875,7 @@ fun! Align#AlignReplaceQuotedSpaces()
|
|
875
875
|
" "call Decho("in replace spaces. line=" . line('.'))
|
876
876
|
while (1)
|
877
877
|
let l:startQuotePos = match(l:line, l:quoteRe, l:startingPos)
|
878
|
-
if (l:startQuotePos < 0)
|
878
|
+
if (l:startQuotePos < 0)
|
879
879
|
" "call Decho("No more quotes to the end of line")
|
880
880
|
break
|
881
881
|
endif
|
@@ -991,14 +991,14 @@ fun! s:Strlen(x)
|
|
991
991
|
let ret= strlen(substitute(a:x,'.','c','g'))
|
992
992
|
|
993
993
|
elseif g:Align_xstrlen == 2
|
994
|
-
" number of spacing codepoints (Latin a + combining circumflex is one spacing
|
994
|
+
" number of spacing codepoints (Latin a + combining circumflex is one spacing
|
995
995
|
" codepoint; a hard tab is one; wide and narrow CJK are one each; etc.)
|
996
996
|
" (comment from TM, solution from TM)
|
997
|
-
let ret=strlen(substitute(a:x, '.\Z', 'x', 'g'))
|
997
|
+
let ret=strlen(substitute(a:x, '.\Z', 'x', 'g'))
|
998
998
|
|
999
999
|
elseif g:Align_xstrlen == 3
|
1000
|
-
" virtual length (counting, for instance, tabs as anything between 1 and
|
1001
|
-
" 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately
|
1000
|
+
" virtual length (counting, for instance, tabs as anything between 1 and
|
1001
|
+
" 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately
|
1002
1002
|
" preceded by lam, one otherwise, etc.)
|
1003
1003
|
" (comment from TM, solution from me)
|
1004
1004
|
let modkeep= &l:mod
|
@@ -4155,15 +4155,15 @@ function! s:BufAbbreviations()
|
|
4155
4155
|
Rabbrev coo[ cookies
|
4156
4156
|
Rabbrev fl[ flash
|
4157
4157
|
Rabbrev rr( render
|
4158
|
-
Rabbrev ra( render :action\ =>\
|
4159
|
-
Rabbrev rc( render :controller\ =>\
|
4160
|
-
Rabbrev rf( render :file\ =>\
|
4161
|
-
Rabbrev ri( render :inline\ =>\
|
4162
|
-
Rabbrev rj( render :json\ =>\
|
4163
|
-
Rabbrev rl( render :layout\ =>\
|
4164
|
-
Rabbrev rp( render :partial\ =>\
|
4165
|
-
Rabbrev rt( render :text\ =>\
|
4166
|
-
Rabbrev rx( render :xml\ =>\
|
4158
|
+
Rabbrev ra( render :action\ =>\
|
4159
|
+
Rabbrev rc( render :controller\ =>\
|
4160
|
+
Rabbrev rf( render :file\ =>\
|
4161
|
+
Rabbrev ri( render :inline\ =>\
|
4162
|
+
Rabbrev rj( render :json\ =>\
|
4163
|
+
Rabbrev rl( render :layout\ =>\
|
4164
|
+
Rabbrev rp( render :partial\ =>\
|
4165
|
+
Rabbrev rt( render :text\ =>\
|
4166
|
+
Rabbrev rx( render :xml\ =>\
|
4167
4167
|
endif
|
4168
4168
|
if buffer.type_name('view','helper')
|
4169
4169
|
Rabbrev dotiw distance_of_time_in_words
|
@@ -4171,8 +4171,8 @@ function! s:BufAbbreviations()
|
|
4171
4171
|
endif
|
4172
4172
|
if buffer.type_name('controller')
|
4173
4173
|
Rabbrev re( redirect_to
|
4174
|
-
Rabbrev rea( redirect_to :action\ =>\
|
4175
|
-
Rabbrev rec( redirect_to :controller\ =>\
|
4174
|
+
Rabbrev rea( redirect_to :action\ =>\
|
4175
|
+
Rabbrev rec( redirect_to :controller\ =>\
|
4176
4176
|
Rabbrev rst( respond_to
|
4177
4177
|
endif
|
4178
4178
|
if buffer.type_name() ==# 'model' || buffer.type_name('model-arb')
|
@@ -4210,13 +4210,13 @@ function! s:BufAbbreviations()
|
|
4210
4210
|
Rabbrev asre( assert_response
|
4211
4211
|
Rabbrev art( assert_redirected_to
|
4212
4212
|
endif
|
4213
|
-
Rabbrev :a :action\ =>\
|
4213
|
+
Rabbrev :a :action\ =>\
|
4214
4214
|
" hax
|
4215
|
-
Rabbrev :c :co________\ =>\
|
4215
|
+
Rabbrev :c :co________\ =>\
|
4216
4216
|
inoreabbrev <buffer> <silent> :c <C-R>=<SID>TheCWord()<CR>
|
4217
|
-
Rabbrev :i :id\ =>\
|
4218
|
-
Rabbrev :o :object\ =>\
|
4219
|
-
Rabbrev :p :partial\ =>\
|
4217
|
+
Rabbrev :i :id\ =>\
|
4218
|
+
Rabbrev :o :object\ =>\
|
4219
|
+
Rabbrev :p :partial\ =>\
|
4220
4220
|
Rabbrev logd( logger.debug
|
4221
4221
|
Rabbrev logi( logger.info
|
4222
4222
|
Rabbrev logw( logger.warn
|
@@ -4,19 +4,19 @@
|
|
4
4
|
" Version: 9.0
|
5
5
|
" Last Change: 2010 May 13
|
6
6
|
" Usage: For detailed help
|
7
|
-
" ":help sql.txt"
|
8
|
-
" or ":help ft-sql-omni"
|
7
|
+
" ":help sql.txt"
|
8
|
+
" or ":help ft-sql-omni"
|
9
9
|
" or read $VIMRUNTIME/doc/sql.txt
|
10
10
|
|
11
11
|
" History
|
12
12
|
" Version 9.0
|
13
13
|
" This change removes some of the support for tables with spaces in their
|
14
|
-
" names in order to simplify the regexes used to pull out query table
|
14
|
+
" names in order to simplify the regexes used to pull out query table
|
15
15
|
" aliases for more robust table name and column name code completion.
|
16
16
|
" Full support for "table names with spaces" can be added in again
|
17
17
|
" after 7.3.
|
18
18
|
" Version 8.0
|
19
|
-
" Incorrectly re-executed the g:ftplugin_sql_omni_key_right and g:ftplugin_sql_omni_key_left
|
19
|
+
" Incorrectly re-executed the g:ftplugin_sql_omni_key_right and g:ftplugin_sql_omni_key_left
|
20
20
|
" when drilling in and out of a column list for a table.
|
21
21
|
" Version 7.0
|
22
22
|
" Better handling of object names
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"
|
26
26
|
" Set completion with CTRL-X CTRL-O to autoloaded function.
|
27
27
|
" This check is in place in case this script is
|
28
|
-
" sourced directly instead of using the autoload feature.
|
28
|
+
" sourced directly instead of using the autoload feature.
|
29
29
|
if exists('&omnifunc')
|
30
30
|
" Do not set the option if already set since this
|
31
31
|
" results in an E117 warning.
|
@@ -35,7 +35,7 @@ if exists('&omnifunc')
|
|
35
35
|
endif
|
36
36
|
|
37
37
|
if exists('g:loaded_sql_completion')
|
38
|
-
finish
|
38
|
+
finish
|
39
39
|
endif
|
40
40
|
let g:loaded_sql_completion = 70
|
41
41
|
|
@@ -50,7 +50,7 @@ let s:tbl_alias = []
|
|
50
50
|
let s:tbl_cols = []
|
51
51
|
let s:syn_list = []
|
52
52
|
let s:syn_value = []
|
53
|
-
|
53
|
+
|
54
54
|
" Used in conjunction with the syntaxcomplete plugin
|
55
55
|
let s:save_inc = ""
|
56
56
|
let s:save_exc = ""
|
@@ -60,7 +60,7 @@ endif
|
|
60
60
|
if exists('g:omni_syntax_group_exclude_sql')
|
61
61
|
let s:save_exc = g:omni_syntax_group_exclude_sql
|
62
62
|
endif
|
63
|
-
|
63
|
+
|
64
64
|
" Used with the column list
|
65
65
|
let s:save_prev_table = ""
|
66
66
|
|
@@ -91,7 +91,7 @@ if !exists('g:omni_sql_include_owner')
|
|
91
91
|
if g:loaded_dbext >= 300
|
92
92
|
" New to dbext 3.00, by default the table lists include the owner
|
93
93
|
" name of the table. This is used when determining how much of
|
94
|
-
" whatever has been typed should be replaced as part of the
|
94
|
+
" whatever has been typed should be replaced as part of the
|
95
95
|
" code replacement.
|
96
96
|
let g:omni_sql_include_owner = 1
|
97
97
|
endif
|
@@ -121,7 +121,7 @@ function! sqlcomplete#Complete(findstart, base)
|
|
121
121
|
let begindot = 1
|
122
122
|
endif
|
123
123
|
while start > 0
|
124
|
-
" Additional code was required to handle objects which
|
124
|
+
" Additional code was required to handle objects which
|
125
125
|
" can contain spaces like "my table name".
|
126
126
|
if line[start - 1] !~ '\(\w\|\.\)'
|
127
127
|
" If the previous character is not a period or word character
|
@@ -131,7 +131,7 @@ function! sqlcomplete#Complete(findstart, base)
|
|
131
131
|
elseif line[start - 1] =~ '\w'
|
132
132
|
" If the previous character is word character continue back
|
133
133
|
let start -= 1
|
134
|
-
elseif line[start - 1] =~ '\.' &&
|
134
|
+
elseif line[start - 1] =~ '\.' &&
|
135
135
|
\ compl_type =~ 'column\|table\|view\|procedure'
|
136
136
|
" If the previous character is a period and we are completing
|
137
137
|
" an object which can be specified with a period like this:
|
@@ -141,7 +141,7 @@ function! sqlcomplete#Complete(findstart, base)
|
|
141
141
|
" If lastword has already been set for column completion
|
142
142
|
" break from the loop, since we do not also want to pickup
|
143
143
|
" a table name if it was also supplied.
|
144
|
-
if lastword != -1 && compl_type == 'column'
|
144
|
+
if lastword != -1 && compl_type == 'column'
|
145
145
|
break
|
146
146
|
endif
|
147
147
|
" If column completion was specified stop at the "." if
|
@@ -152,8 +152,8 @@ function! sqlcomplete#Complete(findstart, base)
|
|
152
152
|
endif
|
153
153
|
" If omni_sql_include_owner = 0, do not include the table
|
154
154
|
" name as part of the substitution, so break here
|
155
|
-
if lastword == -1 &&
|
156
|
-
\ compl_type =~ 'table\|view\|procedure\column_csv' &&
|
155
|
+
if lastword == -1 &&
|
156
|
+
\ compl_type =~ 'table\|view\|procedure\column_csv' &&
|
157
157
|
\ g:omni_sql_include_owner == 0
|
158
158
|
let lastword = start
|
159
159
|
break
|
@@ -197,7 +197,7 @@ function! sqlcomplete#Complete(findstart, base)
|
|
197
197
|
|
198
198
|
if compl_type == 'table' ||
|
199
199
|
\ compl_type == 'procedure' ||
|
200
|
-
\ compl_type == 'view'
|
200
|
+
\ compl_type == 'view'
|
201
201
|
|
202
202
|
" This type of completion relies upon the dbext.vim plugin
|
203
203
|
if s:SQLCCheck4dbext() == -1
|
@@ -235,7 +235,7 @@ function! sqlcomplete#Complete(findstart, base)
|
|
235
235
|
|
236
236
|
if base == ""
|
237
237
|
" The last time we displayed a column list we stored
|
238
|
-
" the table name. If the user selects a column list
|
238
|
+
" the table name. If the user selects a column list
|
239
239
|
" without a table name of alias present, assume they want
|
240
240
|
" the previous column list displayed.
|
241
241
|
let base = s:save_prev_table
|
@@ -254,16 +254,16 @@ function! sqlcomplete#Complete(findstart, base)
|
|
254
254
|
" has entered:
|
255
255
|
" owner.table
|
256
256
|
" table.column_prefix
|
257
|
-
" So there are a couple of things we can do to mitigate
|
257
|
+
" So there are a couple of things we can do to mitigate
|
258
258
|
" this issue.
|
259
259
|
" 1. Check if the dbext plugin has the option turned
|
260
260
|
" on to even allow owners
|
261
261
|
" 2. Based on 1, if the user is showing a table list
|
262
|
-
" and the DrillIntoTable (using <Right>) then
|
262
|
+
" and the DrillIntoTable (using <Right>) then
|
263
263
|
" this will be owner.table. In this case, we can
|
264
|
-
" check to see the table.column exists in the
|
264
|
+
" check to see the table.column exists in the
|
265
265
|
" cached table list. If it does, then we have
|
266
|
-
" determined the user has actually chosen
|
266
|
+
" determined the user has actually chosen
|
267
267
|
" owner.table, not table.column_prefix.
|
268
268
|
let found = -1
|
269
269
|
if g:omni_sql_include_owner == 1 && owner == ''
|
@@ -288,7 +288,7 @@ function! sqlcomplete#Complete(findstart, base)
|
|
288
288
|
endif
|
289
289
|
|
290
290
|
" Get anything after the . and consider this the table name
|
291
|
-
" If an owner has been specified, then we must consider the
|
291
|
+
" If an owner has been specified, then we must consider the
|
292
292
|
" base to be a partial column name
|
293
293
|
" let base = matchstr( base, '^\(.*\.\)\?\zs.*' )
|
294
294
|
|
@@ -342,8 +342,8 @@ function! sqlcomplete#Complete(findstart, base)
|
|
342
342
|
|
343
343
|
if base != ''
|
344
344
|
" Filter the list based on the first few characters the user entered.
|
345
|
-
" Check if the text matches at the beginning
|
346
|
-
" or
|
345
|
+
" Check if the text matches at the beginning
|
346
|
+
" or
|
347
347
|
" Match to a owner.table or alias.column type match
|
348
348
|
" or
|
349
349
|
" Handle names with spaces "my table name"
|
@@ -363,7 +363,7 @@ endfunc
|
|
363
363
|
|
364
364
|
function! sqlcomplete#PreCacheSyntax(...)
|
365
365
|
let syn_group_arr = []
|
366
|
-
if a:0 > 0
|
366
|
+
if a:0 > 0
|
367
367
|
let syn_group_arr = a:1
|
368
368
|
else
|
369
369
|
let syn_group_arr = g:omni_sql_precache_syntax_groups
|
@@ -404,7 +404,7 @@ function! sqlcomplete#DrillIntoTable()
|
|
404
404
|
" If the popup is not visible, simple perform the normal
|
405
405
|
" key behaviour.
|
406
406
|
" Must use exec since they key must be preceeded by "\"
|
407
|
-
" or feedkeys will simply push each character of the string
|
407
|
+
" or feedkeys will simply push each character of the string
|
408
408
|
" rather than the "key press".
|
409
409
|
exec 'call feedkeys("\'.g:ftplugin_sql_omni_key_right.'", "n")'
|
410
410
|
endif
|
@@ -421,7 +421,7 @@ function! sqlcomplete#DrillOutOfColumns()
|
|
421
421
|
" If the popup is not visible, simple perform the normal
|
422
422
|
" key behaviour.
|
423
423
|
" Must use exec since they key must be preceeded by "\"
|
424
|
-
" or feedkeys will simply push each character of the string
|
424
|
+
" or feedkeys will simply push each character of the string
|
425
425
|
" rather than the "key press".
|
426
426
|
exec 'call feedkeys("\'.g:ftplugin_sql_omni_key_left.'", "n")'
|
427
427
|
endif
|
@@ -430,16 +430,16 @@ endfunction
|
|
430
430
|
|
431
431
|
function! s:SQLCWarningMsg(msg)
|
432
432
|
echohl WarningMsg
|
433
|
-
echomsg a:msg
|
433
|
+
echomsg a:msg
|
434
434
|
echohl None
|
435
435
|
endfunction
|
436
|
-
|
436
|
+
|
437
437
|
function! s:SQLCErrorMsg(msg)
|
438
438
|
echohl ErrorMsg
|
439
|
-
echomsg a:msg
|
439
|
+
echomsg a:msg
|
440
440
|
echohl None
|
441
441
|
endfunction
|
442
|
-
|
442
|
+
|
443
443
|
function! s:SQLCGetSyntaxList(syn_group)
|
444
444
|
let syn_group = a:syn_group
|
445
445
|
let compl_list = []
|
@@ -450,7 +450,7 @@ function! s:SQLCGetSyntaxList(syn_group)
|
|
450
450
|
" Return previously cached value
|
451
451
|
let compl_list = s:syn_value[list_idx]
|
452
452
|
else
|
453
|
-
" Request the syntax list items from the
|
453
|
+
" Request the syntax list items from the
|
454
454
|
" syntax completion plugin
|
455
455
|
if syn_group == 'syntax'
|
456
456
|
" Handle this special case. This allows the user
|
@@ -498,7 +498,7 @@ function! s:SQLCAddAlias(table_name, table_alias, cols)
|
|
498
498
|
let table_alias = a:table_alias
|
499
499
|
let cols = a:cols
|
500
500
|
|
501
|
-
if g:omni_sql_use_tbl_alias != 'n'
|
501
|
+
if g:omni_sql_use_tbl_alias != 'n'
|
502
502
|
if table_alias == ''
|
503
503
|
if 'da' =~? g:omni_sql_use_tbl_alias
|
504
504
|
if table_name =~ '_'
|
@@ -508,13 +508,13 @@ function! s:SQLCAddAlias(table_name, table_alias, cols)
|
|
508
508
|
setlocal iskeyword-=_
|
509
509
|
|
510
510
|
" Get the first letter of each word
|
511
|
-
" [[:alpha:]] is used instead of \w
|
511
|
+
" [[:alpha:]] is used instead of \w
|
512
512
|
" to catch extended accented characters
|
513
513
|
"
|
514
|
-
let table_alias = substitute(
|
515
|
-
\ table_name,
|
516
|
-
\ '\<[[:alpha:]]\+\>_\?',
|
517
|
-
\ '\=strpart(submatch(0), 0, 1)',
|
514
|
+
let table_alias = substitute(
|
515
|
+
\ table_name,
|
516
|
+
\ '\<[[:alpha:]]\+\>_\?',
|
517
|
+
\ '\=strpart(submatch(0), 0, 1)',
|
518
518
|
\ 'g'
|
519
519
|
\ )
|
520
520
|
" Restore original value
|
@@ -542,7 +542,7 @@ function! s:SQLCAddAlias(table_name, table_alias, cols)
|
|
542
542
|
return cols
|
543
543
|
endfunction
|
544
544
|
|
545
|
-
function! s:SQLCGetObjectOwner(object)
|
545
|
+
function! s:SQLCGetObjectOwner(object)
|
546
546
|
" The owner regex matches a word at the start of the string which is
|
547
547
|
" followed by a dot, but doesn't include the dot in the result.
|
548
548
|
" ^ - from beginning of line
|
@@ -555,7 +555,7 @@ function! s:SQLCGetObjectOwner(object)
|
|
555
555
|
" let owner = matchstr( a:object, '^\s*\zs.*\ze\.' )
|
556
556
|
let owner = matchstr( a:object, '^\("\|\[\)\?\zs\.\{-}\ze\("\|\]\)\?\.' )
|
557
557
|
return owner
|
558
|
-
endfunction
|
558
|
+
endfunction
|
559
559
|
|
560
560
|
function! s:SQLCGetColumns(table_name, list_type)
|
561
561
|
" Check if the table name was provided as part of the column name
|
@@ -582,7 +582,7 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
582
582
|
if list_idx > -1
|
583
583
|
let table_cols = split(s:tbl_cols[list_idx], '\n')
|
584
584
|
else
|
585
|
-
" Check if we have already cached the column list for this table
|
585
|
+
" Check if we have already cached the column list for this table
|
586
586
|
" by its alias, assuming the table_name provided was actually
|
587
587
|
" the alias for the table instead
|
588
588
|
" select *
|
@@ -600,7 +600,7 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
600
600
|
" And the table ends in a "." or we are looking for a column list
|
601
601
|
" if list_idx == -1 && (a:table_name =~ '\.' || b:sql_compl_type =~ 'column')
|
602
602
|
" if list_idx == -1 && (a:table_name =~ '\.' || a:list_type =~ 'csv')
|
603
|
-
if list_idx == -1
|
603
|
+
if list_idx == -1
|
604
604
|
let saveY = @y
|
605
605
|
let saveSearch = @/
|
606
606
|
let saveWScan = &wrapscan
|
@@ -611,7 +611,7 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
611
611
|
setlocal nowrapscan
|
612
612
|
" If . was entered, look at the word just before the .
|
613
613
|
" We are looking for something like this:
|
614
|
-
" select *
|
614
|
+
" select *
|
615
615
|
" from customer c
|
616
616
|
" where c.
|
617
617
|
" So when . is pressed, we need to find 'c'
|
@@ -638,15 +638,15 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
638
638
|
" if query =~? '^\c\(select\)'
|
639
639
|
if query =~? '^\(select\|update\|delete\)'
|
640
640
|
let found = 1
|
641
|
-
" \(\(\<\w\+\>\)\.\)\? -
|
641
|
+
" \(\(\<\w\+\>\)\.\)\? -
|
642
642
|
" '\c\(from\|join\|,\).\{-}' - Starting at the from clause (case insensitive)
|
643
643
|
" '\zs\(\(\<\w\+\>\)\.\)\?' - Get the owner name (optional)
|
644
|
-
" '\<\w\+\>\ze' - Get the table name
|
644
|
+
" '\<\w\+\>\ze' - Get the table name
|
645
645
|
" '\s\+\<'.table_name.'\>' - Followed by the alias
|
646
646
|
" '\s*\.\@!.*' - Cannot be followed by a .
|
647
647
|
" '\(\<where\>\|$\)' - Must be followed by a WHERE clause
|
648
648
|
" '.*' - Exclude the rest of the line in the match
|
649
|
-
" let table_name_new = matchstr(@y,
|
649
|
+
" let table_name_new = matchstr(@y,
|
650
650
|
" \ '\c\(from\|join\|,\).\{-}'.
|
651
651
|
" \ '\zs\(\("\|\[\)\?.\{-}\("\|\]\)\.\)\?'.
|
652
652
|
" \ '\("\|\[\)\?.\{-}\("\|\]\)\?\ze'.
|
@@ -657,7 +657,7 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
657
657
|
" \ '\(\<where\>\|$\)'.
|
658
658
|
" \ '.*'
|
659
659
|
" \ )
|
660
|
-
let table_name_new = matchstr(@y,
|
660
|
+
let table_name_new = matchstr(@y,
|
661
661
|
\ '\c\(\<from\>\|\<join\>\|,\)\s*'.
|
662
662
|
\ '\zs\(\("\|\[\)\?\w\+\("\|\]\)\?\.\)\?'.
|
663
663
|
\ '\("\|\[\)\?\w\+\("\|\]\)\?\ze'.
|
@@ -699,7 +699,7 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
699
699
|
|
700
700
|
" Return to previous location
|
701
701
|
call cursor(curline, curcol)
|
702
|
-
|
702
|
+
|
703
703
|
if found == 0
|
704
704
|
if g:loaded_dbext > 300
|
705
705
|
exec 'DBSetOption use_tbl_alias='.saveSettingAlias
|
@@ -708,7 +708,7 @@ function! s:SQLCGetColumns(table_name, list_type)
|
|
708
708
|
" Not a SQL statement, do not display a list
|
709
709
|
return []
|
710
710
|
endif
|
711
|
-
endif
|
711
|
+
endif
|
712
712
|
|
713
713
|
if empty(table_cols)
|
714
714
|
" Specify silent mode, no messages to the user (tbl, 1)
|