提交 df1fff5c 编写于 作者: C Cosmin Popescu

version 6.0

上级 1547b8bd
此差异已折叠。
此差异已折叠。
if ( exists('g:loaded_ctrlp_sw_profiles') && g:loaded_ctrlp_sw_profiles )
\ || v:version < 700 || &cp
finish
endif
let g:loaded_ctrlp_sw_profiles = 1
call add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#sw_profiles#init()',
\ 'accept': 'ctrlp#sw_profiles#accept',
\ 'lname': 'SQL Workbench Profiles',
\ 'sname': 'sw_profiles',
\ 'type': 'line',
\ 'exit': 'ctrlp#sw_profiles#exit()',
\ 'enter': 'ctrlp#sw_profiles#enter()',
\ 'sort': 0,
\ 'specinput': 0,
\ })
" Provide a list of strings to search in
"
" Return: a Vim's List
"
let s:current_buffer = ''
" The action to perform on the selected string
" " Arguments:
" a:mode the mode that has been chosen by pressing <cr> <c-v> <c-t> or <c-x>
" the values are 'e', 'v', 't' and 'h', respectively
" a:str the selected string
"
function! ctrlp#sw_profiles#accept(mode, str)
let command = sw#get_connect_command(a:str)
call sw#server#connect_buffer('e', s:current_buffer)
call sw#sqlwindow#execute_sql(command)
let s:current_buffer = ''
endfunction
" (optional) Do something after exiting ctrlp
function! ctrlp#sw_profiles#exit()
call ctrlp#exit()
endfunction
function! ctrlp#sw_profiles#init()
let profiles = sw#parse_profile_xml()
let result = []
for key in keys(profiles)
call add(result, key)
endfor
return result
endfunction
" Give the extension an ID
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Allow it to be called later
function! ctrlp#sw_profiles#id()
return s:id
endfunction
function! ctrlp#sw_profiles#enter()
let s:current_buffer = bufname('%')
let name = sw#sqlwindow#get_resultset_name()
call sw#goto_window(name)
if bufname('%') == name
bwipeout
let s:current_buffer = bufname('%')
endif
endfunction
" vim:nofen:fdl=0:ts=4:sw=4:sts=4
......@@ -76,6 +76,8 @@ endfunction
let s:error = 0
let s:patterns = {'pattern_no_results': '\c\v^\(([0-9]+) rows?\)', 'pattern_empty_line': '\v^[\r \s\t]*$', 'pattern_exec_time': '\v^Execution time: [0-9\.]+', 'pattern_resultset_start': '\v^([\-]+\+?)+([\-]*)-$'}
if !exists('g:Sw_unique_id')
let g:Sw_unique_id = 1
endif
......@@ -193,14 +195,8 @@ function! sw#get_sw_profile()
endfunction
" Executes an sql command{{{1
function! sw#execute_sql(command, wait_result)
let port = sw#get_server_port()
if port == ''
return
endif
if (port == -1)
function! sw#execute_sql(command)
if (!exists('b:sw_channel'))
call sw#display_error("This buffer is not an sql workbench buffer.")
return
endif
......@@ -226,7 +222,7 @@ function! sw#execute_sql(command, wait_result)
endfor
endif
endif
return sw#server#execute_sql(a:command, a:wait_result, port)
return sw#server#execute_sql(a:command)
endfunction
" Exports as ods{{{1
......@@ -236,7 +232,12 @@ function! sw#export_ods(command)
let location = input('Please select a destination file: ', '', 'file')
if (location != '')
let queries = sw#sql_split(a:command)
return sw#sqlwindow#execute_sql(0, "WbExport -type=" . format . ' -file=' . location . ';' . queries[0])
if len(queries) >= 2
let query = queries[1]
else
let query = queries[0]
endif
return sw#sqlwindow#execute_sql("WbExport -type=" . format . ' -file=' . location . ';' . query . ';')
endif
endif
endfunction
......@@ -388,16 +389,25 @@ function! sw#hide_header(rows)
return result
endfunction
" Returns the window id of a buffer identified by name is visible if is
" visible in the current tab, otherwise return 0
function! sw#is_visible(name)
let bufnr = bufnr(a:name)
let windows = win_findbuf(bufnr)
for w in windows
if win_id2win(w) != 0
return w
endif
endfor
return 0
endfunction
" Goes to a window identified by a buffer name{{{1
function! sw#goto_window(name)
let crt = bufname('%')
if bufwinnr(a:name) != -1
while bufname('%') != a:name && sw#session#buffer_name() != a:name
wincmd w
if bufname('%') == crt
return
endif
endwhile
let id = sw#is_visible(a:name)
if id != 0
call win_gotoid(id)
endif
endfunction
......@@ -416,6 +426,39 @@ function! sw#set_special_buffer()
setlocal nomodifiable
endfunction
" Parses the macros xml file to give autocompletion for macros{{{1
function! sw#parse_macro_xml()
if !exists('g:sw_config_dir')
return {}
endif
let lines = readfile(g:sw_config_dir . 'WbMacros.xml')
let s = ''
for line in lines
let s = s . ' ' . line
endfor
let pattern = '\v\c(\<object class\="[^"]{-}"\>.{-}\<\/object\>)'
let result = {}
let n = 0
let list = matchlist(s, pattern, n, 1)
while len(list) > 0
let _pattern = '\v\c^.*\<void property\="#prop#"\>[ \s\r\t]*\<string\>([^\<]+)\<.*$'
let name = substitute(list[1], substitute(_pattern, '#prop#', 'name', 'g'), '\1', 'g')
let driverName = substitute(list[1], substitute(_pattern, '#prop#', 'driverName', 'g'), '\1', 'g')
let group = substitute(list[1], substitute(_pattern, '#prop#', 'group', 'g'), '\1', 'g')
if (group != list[1])
let name = group . '\' . name
endif
let result[name] = driverName
let n = n + 1
let s = substitute(s, '\V' . list[0], '', 'g')
let list = matchlist(s, pattern, n, 1)
endwhile
return result
endfunction
" Parses the profile xml file to give autocompletion for profiles{{{1
function! sw#parse_profile_xml()
if !exists('g:sw_config_dir')
......@@ -528,3 +571,20 @@ function! sw#put_lines_in_buffer(lines)
normal ggdd
setlocal nomodifiable
endfunction
function! sw#get_connect_command(profile)
let pattern = '\v(^[^\\]+\\)?(.*)$'
let profile = substitute(a:profile, pattern, '\2', 'g')
let group = substitute(a:profile, pattern, '\1', 'g')
let group = group[0:strlen(group) - 2]
return 'wbconnect -profile=' . profile . (group == '' ? '' : ' -profileGroup=' . group) . ';'
endfunction
" Makes sure that an sql is not delimiter by the delimiter
function! sw#ensure_sql_not_delimited(sql, delimiter)
return substitute(substitute(substitute(a:sql, '\v\n', '#NEWLINE#', 'g'), '\v' . a:delimiter . '[\s\t\r]*$', '', 'g'), '\v#NEWLINE#', "\n", 'g')
endfunction
function! sw#get_pattern(which)
return s:patterns[a:which]
endfunction
......@@ -19,30 +19,19 @@
let s:last_result = ''
function! sw#cmdline#execute(wait_result, port, ...)
function! sw#cmdline#execute(channel, ...)
let s:last_result = ''
let sql = ''
let i = 1
while i <= a:0
execute "let sql .= ' ' . a:" . i
let i = i + 1
endwhile
let b:on_async_result = 'sw#sqlwindow#check_results'
let b:delimiter = ';'
let result = sw#server#execute_sql(sql, a:wait_result, a:port)
if result != ''
call s:process_results(result)
endif
endfunction
function! sw#cmdline#got_result()
let s:last_result = sw#server#fetch_result()
if results != ''
call s:process_results(result)
endif
call sw#server#execute_sql(sql . ';', a:channel, 'sw#cmdline#got_result')
endfunction
function! s:process_results(result)
let s:last_result = a:result
function! sw#cmdline#got_result(result)
let s:last_result .= a:result
endfunction
function! sw#cmdline#show_last_result()
......
......@@ -22,6 +22,7 @@ if !exists('g:SW_Tabs')
endif
let s:profiles = {}
let s:last_command = {}
" Local functions{{{1
" Iterates in the tabs array{{{2
......@@ -83,15 +84,14 @@ function! s:get_first_tab(tab)
endfunction
" Set a special buffer{{{2
function! s:set_special_buffer(profile, port)
function! s:set_special_buffer(profile, channel)
call sw#session#init_section()
call sw#set_special_buffer()
call sw#session#set_buffer_variable('profile', a:profile)
call sw#session#set_buffer_variable('port', a:port)
call sw#session#set_buffer_variable('sw_channel', a:channel)
call sw#session#set_buffer_variable('t1_shortcuts', 'Main shortcuts:')
call sw#session#set_buffer_variable('t2_shortcuts', 'Available shortcuts in the left panel:')
call sw#session#set_buffer_variable('t3_shortcuts', 'Available shortcuts in the right panel:')
""call sw#session#autocommand('BufEnter', 'sw#check_async_result()')
call s:iterate('s:add_shortcut')
......@@ -150,6 +150,10 @@ endfunction
function! s:process_result_1(result, shortcut, title)
let result = a:result
if !exists('b:profile') || !sw#is_visible('__Info__-' . b:profile)
call sw#display_error("A result was returned by an sql database explorer, but you are not on that tab anymore. You will need to execute the command again")
return
endif
call sw#goto_window('__Info__-' . b:profile)
call sw#session#set_buffer_variable('current_tab', a:shortcut)
call sw#goto_window('__SQL__-' . b:profile)
......@@ -185,8 +189,21 @@ endfunction
" Change a tab{{{2
function! sw#dbexplorer#change_tab(command, shortcut, title)
let result = sw#server#dbexplorer(a:command)
call s:process_result_1(result, a:shortcut, a:title)
let s:last_command = {'command': a:command, 'shortcut': a:shortcut, 'title': a:title, 'type': 1}
call sw#dbexplorer#do_command(a:command)
endfunction
function! sw#dbexplorer#do_command(sql)
if !exists('b:profile') || !exists('b:sw_channel')
return
endif
if a:sql =~ "^:"
let func = substitute(a:sql, '^:', '', 'g')
execute "let s = " . func . "(getline('.'))"
call sw#dbexplorer#message_handler(b:sw_channel, s)
else
call sw#server#execute_sql(substitute(sw#ensure_sql_not_delimited(a:sql, ';'), '\v\<cr\>', "\n", 'g') . ';', b:sw_channel)
endif
endfunction
function! sw#dbexplorer#toggle_form_display()
......@@ -206,6 +223,10 @@ endfunction
function! s:process_result_2(result, tab_shortcut, shortcut, cmd)
let result = a:result
if !exists('b:profile') || !sw#is_visible('__Info__-' . b:profile)
call sw#display_error("A result was returned by an sql database explorer, but you are not on that tab anymore. You will need to execute the command again")
return
endif
call sw#session#set_buffer_variable('shortcut', a:tab_shortcut)
call s:iterate('s:find_tab_by_shortcut')
if (exists('b:tab'))
......@@ -253,10 +274,6 @@ endfunction
function! s:change_panel(command, shortcut, title, tab_shortcut)
echomsg "Processing request..."
"if line('.') < 5
" echoerr "You have to select an object in the left panel"
" return
"endif
let pattern = '\v\c^\/\* BEFORE (.*)\*\/.+$'
if (a:command =~ pattern)
......@@ -275,8 +292,8 @@ function! s:change_panel(command, shortcut, title, tab_shortcut)
let cmd = substitute(cmd, '\v\%' . i . '\%', column, 'g')
let i = i + 1
endfor
let result = sw#server#dbexplorer(cmd)
call s:process_result_2(result, a:tab_shortcut, a:shortcut, cmd)
let s:last_command = {'tab_shortcut': a:tab_shortcut, 'shortcut': a:shortcut, 'cmd': cmd, 'type': 2}
call sw#dbexplorer#do_command(cmd)
endfunction
" Adds a shortcut from a tab to the current buffer{{{2
......@@ -326,20 +343,6 @@ function! s:set_info_buffer()
call sw#put_lines_in_buffer(lines)
endfunction
" Sets the objects initial state{{{2
""function! s:set_objects_buffer()
"" wincmd b
"" wincmd h
"" let b:object_tabs = []
"" let b:txt = ''
"" call s:iterate('s:display_tabs')
"" setlocal modifiable
"" normal! ggdG
"" "put =b:txt
"" normal! ggdd
"" setlocal nomodifiable
""endfunction
" Global functions{{{1
" Adds a tab{{{2
function! sw#dbexplorer#add_tab(profile, title, shortcut, command, panels)
......@@ -356,13 +359,15 @@ endfunction
" Add a panel to a tab{{{2
function! sw#dbexplorer#add_panel(profile, tab_shortcut, title, shortcut, command)
if (!exists('g:extra_panels'))
if (!exists('g:extra_sw_panels'))
let g:extra_sw_panels = {}
endif
let obj = {'title': a:title, 'shortcut': a:shortcut, 'command': a:command}
let obj = {'profile': a:profile, 'panel': {'title': a:title, 'shortcut': a:shortcut, 'command': a:command}}
if (!has_key(a:profile, g:extra_panels))
let g:extra_sw_panels[a:profile] = {}
if !has_key(g:extra_sw_panels, a:tab_shortcut)
let g:extra_sw_panels[a:tab_shortcut] = [obj]
else
call add(g:extra_sw_panels[a:tab_shortcut], obj)
endif
endfunction
......@@ -383,6 +388,8 @@ function! sw#dbexplorer#hide_panel(...)
return
endif
call sw#goto_window('__SQL__' . profile)
call sw#server#disconnect_buffer()
execute "silent! bwipeout __SQL__-" . profile
execute "silent! bwipeout __Info__-" . profile
execute "silent! bwipeout __DBExplorer__-" . profile
......@@ -391,48 +398,12 @@ endfunction
" Export the result panel as ods{{{2
function! sw#dbexplorer#export()
if (exists('b:last_cmd'))
call sw#export_ods(b:profile, b:last_cmd)
call sw#export_ods(b:last_cmd)
else
call sw#display_error("The panel is empty!")
endif
endfunction
function! sw#dbexplorer#show_panel_no_profile(...)
let connection = ''
let i = 1
while i <= a:0
let cmd = "let arg = a:" . i
execute cmd
let connection = connection . ' ' . arg
let i = i + 1
endwhile
let profile = '__no__' . sw#generate_unique_id()
call sw#dbexplorer#show_panel(profile, connection)
endfunction
function! sw#dbexplorer#restore_from_session(...)
echomsg "Processing request..."
let connection = ''
if exists('b:connection')
let connection = b:connection
endif
call sw#goto_window('__Info__-' . b:profile)
call sw#session#init_section()
call sw#session#check()
call s:set_special_buffer(b:profile, connection)
call s:set_highlights()
call sw#goto_window('__SQL__-' . b:profile)
call sw#session#init_section()
call sw#session#check()
call s:set_special_buffer(b:profile, connection)
call sw#goto_window('__DBExplorer__-' . b:profile)
call sw#session#init_section()
call sw#session#check()
call s:set_special_buffer(b:profile, connection)
call sw#dbexplorer#change_tab(b:first_tab['command'], b:first_tab['shortcut'], b:first_tab['title'])
endfunction
function! s:set_highlights()
highlight SWHighlights term=NONE cterm=NONE ctermbg=25 ctermfg=yellow gui=NONE guibg=#808080 guifg=yellow
highlight SWSelectedObject term=NONE cterm=NONE ctermbg=DarkGrey ctermfg=fg gui=NONE guibg=#808080 guifg=yellow
......@@ -442,49 +413,47 @@ function! s:set_highlights()
let id = matchadd('SWHighlights', b:t3_shortcuts)
endfunction
" Handles a message from the server{{{2
function! sw#dbexplorer#message_handler(channel, message)
let result = split(a:message, "\n")
if s:last_command.type == 1
call s:process_result_1(result, s:last_command.shortcut, s:last_command.title)
elseif s:last_command.type == 2
call s:process_result_2(result, s:last_command.tab_shortcut, s:last_command.shortcut, s:last_command.cmd)
endif
endfunction
" Shows the dbexplorer panel{{{2
function! sw#dbexplorer#show_panel(profile, port, ...)
function! sw#dbexplorer#show_panel(profile)
let profile = substitute(a:profile, '\\', '___', 'g')
let result = sw#server#open_dbexplorer(profile, a:port)
let s_below = &splitbelow
set nosplitbelow
let name = "__SQL__-" . profile
if bufexists(name)
if bufexists(name) && bufloaded(name)
call sw#display_error("There is already a dbexplorer opened for " . profile)
return
endif
""if (g:sw_bufexplorer_new_tab)
"" tabnew
""endif
tabnew
let connection = ''
if (a:0)
let connection = a:1
endif
let uid = sw#generate_unique_id()
execute "badd " . name
execute "buffer " . name
call s:set_special_buffer(profile, a:port)
let channel = sw#server#open_dbexplorer(a:profile)
call s:set_special_buffer(profile, channel)
call sw#session#set_buffer_variable('unique_id', uid)
nnoremap <buffer> <silent> E :call sw#dbexplorer#export()<cr>
nnoremap <buffer> <silent> B :call <SID>open_in_new_buffer()<cr>
execute "silent! split __Info__-" . profile
resize 7
"let id = matchadd('SWHighlights', '\v^([^\(]+\([A-Za-z]+\)( \| )?)+$')
call s:set_special_buffer(profile, a:port)
call s:set_special_buffer(profile, channel)
call sw#session#set_buffer_variable('unique_id', uid)
call s:set_highlights()
wincmd b
execute "silent! vsplit __DBExplorer__-" . profile
call s:set_special_buffer(profile, a:port)
call s:set_special_buffer(profile, channel)
call sw#session#set_buffer_variable('unique_id', uid)
vertical resize 60
""call s:set_objects_buffer()
call s:iterate('s:get_first_tab')
call sw#dbexplorer#change_tab(b:first_tab['command'], b:first_tab['shortcut'], b:first_tab['title'])
if s_below
......@@ -504,14 +473,4 @@ function! sw#dbexplorer#fix_source_code()
normal gg0G0x
setlocal nomodifiable
endfunction
function! sw#dbexplorer#postgre_proc(line)
let proc = substitute(a:line, '\v\c([^\(]+)\(.*$', '\1', 'g')
let lines = sw#server#dbexplorer('WbProcSource ' . proc)
let result = ''
for line in lines
let result = result . line . "\n"
endfor
return result
endfunction
" vim:fdm=marker
"============================================================================"
"
" Vim SQL Workbench/J Implementation
"
" Copyright (c) Cosmin Popescu
"
" Author: Cosmin Popescu <cosminadrianpopescu at gmail dot com>
" Version: 1.00 (2015-01-08)
" Requires: Vim 7
" License: GPL
"
" Description:
"
" Provides SQL database access to any DBMS supported by SQL Workbench/J. The
" only dependency is SQL Workbench/J. Also includes powefull intellisense
" autocomplete based on the current selected database
"
"============================================================================"
let s:label = ''
function! sw#interactive#wait(label)
let s:label = a:label
normal 
redraw!
let val = input("SQL Workbench/J is asking an input for " . s:label)
return ''
endfunction
function! sw#interactive#get(label)
let val = input("SQL Workbench/J is asking an input for " . a:label)
call sw#server#send_feedback(val)
endfunction
......@@ -90,173 +90,10 @@ function! s:input_select(message, default_value, options)
return result
endfunction
function! s:process_search_result(result, columns)
let result = split(a:result, "\n")
if a:columns != ''
let _c = split(a:columns, ',')
let columns = []
for column in _c
if column == 'NAME'
call add(columns, 0)
endif
if column == 'TYPE'
call add(columns, 1)
endif
if column == 'SOURCE'
call add(columns, 2)
endif
endfor
let i = 0
let hide = []
while i < 3
if index(columns, i) == -1
call add(hide, i)
endif
let i = i + 1
endwhile
if exists('b:resultsets')
call sw#session#unset_buffer_variable('resultsets')
endif
if exists('b:messages')
call sw#session#unset_buffer_variable('messages')
endif
if len(hide) > 0
let result = sw#hide_columns(result, hide)
endif
else
if g:sw_last_sql_query =~ '\v\cwbgrepsource'
let _r = []
for line in result
if !(line =~ ':')
call add(_r, line)
endif
endfor
let result = _r
endif
endif
let resultsets = []
let messages = []
let where = 'm'
for line in result
if line =~ '\v\c^[\=]+$'
let where = 'r'
elseif line =~ '\v\c^$'
let where = 'm'
endif
if where == 'm'
call add(messages, line)
else
if !(line =~ '\v\c[\=]+$')
if line =~ '\v\c^Query returned'
call add(resultsets, '')
endif
call add(resultsets, line)
endif
endif
endfor
let result = resultsets
let __name = ''
let __name = bufname('%')
let uid = b:unique_id
let name = s:get_resultset_name()
if (!bufexists(name))
let port = b:port
let s_below = &splitbelow
set splitbelow
execute "split " . name
call sw#session#init_section()
call sw#set_special_buffer()
call sw#session#set_buffer_variable('port', port)
if !s_below
set nosplitbelow
endif
call sw#session#set_buffer_variable('resultsets', resultsets)
call sw#session#set_buffer_variable('state', 'resultsets')
call sw#session#set_buffer_variable('r_unique_id', uid)
call sw#sqlwindow#set_results_shortcuts()
endif
if (len(messages) > 0)
call sw#session#set_buffer_variable('messages', messages)
endif
let highlight = ''
if exists('b:highlight')
let highlight = b:highlight
call sw#session#unset_buffer_variable('highlight')
if exists('b:highlight_case')
let highlight = b:highlight_case . highlight
call sw#session#unset_buffer_variable('highlight_case')
endif
let highlight = '\V' . highlight
endif
if bufwinnr('__SQL__-' . uid) != -1
call sw#goto_window('__SQL__-' . uid)
else
call sw#goto_window(s:get_resultset_name())
let __name = sw#find_buffer_by_unique_id(b:r_unique_id)
endif
if exists('b:match_id')
try
call matchdelete(b:match_id)
catch
endtry
call sw#session#unset_buffer_variable('match_id')
endif
setlocal modifiable
normal ggdG
for line in result
put =line
endfor
normal ggdd
if highlight != ''
call sw#session#set_buffer_variable('match_id', matchadd('Search', highlight))
endif
setlocal nomodifiable
if __name != ''
call sw#goto_window(__name)
endif
endfunction
function! s:set_async_variables(columns)
call sw#set_on_async_result('sw#search#on_async_result')
let b:__columns = a:columns
endfunction
function! s:asynchronious(columns, set)
let name = sw#session#buffer_name()
if name == s:get_resultset_name()
let a_name = sw#find_buffer_by_unique_id(b:r_unique_id)
else
let a_name = s:get_resultset_name()
endif
if a:set
if sw#dbexplorer#is_db_explorer_tab()
call sw#dbexplorer#set_values_to_all_buffers(['on_async_result', '__columns'], ['sw#search#on_async_result', a:columns])
else
call s:set_async_variables(a:columns)
endif
else
if sw#dbexplorer#is_db_explorer_tab()
call sw#dbexplorer#unset_values_from_all_buffers(['on_async_result', '__columns'])
else
call s:unset_async_variables()
endif
endif
call sw#goto_window(a_name)
if a:set
call s:set_async_variables(a:columns)
else
call s:unset_async_variables()
endif
call sw#goto_window(name)
endfunction
function! s:unset_async_variables()
if sw#dbexplorer#is_db_explorer_tab()
call sw#dbexplorer#unset_values_from_all_buffers(['on_async_result', '__columns', 'async_on_progress'])
......@@ -270,28 +107,13 @@ function! s:unset_async_variables()
endif
endfunction
function! sw#search#on_async_result()
let result = sw#get_sql_result(0)
let columns = g:sw_search_default_result_columns
if exists('b:__columns')
let columns = b:__columns
endif
call s:process_search_result(result, columns)
call s:asynchronious('', 0)
endfunction
function! sw#search#do(command, columns, wait_result)
function! sw#search#do(command)
echomsg "Searching. Please wait..."
call sw#session#init_section()
call s:asynchronious(a:columns, 1)
let result = sw#execute_sql(a:command, a:wait_result)
if result != ''
call s:process_search_result(result, a:columns)
call s:asynchronious('', 0)
endif
call sw#execute_sql(a:command . ';')
endfunction
function! sw#search#data_defaults(wait_result, value)
function! sw#search#data_defaults(value)
let command = 'WbGrepData -searchValue="' . escape(a:value, '"') . '" -ignoreCase=' . g:sw_search_default_ignore_case . ' -compareType=' . g:sw_search_default_compare_types . ' -tables=' . g:sw_search_default_tables . ' -types="' . g:sw_search_default_data_types . '" -excludeTables=' . g:sw_search_default_exclude_tables . ' -excludeLobs=' . g:sw_search_default_exclude_lobs
call sw#session#set_buffer_variable('highlight', a:value)
......@@ -301,13 +123,13 @@ function! sw#search#data_defaults(wait_result, value)
call sw#session#set_buffer_variable('highlight_case', '\c')
endif
call sw#search#do(command, '', a:wait_result)
call sw#search#do(command)
endfunction
function! sw#search#object_defaults(wait_result, values)
function! sw#search#object_defaults(values)
let command = 'WbGrepSource -searchValues="' . escape(a:values, '"') . '" -useRegex=' . g:sw_search_default_regex . ' -matchAll=' . g:sw_search_default_match_all . ' -ignoreCase=' . g:sw_search_default_ignore_case . ' -types="' . g:sw_search_default_types . '" -objects=' . g:sw_search_default_objects
call sw#search#do(command, g:sw_search_default_result_columns, a:wait_result)
call sw#search#do(command)
endfunction
function! s:get_search_parameters(v)
......@@ -360,7 +182,7 @@ function! s:get_search_parameters(v)
return result
endfunction
function! sw#search#prepare(wait_result, cmd, ...)
function! sw#search#prepare(cmd, ...)
if !a:0
if a:cmd == 'WbGrepSource'
let command = a:cmd . s:get_search_parameters(s:obj_parameters)
......@@ -370,32 +192,22 @@ function! sw#search#prepare(wait_result, cmd, ...)
if command == a:cmd
return
endif
if a:cmd == 'WbGrepSource'
let columns = input('Available columns are: NAME,TYPE,SOURCE. Select columns to display: ', g:sw_search_default_result_columns)
else
let columns = ''
endif
else
let i = 1
let command = a:cmd
if a:cmd == 'WbGrepSource'
let columns = g:sw_search_default_result_columns
else
let columns = ''
endif
while i <= a:0
let cmd = "let arg = a:" . i
execute cmd
let command = command . ' -searchValues=' . arg
let command = command . ' ' . (a:cmd == 'WbGrepSource' ? '-searchValues' : '-searchValue') . '=' . arg . ' -types="TABLE"'
let i = i + 1
endwhile
endif
call sw#search#do(command, columns, a:wait_result)
call sw#search#do(command)
endfunction
function! sw#search#object(wait_result, ...)
let command = 'call sw#search#prepare(' . a:wait_result . ', "WbGrepSource"'
function! sw#search#object(...)
let command = 'call sw#search#prepare("WbGrepSource"'
let i = 1
while i <= a:0
let cmd = "let arg = a:" . i
......@@ -409,8 +221,8 @@ function! sw#search#object(wait_result, ...)
execute command
endfunction
function! sw#search#data(wait_result, ...)
let command = 'call sw#search#prepare(' . a:wait_result . ', "WbGrepData"'
function! sw#search#data(...)
let command = 'call sw#search#prepare("WbGrepData"'
let i = 1
while i <= a:0
let cmd = "let arg = a:" . i
......
......@@ -18,202 +18,193 @@
"============================================================================"
let s:current_file = expand('<sfile>:p:h')
let s:active_servers = []
function! s:get_pipe_name(id)
return g:sw_tmp . '/sw-pipe-' . a:id
let s:channel_handlers = {}
let s:pattern_prompt_begin = '\v^([a-zA-Z_0-9\.]+(\@[a-zA-Z_0-9\/\-]+)*\>[ \s\t]*)+'
let s:pattern_prompt = s:pattern_prompt_begin . '$'
let s:pattern_wait_input = '\v^([a-zA-Z_][a-zA-Z0-9_]*( \[[^\]]+\])?: |([^\>]+\> )?([^\>]+\> )*Username|([^\>]+\> )*Password: |([^\>]+\>[ ]+)?Do you want to run the command UPDATE\? \(Yes\/No\/All\)[ ]+)$'
let s:pattern_new_connection = '\v^Connection to "([^"]+)" successful$'
let s:timer = {'id': '', 'sec' : 0}
function! s:log_init(channel)
if g:sw_log_to_file
let s:channel_handlers[a:channel].log = g:sw_tmp . '/' . v:servername . '-' . substitute(fnamemodify(bufname('%'), ':t'), '\.', '-', 'g')
else
let s:channel_handlers[a:channel].log = ''
endif
endfunction
function! sw#server#run(port, ...)
if !exists('g:loaded_dispatch')
throw 'You cannot start a server without vim dispatch plugin. Please install it first. If you don''t want or you don''t have the possibility to install it, you can always start the server manually. '
function! s:log_channel(channel, txt)
if g:sw_log_to_file
let file = s:channel_handlers[a:channel].log
let mode = filereadable(file) ? 'ab' : 'wb'
call writefile(split(a:txt, "\n"), file, mode)
else
let s:channel_handlers[a:channel].log .= a:txt
endif
let cmd = 'Start! ' . s:current_file . '/../../resources/sqlwbconsole' . ' -t ' . g:sw_tmp . ' -s ' . v:servername . ' -c ' . g:sw_exe . ' -v ' . g:sw_vim_exe . ' -o ' . a:port
endfunction
if a:0
let cmd = cmd + ' -p ' . a:1
function! sw#server#channel_log(channel)
return s:channel_handlers[a:channel].log
endfunction
function! sw#server#handle_message(channel, msg)
call s:log_channel(a:channel, a:msg)
let lines = split(substitute(a:msg, "\r", "", 'g'), "\n")
let got_prompt = 0
let max_length = 0
let text = ''
for line in lines
let line = substitute(line, '\v^(\.\.\> )*', '', 'g')
let text .= (text == '' ? '' : "\n") . substitute(line, s:pattern_prompt_begin, '', 'g')
if line =~ s:pattern_prompt
let got_prompt = 1
endif
if line =~ s:pattern_wait_input && !(line =~ '\v^Catalog: $') && !(line =~ '\v^Schema: $')
let value = input('SQL Workbench/J is asking for input for ' . line . ' ', 'abc')
call ch_sendraw(b:sw_channel, value . "\n")
endif
if line =~ s:pattern_new_connection
let s:channel_handlers[a:channel].current_url = substitute(line, s:pattern_new_connection, '\1', 'g')
endif
endfor
let s:channel_handlers[a:channel].text .= text . "\n"
if got_prompt
let type = s:channel_handlers[a:channel].type
if (type == 'sqlwindow')
if s:channel_handlers[a:channel].tmp_handler != ''
let Func = function(s:channel_handlers[a:channel].tmp_handler)
call Func(s:channel_handlers[a:channel].text)
let s:channel_handlers[a:channel].tmp_handler = ''
else
call sw#sqlwindow#message_handler(a:channel, s:channel_handlers[a:channel].text)
endif
elseif (type == 'dbexplorer')
call sw#dbexplorer#message_handler(a:channel, s:channel_handlers[a:channel].text)
endif
let s:channel_handlers[a:channel].text = ''
call s:init_timer()
endif
endfunction
execute cmd
redraw!
function! s:start_sqlwb(type)
let job = job_start(g:sw_exe . ' -feedback=true -showProgress=false -abortOnError=false -showTiming=true', {'in_mode': 'raw', 'out_mode': 'raw'})
let channel = job_getchannel(job)
call ch_setoptions(channel, {'callback': 'sw#server#handle_message'})
let s:channel_handlers[channel] = {'text': '', 'type': a:type, 'buffer': fnamemodify(bufname('%'), ':p'), 'current_url': '', 'tmp_handler': ''}
call s:log_init(channel)
return channel
endfunction
function! sw#server#connect_buffer(port, ...)
function! sw#server#connect_buffer(...)
let file = bufname('%')
let command = 'e'
if (a:0 >= 2)
let file = a:1
let command = a:2
let file = a:2
let command = a:1
elseif a:0 >= 1
let command = a:1
endif
call sw#sqlwindow#open_buffer(a:port, file, command)
endfunction
function! sw#server#new(port)
call add(s:active_servers, a:port)
echomsg "Added new server on port: " . a:port
call sw#interrupt()
redraw!
return ''
endfunction
execute command . " " . file
call sw#session#init_section()
function! sw#server#remove(port)
let i = 0
for port in s:active_servers
if port == a:port
unlet s:active_servers[i]
endif
let i = i + 1
endfor
echomsg "Removed server from port: " . a:port
call sw#interrupt()
redraw!
return ''
if (!exists('b:sw_channel'))
let b:sw_channel = s:start_sqlwb('sqlwindow')
endif
call sw#sqlwindow#open_buffer(file, command)
endfunction
function! s:pipe_execute(type, cmd, wait_result, ...)
if v:servername == ''
call sw#display_error("This instance of vim is not started in server mode. SQL Workbench cannot be used.")
return ''
function! sw#server#execute_sql(sql, ...)
let channel = ''
if (exists('b:sw_channel'))
let channel = b:sw_channel
endif
let port = 0
if a:0
let port = a:1
else
if exists('b:port')
let port = b:port
endif
let callback = ''
if a:0 >= 2
let channel = a:1
let callback = a:2
elseif a:0 >= 1
let channel = a:1
endif
if port == 0
throw "There is no port set for this buffer. "
if ch_status(channel) != 'open'
call sw#display_error("The channel is not open. This means that SQL Workbench/J instance for this answer does not responsd anymore. Please do again SWSqlBufferConnect")
unlet b:sw_channel
return ''
endif
let uid = -1
if exists('b:unique_id')
let uid = b:unique_id
let text = a:sql . "\n"
call s:log_channel(channel, text)
if callback != ''
let s:channel_handlers[channel].tmp_handler = callback
endif
let sql = a:cmd
if a:type == 'COM' || a:type == 'DBE'
let delimiter = ';'
if exists('b:delimiter')
let delimiter = b:delimiter
endif
let statements = sw#sql_split(a:cmd, delimiter)
let sql = ''
for statement in statements
let sql .= (sql == '' ? '' : delimiter . "\n==========\n") . statement
endfor
if !(a:cmd =~ '\v^[^\n]+\n$')
let sql .= delimiter
endif
call ch_sendraw(channel, text)
if g:sw_command_timer
call s:init_timer()
let s:timer.id = timer_start(1000, 'sw#server#timer', {'repeat': -1})
endif
endfunction
try
python << SCRIPT
import vim
import socket
import re
identifier = vim.eval('v:servername') + "#" + vim.eval('uid')
cmd = vim.eval('sql')
port = int(vim.eval('port'))
type = vim.eval('a:type')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', port))
packet = ''
packet += type
if vim.eval('a:wait_result') == '0' and vim.eval('a:type') != 'VAL':
packet += '?' + identifier + '?'
#end if
packet += cmd
packet = str(len(packet)) + "#" + packet
s.sendall(packet)
result = ''
if vim.eval('a:wait_result') == '1':
while 1:
data = s.recv(4096)
if (re.search('^DISCONNECT', data)):
break
#end if
pattern = "^FEEDBACK(.*)$"
if (re.match(pattern, data) != None):
line = re.sub("^FEEDBACK(.*)$", "\\1", data)
vim.command("let value = input('SQL Workbench/J is asking for input for %s') . \"\\n\"" % line.replace("'", "''"))
s.sendall(vim.eval('value'))
data = '>'
#end if
if not data:
break
#end if
result += data
#end while
#end if
s.close()
vim.command("let result = ''")
lines = result.split("\n")
for line in lines:
vim.command("let result = result . '%s\n'" % line.replace("'", "''"))
#end for
SCRIPT
catch
call sw#display_error("There is a problem communicating with the server on port " . port . ". Maybe the server is down?")
return ''
endtry
if len(result) <= 3
let result = ''
function! s:init_timer()
if s:timer.id != ''
call timer_stop(s:timer.id)
endif
return substitute(result, '\r', '', 'g')
let s:timer = {'id': '', 'sec': 0}
endfunction
function! sw#server#stop(port)
call s:pipe_execute('COM', "exit", 0, a:port)
function! sw#server#timer(timer)
let s:timer.sec += 1
echo "Query time: " . s:timer.sec . " seconds"
endfunction
function! sw#server#fetch_result()
let result = s:pipe_execute('RES', v:servername . "#" . b:unique_id, 1, b:port)
return result
endfunction
function! sw#server#disconnect_buffer(...)
let channel = ''
if (exists('b:sw_channel'))
let channel = b:sw_channel
unlet b:sw_channel
endif
if a:0
let channel = a:1
endif
call sw#server#execute_sql('exit', channel)
unlet s:channel_handlers[channel]
call s:init_timer()
function! sw#server#open_dbexplorer(profile, port)
return s:pipe_execute('DBE', substitute(a:profile, '___', "\\\\", 'g') . "\n", 1, a:port)
if exists('g:sw_airline_support') && g:sw_airline_support == 1
call airline#update_statusline()
endif
endfunction
function! sw#server#dbexplorer(sql)
if !exists('b:profile')
return
endif
call sw#server#open_dbexplorer(b:profile, b:port)
if a:sql =~ "^:"
let func = substitute(a:sql, '^:', '', 'g')
execute "let s = " . func . "(getline('.'))"
else
let s = s:pipe_execute('DBE', substitute(b:profile, '___', "\\\\", 'g') . "\n" . a:sql . ';' . "\n", 1)
endif
let lines = split(s, "\n")
let result = []
let rec = 0
for line in lines
if rec && !(line =~ '\v^[\=]+$')
call add(result, line)
endif
if line =~ '\v\c^[\=]+$'
let rec = 1
function! sw#server#get_buffer_url(buffer)
for key in keys(s:channel_handlers)
if s:channel_handlers[key]['buffer'] == a:buffer
return s:channel_handlers[key]['current_url']
endif
endfor
if len(result) == 0
let result = split(s, "\n")
endif
return result
return ''
endfunction
function! sw#server#execute_sql(sql, wait_result, port)
let sql = a:sql
if !(substitute(sql, "^\\v\\c\\n", ' ', 'g') =~ b:delimiter . '[ \s\t\r\n]*$')
let sql = sql . b:delimiter . "\n"
endif
return s:pipe_execute('COM', sql, a:wait_result, a:port)
function! sw#server#get_active_connections()
let result = ''
for key in keys(s:channel_handlers)
let url = s:channel_handlers[key]['current_url']
let result .= (result == '' ? '' : "\n") . s:channel_handlers[key]['buffer'] . ' - ' . (url == '' ? 'NOT CONNECTED' : url)
endfor
return result == '' ? 'No active sql workbench buffers' : result
endfunction
function! sw#server#send_feedback(val)
return s:pipe_execute('VAL', a:val, 0)
function! sw#server#tmp()
return s:channel_handlers
endfunction
function! sw#server#open_dbexplorer(profile)
let channel = s:start_sqlwb('dbexplorer')
let command = sw#get_connect_command(a:profile)
call sw#server#execute_sql(command, channel)
return channel
endfunction
......@@ -98,6 +98,7 @@ function! sw#session#unset_buffer_variable(var)
endfunction
function! sw#session#sync()
return
if !exists("g:SessionLoad")
for buffer in keys(g:sw_session)
if !buffer_exists(buffer)
......@@ -110,6 +111,7 @@ function! sw#session#sync()
endfunction
function! sw#session#restore()
return
let g:sw_session = {}
let g:sw_autocommands = {}
if exists('g:Str_sw_session')
......
此差异已折叠。
此差异已折叠。
......@@ -61,10 +61,6 @@ if !exists('g:sw_search_default_objects')
let g:sw_search_default_objects = '%'
endif
if !exists('g:sw_search_default_result_columns')
let g:sw_search_default_result_columns = ''
endif
if !exists('g:sw_search_default_compare_types')
let g:sw_search_default_compare_types = 'contains'
endif
......@@ -133,10 +129,6 @@ if !exists('g:sw_tab_switches_between_bottom_panels')
let g:sw_tab_switches_between_bottom_panels = 1
endif
if !exists('g:sw_use_old_sw')
let g:sw_use_old_sw = 0
endif
if !exists('g:sw_highlight_resultsets')
let g:sw_highlight_resultsets = 1
endif
......@@ -145,6 +137,14 @@ if !exists('g:sw_save_resultsets')
let g:sw_save_resultsets = 0
endif
if !exists('g:sw_log_to_file')
let g:sw_log_to_file = 0
endif
if !exists('g:sw_command_timer')
let g:sw_command_timer = 1
endif
"if !exists('g:sw_overwrite_current_command')
" let g:sw_overwrite_current_command = 0
"endif
......@@ -169,33 +169,54 @@ for _profile in items(g:extra_sw_tabs)
endfor
endfor
for key in keys(g:SW_Tabs)
let tabs = g:SW_Tabs[key]
for tab in tabs
for shortcut in keys(g:extra_sw_panels)
let panels = g:extra_sw_panels[shortcut]
for panel in panels
if tab['shortcut'] == shortcut && key == panel['profile']
call add(tab['panels'], panel['panel'])
endif
endfor
endfor
endfor
endfor
command! -nargs=+ -complete=customlist,sw#autocomplete_profile SWDbExplorer call sw#dbexplorer#show_panel(<f-args>)
command! -nargs=? SWDbExplorerClose call sw#dbexplorer#hide_panel(<f-args>)
command! SWDbExplorerRestore call sw#session#restore_dbexplorer()
command! SWDbExplorerReconnect call sw#dbexplorer#reconnect()
command! -nargs=+ -complete=file SWSqlConnectToServer call sw#server#connect_buffer(<f-args>, g:sw_sqlopen_command)
command! -bang SWSqlExecuteCurrent call sw#sqlwindow#execute_sql(<bang>1, sw#sqlwindow#extract_current_sql())
command! -bang SWSqlExecuteSelected call sw#sqlwindow#execute_sql(<bang>1, sw#sqlwindow#extract_selected_sql())
command! -bang SWSqlExecuteAll call sw#sqlwindow#execute_sql(<bang>1, sw#sqlwindow#extract_all_sql())
command! -bang -nargs=1 SWSqlExecuteMacro call sw#sqlwindow#execute_macro(<f-args>, <bang>1)
command! SWSqlToggleMessages call sw#sqlwindow#toggle_messages()
command! SWDbExplorerToggleFormDisplay call sw#dbexplorer#toggle_form_display()
command! -nargs=* -complete=file SWSqlBufferConnect call sw#server#connect_buffer(g:sw_sqlopen_command, <f-args>)
command! -nargs=* -complete=file SWSqlBufferDisconnect call sw#server#disconnect_buffer()
command! SWSqlExecuteCurrent call sw#sqlwindow#execute_sql(sw#sqlwindow#extract_current_sql())
command! SWSqlExecuteSelected call sw#sqlwindow#execute_sql(sw#sqlwindow#extract_selected_sql())
command! SWSqlExecuteAll call sw#sqlwindow#execute_sql(sw#sqlwindow#extract_all_sql())
command! -nargs=0 SWSqlGetSqlCount call sw#sqlwindow#get_count(sw#sqlwindow#extract_current_sql())
command! -nargs=0 SWSqlGetObjRows call sw#sqlwindow#get_count(expand('<cword>'))
command! -nargs=0 SWSqlShowActiveConnections echo sw#server#get_active_connections()
command! -nargs=0 SWSqlShowLog call sw#sqlwindow#show_current_buffer_log()
command! -nargs=* SWSqlExecuteMacro call sw#sqlwindow#execute_macro(<f-args>)
command! -nargs=0 SWSqlShowLastResultset call sw#sqlwindow#open_resulset_window()
command! SWSqlToggleMessages call sw#sqlwindow#toggle_messages()
command! SWSqlToggleFormDisplay call sw#sqlwindow#toggle_display()
command! SWSqlObjectInfo call sw#sqlwindow#get_object_info()
command! SWSqlObjectSource call sw#sqlwindow#get_object_source()
command! SWSqlExport call sw#sqlwindow#export_last()
command! -bang -nargs=+ SWSqlExecuteNow call sw#cmdline#execute(<bang>1, <f-args>)
command! -nargs=+ SWSqlExecuteNow call sw#cmdline#execute(b:sw_channel, <f-args>)
command! -nargs=0 SWSqlExecuteNowLastResult call sw#cmdline#show_last_result()
command! -bang -nargs=+ SWSearchObject call sw#search#object(<bang>1, <f-args>)
command! -bang SWSearchObjectAdvanced call sw#search#object(<bang>1)
command! -bang -nargs=1 SWSearchObjectDefaults call sw#search#object_defaults(<bang>1, <f-args>)
command! -bang -nargs=+ SWSearchData call sw#search#data(<bang>1, <f-args>)
command! -bang SWSearchDataAdvanced call sw#search#data(<bang>1)
command! -bang -nargs=1 SWSearchDataDefaults call sw#search#data_defaults(<bang>1, <f-args>)
command! -nargs=+ SWSearchObject call sw#search#object(<f-args>)
command! SWSearchObjectAdvanced call sw#search#object()
command! -nargs=1 SWSearchObjectDefaults call sw#search#object_defaults(<f-args>)
command! -nargs=+ SWSearchData call sw#search#data(<f-args>)
command! SWSearchDataAdvanced call sw#search#data()
command! -nargs=1 SWSearchDataDefaults call sw#search#data_defaults(<f-args>)
command! -bang -nargs=* SWSqlAutocomplete call sw#autocomplete#cache(<bang>0, <f-args>)
command! -nargs=1 -complete=customlist,sw#autocomplete#complete_cache_name SWSqlAutocompleteLoad call sw#autocomplete#load(<f-args>)
command! -nargs=1 -complete=customlist,sw#autocomplete#complete_cache_name SWSqlAutocompletePersist call sw#autocomplete#persist(<f-args>)
command! SWSqlBufferRestore call sw#session#restore_sqlbuffer()
command! -nargs=0 SWSqlShowAllColumns call sw#sqlwindow#show_all_columns()
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlShowOnlyColumn call sw#sqlwindow#show_only_column(<f-args>)
command! -nargs=+ -complete=customlist,sw#sqlwindow#complete_columns SWSqlShowOnlyColumns call sw#sqlwindow#show_only_columns([<f-args>])
......@@ -204,7 +225,7 @@ command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlHideCo
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlFilterColumn call sw#sqlwindow#filter_column(<f-args>)
command! -nargs=1 -complete=customlist,sw#sqlwindow#complete_columns SWSqlUnfilterColumn call sw#sqlwindow#un_filter_column(<f-args>)
command! -nargs=0 SWSqlRemoveAllFilters call sw#sqlwindow#remove_all_filters()
command! -nargs=0 SWSqlWipeoutResultsSets let g:sw_last_resultset = []
command! -bang -nargs=0 SWSqlWipeoutResultsSets call sw#sqlwindow#wipeout_resultsets(<bang>0)
command! -nargs=+ -complete=customlist,sw#autocomplete_profile SWServerStart call sw#server#run(<f-args>)
command! -nargs=1 SWServerStop call sw#server#stop(<f-args>)
......
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
" Due to some potential rendering issues, the use of the `space` variable is
" recommended.
let g:sw_airline_support = 1
let s:spc = g:airline_symbols.space
let s:airline_section_c = ''
" First we define an init function that will be invoked from extensions.vim
function! airline#extensions#sw#init(ext)
" Here we define a new part for the plugin. This allows users to place this
" extension in arbitrary locations.
call a:ext.add_statusline_func('airline#extensions#sw#apply')
endfunction
" This function will be invoked just prior to the statusline getting modified.
function! airline#extensions#sw#apply(...)
if s:airline_section_c == ''
let s:airline_section_c = g:airline_section_c
endif
if exists('b:sw_channel')
let url = sw#server#get_buffer_url(bufname('%'))
if url != ''
let g:airline_section_c = s:airline_section_c . s:spc . g:airline_left_alt_sep . s:spc . url
return
else
let g:airline_section_c = s:airline_section_c . s:spc . g:airline_left_alt_sep . s:spc . 'NOT CONNECTED'
return
endif
endif
if (s:airline_section_c != '')
let g:airline_section_c = s:airline_section_c
endif
endfunction
__author__ = 'Cosmin Popescu'
此差异已折叠。
此差异已折叠。
#!/usr/bin/env python
#
from optparse import OptionParser
from lib.sqlwbserver import SQLWorkbench
from lib.sqlwbserver_old import SQLWorkbenchOld
import sys
if __name__ == "__main__":
parser = OptionParser()
obj = SQLWorkbench()
parser.add_option("-t", "--tmp", help="The location of tmp folder", dest="tmp", default="/tmp")
parser.add_option("-p", "--profile", help="The sql workbench profile", dest="profile", default=None)
parser.add_option("-c", "--command", help="The command to launch the sql workbench console", dest="cmd", default=None)
parser.add_option("-v", "--vim", help="The path to the vim executable", dest="vim", default='vim')
parser.add_option("-o", "--port", help="The port on which to send the commands", dest="port", default='5000', type = "int")
parser.add_option("-l", "--log", help = "Log file path", default = None, dest = "log")
parser.add_option("-d", "--debug", help="The debuging mode", dest="debug", default='0')
parser.add_option("-O", "--old", help="Use an SQL Workbench (before build 118)", dest="old", default='0')
(options,args) = parser.parse_args(sys.argv[1:], obj)
if hasattr(options, 'old'):
if options.old == '1':
obj = SQLWorkbenchOld()
(options,args) = parser.parse_args(sys.argv[1:], obj)
#end if
#end if
obj.args = args
obj.main()
#end if
# vim:set et ts=4 sw=4:
#EOF
""execute "setlocal <M-i>=\ei"
""execute "setlocal <M-m>=\em"
""execute "setlocal <M-s>=\es"
nmap <buffer> <C-A> :SWSqlExecuteAll!<cr>
vmap <buffer> <C-e> :<bs><bs><bs><bs><bs>SWSqlExecuteSelected!<cr>
nmap <buffer> <C-@> :SWSqlExecuteCurrent!<cr>
nmap <buffer> <Leader><C-A> :SWSqlExecuteAll<cr>
vmap <buffer> <Leader><C-e> :<bs><bs><bs><bs><bs>SWSqlExecuteSelected<cr>
nmap <buffer> <Leader><C-@> :SWSqlExecuteCurrent<cr>
nmap <buffer> <leader><C-m> :SWSqlExecuteMacro<cr>
nmap <buffer> <leader>os :SWSqlObjectSource<cr>
nmap <buffer> <C-m> <C-w>b:SWSqlToggleMessages<cr><C-w>t
nmap <buffer> <C-c> :SWKillCurrentCommand<cr>
nmap <buffer> <leader>oi :SWSqlObjectInfo<cr>
nmap <buffer> <Leader><C-c> :SWSqlGetSqlCount<cr>
......@@ -2,7 +2,6 @@
""execute "setlocal <M-s>=\es"
""execute "setlocal <M-m>=\em"
""execute "setlocal <M-d>=\ed"
nmap <buffer> <C-A> :SWSqlExecuteAll<cr>
nmap <buffer> <C-i> :SWSqlObjectInfo<cr>
nmap <buffer> <Leader>os :SWSqlObjectSource<cr>
nmap <buffer> <C-m> :SWSqlToggleMessages<cr>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册