comparison runtime/ftplugin/sql.vim @ 2034:7bc41231fbc7

Update runtime files.
author Bram Moolenaar <bram@zimbu.org>
date Wed, 06 Jan 2010 20:54:52 +0100
parents 73fe8baea242
children 22a6f99e6477
comparison
equal deleted inserted replaced
2033:de5a43c5eedc 2034:7bc41231fbc7
1 " SQL filetype plugin file 1 " SQL filetype plugin file
2 " Language: SQL (Common for Oracle, Microsoft SQL Server, Sybase) 2 " Language: SQL (Common for Oracle, Microsoft SQL Server, Sybase)
3 " Version: 4.0 3 " Version: 6.0
4 " Maintainer: David Fishburn <fishburn at ianywhere dot com> 4 " Maintainer: David Fishburn <fishburn at ianywhere dot com>
5 " Last Change: Wed 27 Feb 2008 04:35:21 PM Eastern Standard Time 5 " Last Change: 2009 Aug 04
6 " Download: http://vim.sourceforge.net/script.php?script_id=454 6 " Download: http://vim.sourceforge.net/script.php?script_id=454
7 7
8 " For more details please use: 8 " For more details please use:
9 " :h sql.txt 9 " :h sql.txt
10 " 10 "
27 " basis. NOTE: you can also use completion: 27 " basis. NOTE: you can also use completion:
28 " :SQLSetType <tab> 28 " :SQLSetType <tab>
29 " 29 "
30 " To change the default dialect, add the following to your vimrc: 30 " To change the default dialect, add the following to your vimrc:
31 " let g:sql_type_default = 'sqlanywhere' 31 " let g:sql_type_default = 'sqlanywhere'
32 "
33 " This file also creates a command, SQLGetType, which allows you to
34 " determine what the current dialect is in use.
35 " :SQLGetType
36 "
37 " History
38 "
39 " Version 6.0
40 "
41 " NF: Adds the command SQLGetType
42 "
43 " Version 5.0
44 "
45 " NF: Adds the ability to choose the keys to control SQL completion, just add
46 " the following to your .vimrc:
47 " let g:ftplugin_sql_omni_key = '<C-C>'
48 " let g:ftplugin_sql_omni_key_right = '<Right>'
49 " let g:ftplugin_sql_omni_key_left = '<Left>'
50 "
51 " BF: format-options - Auto-wrap comments using textwidth was turned off
52 " by mistake.
32 53
33 54
34 " Only do this when not done yet for this buffer 55 " Only do this when not done yet for this buffer
35 if exists("b:did_ftplugin") 56 if exists("b:did_ftplugin")
36 finish 57 finish
42 " Disable autowrapping for code, but enable for comments 63 " Disable autowrapping for code, but enable for comments
43 " t Auto-wrap text using textwidth 64 " t Auto-wrap text using textwidth
44 " c Auto-wrap comments using textwidth, inserting the current comment 65 " c Auto-wrap comments using textwidth, inserting the current comment
45 " leader automatically. 66 " leader automatically.
46 setlocal formatoptions-=t 67 setlocal formatoptions-=t
47 setlocal formatoptions-=c 68 setlocal formatoptions+=c
48 69
49 " Functions/Commands to allow the user to change SQL syntax dialects 70 " Functions/Commands to allow the user to change SQL syntax dialects
50 " through the use of :SQLSetType <tab> for completion. 71 " through the use of :SQLSetType <tab> for completion.
51 " This works with both Vim 6 and 7. 72 " This works with both Vim 6 and 7.
52 73
150 " the existing filetype. 171 " the existing filetype.
151 let &filetype = 'sql' 172 let &filetype = 'sql'
152 endfunction 173 endfunction
153 command! -nargs=* -complete=custom,SQL_GetList SQLSetType :call SQL_SetType(<q-args>) 174 command! -nargs=* -complete=custom,SQL_GetList SQLSetType :call SQL_SetType(<q-args>)
154 175
176 endif
177
178 " Functions/Commands to allow the user determine current SQL syntax dialect
179 " This works with both Vim 6 and 7.
180
181 if !exists("*SQL_GetType")
182 function SQL_GetType()
183 if exists('b:sql_type_override')
184 echomsg "Current SQL dialect in use:".b:sql_type_override
185 else
186 echomsg "Current SQL dialect in use:".g:sql_type_default
187 endif
188 endfunction
189 command! -nargs=0 SQLGetType :call SQL_GetType()
155 endif 190 endif
156 191
157 if exists("b:sql_type_override") 192 if exists("b:sql_type_override")
158 " echo 'sourcing buffer ftplugin/'.b:sql_type_override.'.vim' 193 " echo 'sourcing buffer ftplugin/'.b:sql_type_override.'.vim'
159 if globpath(&runtimepath, 'ftplugin/'.b:sql_type_override.'.vim') != '' 194 if globpath(&runtimepath, 'ftplugin/'.b:sql_type_override.'.vim') != ''
309 \ 'table,trigger' . 344 \ 'table,trigger' .
310 \ ',schema,service,publication,database,datatype,domain' . 345 \ ',schema,service,publication,database,datatype,domain' .
311 \ ',index,subscription,synchronization,view,variable' 346 \ ',index,subscription,synchronization,view,variable'
312 endif 347 endif
313 348
349 " Key to trigger SQL completion
350 if !exists('g:ftplugin_sql_omni_key')
351 let g:ftplugin_sql_omni_key = '<C-C>'
352 endif
353 " Key to trigger drill into column list
354 if !exists('g:ftplugin_sql_omni_key_right')
355 let g:ftplugin_sql_omni_key_right = '<Right>'
356 endif
357 " Key to trigger drill out of column list
358 if !exists('g:ftplugin_sql_omni_key_left')
359 let g:ftplugin_sql_omni_key_left = '<Left>'
360 endif
361
314 " Replace all ,'s with bars, except ones with numbers after them. 362 " Replace all ,'s with bars, except ones with numbers after them.
315 " This will most likely be a \{,1} string. 363 " This will most likely be a \{,1} string.
316 let s:ftplugin_sql_objects = 364 let s:ftplugin_sql_objects =
317 \ '\\c^\\s*' . 365 \ '\\c^\\s*' .
318 \ '\\(\\(' . 366 \ '\\(\\(' .
380 " Prevent the intellisense plugin from loading 428 " Prevent the intellisense plugin from loading
381 let b:sql_vis = 1 429 let b:sql_vis = 1
382 if !exists('g:omni_sql_no_default_maps') 430 if !exists('g:omni_sql_no_default_maps')
383 " Static maps which use populate the completion list 431 " Static maps which use populate the completion list
384 " using Vim's syntax highlighting rules 432 " using Vim's syntax highlighting rules
385 imap <buffer> <c-c>a <C-\><C-O>:call sqlcomplete#Map('syntax')<CR><C-X><C-O> 433 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'a <C-\><C-O>:call sqlcomplete#Map("syntax")<CR><C-X><C-O>'
386 imap <buffer> <c-c>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O> 434 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'k <C-\><C-O>:call sqlcomplete#Map("sqlKeyword")<CR><C-X><C-O>'
387 imap <buffer> <c-c>f <C-\><C-O>:call sqlcomplete#Map('sqlFunction')<CR><C-X><C-O> 435 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'f <C-\><C-O>:call sqlcomplete#Map("sqlFunction")<CR><C-X><C-O>'
388 imap <buffer> <c-c>o <C-\><C-O>:call sqlcomplete#Map('sqlOption')<CR><C-X><C-O> 436 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'o <C-\><C-O>:call sqlcomplete#Map("sqlOption")<CR><C-X><C-O>'
389 imap <buffer> <c-c>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O> 437 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'T <C-\><C-O>:call sqlcomplete#Map("sqlType")<CR><C-X><C-O>'
390 imap <buffer> <c-c>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O> 438 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'s <C-\><C-O>:call sqlcomplete#Map("sqlStatement")<CR><C-X><C-O>'
391 " Dynamic maps which use populate the completion list 439 " Dynamic maps which use populate the completion list
392 " using the dbext.vim plugin 440 " using the dbext.vim plugin
393 imap <buffer> <c-c>t <C-\><C-O>:call sqlcomplete#Map('table')<CR><C-X><C-O> 441 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'t <C-\><C-O>:call sqlcomplete#Map("table")<CR><C-X><C-O>'
394 imap <buffer> <c-c>p <C-\><C-O>:call sqlcomplete#Map('procedure')<CR><C-X><C-O> 442 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'p <C-\><C-O>:call sqlcomplete#Map("procedure")<CR><C-X><C-O>'
395 imap <buffer> <c-c>v <C-\><C-O>:call sqlcomplete#Map('view')<CR><C-X><C-O> 443 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'v <C-\><C-O>:call sqlcomplete#Map("view")<CR><C-X><C-O>'
396 imap <buffer> <c-c>c <C-\><C-O>:call sqlcomplete#Map('column')<CR><C-X><C-O> 444 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'c <C-\><C-O>:call sqlcomplete#Map("column")<CR><C-X><C-O>'
397 imap <buffer> <c-c>l <C-\><C-O>:call sqlcomplete#Map('column_csv')<CR><C-X><C-O> 445 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'l <C-\><C-O>:call sqlcomplete#Map("column_csv")<CR><C-X><C-O>'
398 " The next 3 maps are only to be used while the completion window is 446 " The next 3 maps are only to be used while the completion window is
399 " active due to the <CR> at the beginning of the map 447 " active due to the <CR> at the beginning of the map
400 imap <buffer> <c-c>L <C-Y><C-\><C-O>:call sqlcomplete#Map('column_csv')<CR><C-X><C-O> 448 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'L <C-Y><C-\><C-O>:call sqlcomplete#Map("column_csv")<CR><C-X><C-O>'
401 " <C-Right> is not recognized on most Unix systems, so only create 449 " <C-Right> is not recognized on most Unix systems, so only create
402 " these additional maps on the Windows platform. 450 " these additional maps on the Windows platform.
403 " If you would like to use these maps, choose a different key and make 451 " If you would like to use these maps, choose a different key and make
404 " the same map in your vimrc. 452 " the same map in your vimrc.
405 if has('win32') 453 " if has('win32')
406 imap <buffer> <c-right> <C-R>=sqlcomplete#DrillIntoTable()<CR> 454 exec 'imap <buffer> '.g:ftplugin_sql_omni_key_right.' <C-R>=sqlcomplete#DrillIntoTable()<CR>'
407 imap <buffer> <c-left> <C-R>=sqlcomplete#DrillOutOfColumns()<CR> 455 exec 'imap <buffer> '.g:ftplugin_sql_omni_key_left.' <C-R>=sqlcomplete#DrillOutOfColumns()<CR>'
408 endif 456 " endif
409 " Remove any cached items useful for schema changes 457 " Remove any cached items useful for schema changes
410 imap <buffer> <c-c>R <C-\><C-O>:call sqlcomplete#Map('resetCache')<CR><C-X><C-O> 458 exec 'imap <buffer> '.g:ftplugin_sql_omni_key.'R <C-\><C-O>:call sqlcomplete#Map("resetCache")<CR><C-X><C-O>'
411 endif 459 endif
412 460
413 if b:sql_compl_savefunc != "" 461 if b:sql_compl_savefunc != ""
414 " We are changing the filetype to SQL from some other filetype 462 " We are changing the filetype to SQL from some other filetype
415 " which had OMNI completion defined. We need to activate the 463 " which had OMNI completion defined. We need to activate the