From 479191ab4b06eaa88a14d018a1968810f279284f Mon Sep 17 00:00:00 2001 From: somini Date: Fri, 18 Mar 2016 00:15:23 +0000 Subject: [PATCH 1/3] Add SQL initial support Just IF, LOOP and BEGIN for now, that should cover a large number of cases. --- plugin/endwise.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/endwise.vim b/plugin/endwise.vim index 23eb339..a2e8052 100644 --- a/plugin/endwise.vim +++ b/plugin/endwise.vim @@ -67,6 +67,10 @@ augroup endwise " {{{1 \ let b:endwise_addition = 'endsnippet' | \ let b:endwise_words = 'snippet' | \ let b:endwise_syngroups = 'snipSnippet,snipSnippetHeader,snipSnippetHeaderKeyword' + autocmd FileType sql + \ let b:endwise_addition = '\="end" . (submatch(0) !~# "begin" ? submatch(0) : "") . ";" ' | + \ let b:endwise_words = 'if,loop,begin' | + \ let b:endwise_syngroups = 'sqlKeyword' autocmd FileType * call s:abbrev() augroup END " }}}1 From d4b0cd2571749e109e2e8c6a8696e6921b3e030e Mon Sep 17 00:00:00 2001 From: somini Date: Sat, 19 Mar 2016 00:52:11 +0000 Subject: [PATCH 2/3] Constraint nonstandard syntax to its dialect Use the SQL runtime files distributed by default. Falls back to Oracle PL/SQL syntax. --- plugin/endwise.vim | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugin/endwise.vim b/plugin/endwise.vim index a2e8052..5a7ebb1 100644 --- a/plugin/endwise.vim +++ b/plugin/endwise.vim @@ -67,12 +67,18 @@ augroup endwise " {{{1 \ let b:endwise_addition = 'endsnippet' | \ let b:endwise_words = 'snippet' | \ let b:endwise_syngroups = 'snipSnippet,snipSnippetHeader,snipSnippetHeaderKeyword' - autocmd FileType sql - \ let b:endwise_addition = '\="end" . (submatch(0) !~# "begin" ? submatch(0) : "") . ";" ' | - \ let b:endwise_words = 'if,loop,begin' | - \ let b:endwise_syngroups = 'sqlKeyword' + autocmd FileType sql call s:filetype_sql() autocmd FileType * call s:abbrev() -augroup END " }}}1 +augroup END +function! s:filetype_sql() + let b:endwise_syngroups = 'sqlKeyword' + let current_dialect = get(b:, 'sql_type_override', get(g:, 'sql_type_default', 'sqloracle')) " :help sql-dialects + if current_dialect == 'sqloracle' + let b:endwise_addition = '\="end" . (submatch(0) !~# "begin" ? submatch(0) : "") . ";" ' | + let b:endwise_words = 'loop,begin,if' + endif +endfunction +" }}}1 function! s:abbrev() if exists('g:endwise_abbreviations') From 4b52ef7338202dc52624b214f473d99e20a2bf63 Mon Sep 17 00:00:00 2001 From: somini Date: Mon, 28 Mar 2016 23:46:53 +0100 Subject: [PATCH 3/3] Fix Oracle SQL addition Add a missing space to the match and switch the pattern around. --- plugin/endwise.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/endwise.vim b/plugin/endwise.vim index 5a7ebb1..8e71059 100644 --- a/plugin/endwise.vim +++ b/plugin/endwise.vim @@ -74,7 +74,7 @@ function! s:filetype_sql() let b:endwise_syngroups = 'sqlKeyword' let current_dialect = get(b:, 'sql_type_override', get(g:, 'sql_type_default', 'sqloracle')) " :help sql-dialects if current_dialect == 'sqloracle' - let b:endwise_addition = '\="end" . (submatch(0) !~# "begin" ? submatch(0) : "") . ";" ' | + let b:endwise_addition = '\="end" . (submatch(0) !~? "begin" ? " ".submatch(0) : "") . ";" ' | let b:endwise_words = 'loop,begin,if' endif endfunction