From df177f679e950a2ab2ad5fe7d45c1daface004d7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 22 Feb 2005 08:39:57 +0000 Subject: updated for version 7.0051 --- runtime/ftplugin/sql.vim | 195 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 179 insertions(+), 16 deletions(-) (limited to 'runtime/ftplugin') diff --git a/runtime/ftplugin/sql.vim b/runtime/ftplugin/sql.vim index afbdf555c..efccebdf1 100644 --- a/runtime/ftplugin/sql.vim +++ b/runtime/ftplugin/sql.vim @@ -1,35 +1,198 @@ -" Vim filetype plugin file -" Language: SQL (Common for Oracle, Microsoft SQL Server, Sybase) -" Version: 0.02 -" Maintainer: David Fishburn -" Last Change: Tue May 27 2003 09:33:31 +" SQL filetype plugin file +" Language: SQL (Common for Oracle, Microsoft SQL Server, Sybase) +" Version: 0.08 +" Maintainer: David Fishburn +" Last Change: Mon Feb 21 2005 7:27:36 AM +" Download: http://vim.sourceforge.net/script.php?script_id=454 " This file should only contain values that are common to all SQL languages " Oracle, Microsoft SQL Server, Sybase ASA/ASE, MySQL, and so on " If additional features are required create: -" vimfiles/after/ftplugin/sql.vim -" to override and add any of your own settings +" vimfiles/after/ftplugin/sql.vim (Windows) +" .vim/after/ftplugin/sql.vim (Unix) +" to override and add any of your own settings. " Only do this when not done yet for this buffer if exists("b:did_ftplugin") finish endif +let s:save_cpo = &cpo +set cpo= + " Don't load another plugin for this buffer let b:did_ftplugin = 1 +" Some standard expressions for use with the matchit strings +let s:notend = '\%(\:\\(;\)\?$,'. - \ '\:\:\:\:'. - \ '\%(\:\,'. - \ '\:\:\:'. - \ '\%(\:\,'. - \ '\:\:\:'. - \ '\%(\:\,'. - \ '\:\:\:'. - \ '\%(\:\' + \ '\:\\W*$,'. + \ + \ s:notend . '\:'. + \ '\\|\\|\:'. + \ '\,'. + \ + \ '\\|'. + \ '\\|'. + \ '\%(' . s:notend . '\\)\|'. + \ '\%(' . s:notend . '\\):'. + \ '\\|\\|\\|\:'. + \ '\%(\\)\)\|\,'. + \ + \ '\%('. s:notend . '\\):'. + \ '\%('.s:when_no_matched_or_others.'\):'. + \ '\%(\\|\\),' . + \ + \ '\:' . + \ '\:' . + \ '\,' . + \ + \ '\%(\' + " \ '\\|\:'. + " \ '\\(;\)\?\s*$' + " \ '\:'.s:when_no_matched_or_others. + " \ ':\,'. + " + " \ '\%(\\|\%('. s:notend . '\\)\):'. + " \ '\%(\\|'.s:when_no_matched_or_others.'\):'. + " \ '\%(\%(\\)\|\\),' . endif + +" Define how to find the macro definition of a variable using the various +" [d, [D, [_CTRL_D and so on features +" Match these values ignoring case +" ie DECLARE varname INTEGER +let &l:define = '\c\(DECLARE\|IN\|OUT\|INOUT\)\s*' + + +" Mappings to move to the next BEGIN ... END block +" \W - no characters or digits +nmap ]] :call search('\c^\s*begin\>', 'W' ) +nmap [[ :call search('\c^\s*begin\>', 'bW' ) +nmap ][ :call search('\c^\s*end\W*$', 'W' ) +nmap [] :call search('\c^\s*end\W*$', 'bW' ) +vmap ]] /\c^\s*begin\> +vmap [[ ?\c^\s*begin +vmap ][ /\c^\s*end\W*$ +vmap [] ?\c^\s*end\W*$ + + +" Predefined SQL objects what are used by the below mappings using +" the ]} style maps. +" This global variable allows the users to override it's value +" from within their vimrc. +if !exists('g:ftplugin_sql_objects') + let g:ftplugin_sql_objects = 'function,procedure,event,' . + \ '\(existing\\|global\s\+temporary\s\+\)\?table,trigger' . + \ ',schema,service,publication,database,datatype,domain' . + \ ',index,subscription,synchronization,view,variable' +endif + +let s:ftplugin_sql_objects = + \ '\c^\s*' . + \ '\(create\s\+\(or\s\+replace\s\+\)\?\)\?' . + \ '\<\(' . + \ substitute(g:ftplugin_sql_objects, ',', '\\\\|', 'g') . + \ '\)\>' + +" Mappings to move to the next CREATE ... block +" map ]} :call search(g:ftplugin_sql_objects, 'W' ) +" nmap [{ :call search('\c^\s*\(create\s\+\(or\s\+replace\s\+\)\?\)\?\<\(function\\|procedure\\|event\\|table\\|trigger\\|schema\)\>', 'bW' ) +" exec 'nmap ]} /'.s:ftplugin_sql_objects.'' +exec "nmap ]} :call search('".s:ftplugin_sql_objects."', 'W')" +exec "nmap [{ :call search('".s:ftplugin_sql_objects."', 'bW')" +" Could not figure out how to use a :call search() string in visual mode +" without it ending visual mode +exec 'vmap ]} /'.s:ftplugin_sql_objects.'' +exec 'vmap [{ ?'.s:ftplugin_sql_objects.'' +" vmap ]} /\c^\s*\(create\s\+\(or\s\+replace\s\+\)\?\)\?\<\(function\\|procedure\\|event\\|table\\|trigger\\|schema\)\> +" vmap [{ ?\c^\s*\(create\s\+\(or\s\+replace\s\+\)\?\)\?\<\(function\\|procedure\\|event\\|table\\|trigger\\|schema\)\> + +" Mappings to move to the next COMMENT +" +" Had to double the \ for the \| separator since this has a special +" meaning on maps +let b:comment_leader = '\(--\\|\/\/\\|\*\\|\/\*\\|\*\/\)' +" Find the start of the next comment +let b:comment_start = '^\(\s*'.b:comment_leader.'.*\n\)\@ ]" /'.b:comment_start.'' +exec 'nnoremap [" /'.b:comment_end.'' +exec 'vnoremap ]" /'.b:comment_start.'' +exec 'vnoremap [" /'.b:comment_end.'' + +" Comments can be of the form: +" /* +" * +" */ +" or +" // +" or +" -- +setlocal comments=s1:/*,mb:*,ex:*/,:--,:// + +let &cpo = s:save_cpo + +" vim:sw=4:ff=unix: + -- cgit v1.2.1