Mercurial > vim
comparison runtime/autoload/sqlcomplete.vim @ 2034:7bc41231fbc7
Update runtime files.
author | Bram Moolenaar <bram@zimbu.org> |
---|---|
date | Wed, 06 Jan 2010 20:54:52 +0100 |
parents | 18ee39301b82 |
children | b9e314fe473f |
comparison
equal
deleted
inserted
replaced
2033:de5a43c5eedc | 2034:7bc41231fbc7 |
---|---|
1 " Vim OMNI completion script for SQL | 1 " Vim OMNI completion script for SQL |
2 " Language: SQL | 2 " Language: SQL |
3 " Maintainer: David Fishburn <fishburn@ianywhere.com> | 3 " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com> |
4 " Version: 6.0 | 4 " Version: 7.0 |
5 " Last Change: Thu 03 Apr 2008 10:37:54 PM Eastern Daylight Time | 5 " Last Change: 2009 Jan 04 |
6 " Usage: For detailed help | 6 " Usage: For detailed help |
7 " ":help sql.txt" | 7 " ":help sql.txt" |
8 " or ":help ft-sql-omni" | 8 " or ":help ft-sql-omni" |
9 " or read $VIMRUNTIME/doc/sql.txt | 9 " or read $VIMRUNTIME/doc/sql.txt |
10 | 10 |
11 " History | |
12 " Version 7.0 | |
13 " Better handling of object names | |
14 " Version 6.0 | |
15 " Supports object names with spaces "my table name" | |
16 " | |
11 " Set completion with CTRL-X CTRL-O to autoloaded function. | 17 " Set completion with CTRL-X CTRL-O to autoloaded function. |
12 " This check is in place in case this script is | 18 " This check is in place in case this script is |
13 " sourced directly instead of using the autoload feature. | 19 " sourced directly instead of using the autoload feature. |
14 if exists('&omnifunc') | 20 if exists('&omnifunc') |
15 " Do not set the option if already set since this | 21 " Do not set the option if already set since this |
20 endif | 26 endif |
21 | 27 |
22 if exists('g:loaded_sql_completion') | 28 if exists('g:loaded_sql_completion') |
23 finish | 29 finish |
24 endif | 30 endif |
25 let g:loaded_sql_completion = 50 | 31 let g:loaded_sql_completion = 70 |
26 | 32 |
27 " Maintains filename of dictionary | 33 " Maintains filename of dictionary |
28 let s:sql_file_table = "" | 34 let s:sql_file_table = "" |
29 let s:sql_file_procedure = "" | 35 let s:sql_file_procedure = "" |
30 let s:sql_file_view = "" | 36 let s:sql_file_view = "" |
104 " Check if the first character is a ".", for column completion | 110 " Check if the first character is a ".", for column completion |
105 if line[start - 1] == '.' | 111 if line[start - 1] == '.' |
106 let begindot = 1 | 112 let begindot = 1 |
107 endif | 113 endif |
108 while start > 0 | 114 while start > 0 |
109 if line[start - 1] =~ '\(\w\|\s\+\)' | 115 " Additional code was required to handle objects which |
116 " can contain spaces like "my table name". | |
117 if line[start - 1] !~ '\(\w\|\.\)' | |
118 " If the previous character is not a period or word character | |
119 break | |
120 " elseif line[start - 1] =~ '\(\w\|\s\+\)' | |
121 " let start -= 1 | |
122 elseif line[start - 1] =~ '\w' | |
123 " If the previous character is word character continue back | |
110 let start -= 1 | 124 let start -= 1 |
111 elseif line[start - 1] =~ '\.' && | 125 elseif line[start - 1] =~ '\.' && |
112 \ compl_type =~ 'column\|table\|view\|procedure' | 126 \ compl_type =~ 'column\|table\|view\|procedure' |
127 " If the previous character is a period and we are completing | |
128 " an object which can be specified with a period like this: | |
129 " table_name.column_name | |
130 " owner_name.table_name | |
131 | |
113 " If lastword has already been set for column completion | 132 " If lastword has already been set for column completion |
114 " break from the loop, since we do not also want to pickup | 133 " break from the loop, since we do not also want to pickup |
115 " a table name if it was also supplied. | 134 " a table name if it was also supplied. |
116 if lastword != -1 && compl_type == 'column' | 135 if lastword != -1 && compl_type == 'column' |
117 break | 136 break |
182 let saveSetting = DB_listOption('dict_show_owner') | 201 let saveSetting = DB_listOption('dict_show_owner') |
183 exec 'DBSetOption dict_show_owner='.(g:omni_sql_include_owner==1?'1':'0') | 202 exec 'DBSetOption dict_show_owner='.(g:omni_sql_include_owner==1?'1':'0') |
184 endif | 203 endif |
185 | 204 |
186 let compl_type_uc = substitute(compl_type, '\w\+', '\u&', '') | 205 let compl_type_uc = substitute(compl_type, '\w\+', '\u&', '') |
187 if s:sql_file_{compl_type} == "" | 206 " Same call below, no need to do it twice |
188 let s:sql_file_{compl_type} = DB_getDictionaryName(compl_type_uc) | 207 " if s:sql_file_{compl_type} == "" |
189 endif | 208 " let s:sql_file_{compl_type} = DB_getDictionaryName(compl_type_uc) |
209 " endif | |
190 let s:sql_file_{compl_type} = DB_getDictionaryName(compl_type_uc) | 210 let s:sql_file_{compl_type} = DB_getDictionaryName(compl_type_uc) |
191 if s:sql_file_{compl_type} != "" | 211 if s:sql_file_{compl_type} != "" |
192 if filereadable(s:sql_file_{compl_type}) | 212 if filereadable(s:sql_file_{compl_type}) |
193 let compl_list = readfile(s:sql_file_{compl_type}) | 213 let compl_list = readfile(s:sql_file_{compl_type}) |
194 endif | 214 endif |
310 else | 330 else |
311 let compl_list = s:SQLCGetSyntaxList(compl_type) | 331 let compl_list = s:SQLCGetSyntaxList(compl_type) |
312 endif | 332 endif |
313 | 333 |
314 if base != '' | 334 if base != '' |
315 " Filter the list based on the first few characters the user | 335 " Filter the list based on the first few characters the user entered. |
316 " entered | 336 " Check if the text matches at the beginning |
317 let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "\\(^'.base.'\\|\\([^.]*\\)\\?'.base.'\\)"' | 337 " or |
338 " Match to a owner.table or alias.column type match | |
339 " or | |
340 " Handle names with spaces "my table name" | |
341 let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "\\(^'.base.'\\|^\\(\\w\\+\\.\\)\\?'.base.'\\)"' | |
342 " let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "\\(^'.base.'\\)"' | |
343 " let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "\\(^'.base.'\\|\\(\\.\\)\\?'.base.'\\)"' | |
344 " let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "\\(^'.base.'\\|\\([^.]*\\)\\?'.base.'\\)"' | |
318 let compl_list = filter(deepcopy(compl_list), expr) | 345 let compl_list = filter(deepcopy(compl_list), expr) |
319 endif | 346 endif |
320 | 347 |
321 if exists('b:sql_compl_savefunc') && b:sql_compl_savefunc != "" | 348 if exists('b:sql_compl_savefunc') && b:sql_compl_savefunc != "" |
322 let &omnifunc = b:sql_compl_savefunc | 349 let &omnifunc = b:sql_compl_savefunc |