提交 56a726dd 编写于 作者: C Cosmin Popescu

added sw_delete_tmp option and improved autocomplete regexp patterns

上级 1cb395b2
......@@ -70,6 +70,15 @@ function! s:get_wake_vim_cmd()
return s:wake_vim_cmd . ' --remote-expr "sw#got_async_result(' . s:get_buff_unique_id() . ')"'
endfunction
function! s:delete_tmp()
if (g:sw_delete_tmp)
call delete(g:sw_tmp . '/' . s:input_file())
call delete(g:sw_tmp . '/' . s:output_file())
call delete(g:sw_tmp . '/' . s:async_input_file())
endif
endfunction
function! sw#async_end()
let idx = index(g:sw_async_ended, s:get_buff_unique_id())
if idx != -1
......@@ -81,10 +90,7 @@ function! sw#async_end()
let func = b:on_async_result
execute "call " . func . "()"
endif
call delete(g:sw_tmp . '/' . s:input_file())
call delete(g:sw_tmp . '/' . s:output_file())
call delete(g:sw_tmp . '/' . s:async_input_file())
call s:delete_tmp()
endif
endfunction
......@@ -96,10 +102,7 @@ function! sw#reset_current_command()
if exists('b:async_on_progress')
unlet b:async_on_progress
endif
call delete(g:sw_tmp . '/' . s:input_file())
call delete(g:sw_tmp . '/' . s:output_file())
call delete(g:sw_tmp . '/' . s:async_input_file())
call s:delete_tmp()
endfunction
function! sw#kill_current_command()
......@@ -118,10 +121,7 @@ function! sw#kill_current_command()
call sw#session#unset_buffer_variable('on_async_kill')
execute "call " . func . "()"
endif
call delete(g:sw_tmp . '/' . s:input_file())
call delete(g:sw_tmp . '/' . s:output_file())
call delete(g:sw_tmp . '/' . s:async_input_file())
call s:delete_tmp()
endfunction
function! sw#check_async_result()
......
......@@ -22,7 +22,7 @@ let s:pattern_identifier = '\v' . s:_pattern_identifier
let s:pattern_reserved_word = '\v\c<(inner|outer|right|left|join|as|using|where|group|order|and|or|not)>'
let s:pattern_subquery = '\v#sq([0-9]+)#'
let s:script_path = expand('<sfile>:p:h') . '/../../'
let s:pattern_expressions = '\v\c\(([\s\t ]*select)@![^\)]{-}\)'
let s:pattern_expressions = '\v\c\(([\s\t ]*select)@![^\(\)]{-}\)'
function! s:eliminate_sql_comments(sql)
let sql = sw#get_sql_canonical(a:sql)[0]
......@@ -455,6 +455,9 @@ endfunction
function! s:extract_subqueries(sql)
let pattern = '\v\c(\([ \s\t]*select[^\(\)]+\))'
let s = substitute(a:sql, s:pattern_expressions, '#values#', 'g')
while s =~ s:pattern_expressions
let s = substitute(s, s:pattern_expressions, '#values#', 'g')
endwhile
let matches = []
let n = 0
let m = matchstr(s, pattern, '')
......@@ -538,7 +541,13 @@ function! s:get_subquery_fields(sql, subqueries)
" get my_id, and then return the autocomplete with alias.my_id.
" That's why we eliminate everything before the point
" If the field does not contain *, we just get the last identifier
let f = matchstr(field, '\v([^ \t\s]+)$')
if field =~ '\v\.'
let f = matchstr(field, '\v([^\.]+)$')
elseif field =~ '\v[ ]'
let f = matchstr(field, '\v([^ ]+)$')
else
let f = field
endif
call add(result, f)
elseif field == '*'
" If the field is *, we need to get the tables of this subquery
......
......@@ -152,6 +152,10 @@ if !exists('g:sw_tab_switches_between_bottom_panels')
let g:sw_tab_switches_between_bottom_panels = 1
endif
if !exists('g:sw_delete_tmp')
let g:sw_delete_tmp = 1
endif
"if !exists('g:sw_overwrite_current_command')
" let g:sw_overwrite_current_command = 0
"endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册