Skip to content

Commit 612ed9b

Browse files
Merge pull request #338 from vim-vdebug/issue-228-fix-vdebug-opt-dictionary
add vim functions to add or set the path maps
2 parents 4b5616b + 20c6727 commit 612ed9b

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

plugin/vdebug.vim

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ command! VdebugStart python3 debugger.run()
118118
command! -nargs=? BreakpointRemove python3 debugger.remove_breakpoint(<q-args>)
119119
command! BreakpointWindow python3 debugger.toggle_breakpoint_window()
120120
command! -nargs=? -bang VdebugEval python3 debugger.handle_eval('<bang>', <q-args>)
121-
command! -nargs=+ -complete=customlist,s:OptionNames VdebugOpt python3 debugger.handle_opt(<f-args>)
121+
command! -nargs=+ -complete=customlist,s:OptionNames VdebugOpt :call Vdebug_set_option(<f-args>)
122+
command! -nargs=+ VdebugPathMap :call Vdebug_path_map(<f-args>)
123+
command! -nargs=+ VdebugAddPathMap :call Vdebug_add_path_map(<f-args>)
122124
command! -nargs=? VdebugTrace python3 debugger.handle_trace(<q-args>)
123125

124126
if hlexists("DbgCurrentLine") == 0
@@ -246,6 +248,38 @@ function! s:OptionNames(A,L,P)
246248
endif
247249
endfunction
248250

251+
function! Vdebug_set_option(option, ...)
252+
if ! a:0
253+
let g:vdebug_options[a:option]
254+
return
255+
endif
256+
if a:option == 'path_maps'
257+
echomsg 'use :VdebugAddPathMap to add extra or :VdebugPathMap to set new'
258+
return
259+
elseif a:option == 'window_commands'
260+
echomsg 'update window_commands in your vimrc please'
261+
return
262+
elseif a:option == 'window_arrangement'
263+
echomsg 'update window_arrangement in your vimrc please'
264+
return
265+
endif
266+
echomsg 'Setting vdebug option "' . a:option . '" to: ' . a:1
267+
let g:vdebug_options[a:option] = a:1
268+
exe ":python3 debugger.reload_options()"
269+
endfunction
270+
271+
function! Vdebug_add_path_map(from, to)
272+
echomsg 'Adding vdebug path map "{' . a:from . ':' . a:to . '}"'
273+
let g:vdebug_options['path_maps'] = extend(g:vdebug_options['path_maps'], {a:from: a:to})
274+
exe ":python3 debugger.reload_options()"
275+
endfunction
276+
277+
function! Vdebug_path_map(from, to)
278+
echomsg 'Setting vdebug path maps to "{' . a:from . ':' . a:to . '}"'
279+
let g:vdebug_options['path_maps'] = {a:from: a:to}
280+
exe ":python3 debugger.reload_options()"
281+
endfunction
282+
249283
function! Vdebug_get_visual_selection()
250284
let [lnum1, col1] = getpos("'<")[1:2]
251285
let [lnum2, col2] = getpos("'>")[1:2]

pythonx/vdebug/debugger_interface.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ def step_out(self):
6666
"""
6767
self.session_handler.dispatch_event("step_out")
6868

69-
def handle_opt(self, option, value=None):
70-
"""Set an option, overwriting the existing value.
71-
"""
72-
if value is None:
73-
return self.ui.say(opts.Options.get(option))
74-
self.ui.say("Setting vdebug option '%s' to: %s" % (option, value))
75-
vim.command('let g:vdebug_options["%s"] = "%s"' % (option, value))
76-
return opts.Options.overwrite(option, value)
77-
7869
def handle_return_keypress(self):
7970
"""React to a <enter> keypress event.
8071
"""

0 commit comments

Comments
 (0)