here is a patch that fixes and enhances the termdebug plugin.

     - Make :Termdebug (without argument) an error
       After all, if no argument is given, what should you debug?

     - If you run :Termdebug several times, the plugin throws "E174: 
       command already exists", so add the bang argument to it".
       In addition, make the commands buffer-local.

     - Arguments supplied to the command line were not used correctly.
       So in case additional runtime arguments are given, use the
       "set args" command of gdb to set those arguments. This allows to 
       run e.g. :Termdebug vim --clean -c ":set nu". Currently I believe
       gdb will try to literally run "vim --clean -c ":set nu"" which 
       fails obviously.

Letzte Worte eines U-Boot Fahrers:
  "Ich schlafe nur bei offenem Fenster."

You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit

You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index 256f7ef60..9c061d587 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -25,7 +25,7 @@ endif
 " The command that starts debugging, e.g. ":Termdebug vim".
 " To end type "quit" in the gdb window.
-command -nargs=* -complete=file Termdebug call s:StartDebug(<q-args>)
+command -nargs=+ -complete=file Termdebug call s:StartDebug(<f-args>)
 " Name of the gdb command, defaults to "gdb".
 if !exists('termdebugger')
@@ -43,7 +43,7 @@ else
 hi default debugBreakpoint term=reverse ctermbg=red guibg=red
-func s:StartDebug(cmd)
+func s:StartDebug(...)
   let s:startwin = win_getid(winnr())
   let s:startsigncolumn = &signcolumn
@@ -58,6 +58,12 @@ func s:StartDebug(cmd)
     let vertical = 0
+  let args = ''
+  let run = a:1
+  if len(a:000) > 1
+    let args = join(a:000[1:])
+  endif
   " Open a terminal window without a job, to run the debugged program
   let s:ptybuf = term_start('NONE', {
 	\ 'term_name': 'gdb program',
@@ -90,7 +96,7 @@ func s:StartDebug(cmd)
   " Open a terminal window to run the debugger.
   " Add -quiet to avoid the intro message causing a hit-enter prompt.
-  let cmd = [g:termdebugger, '-quiet', '-tty', pty, a:cmd]
+  let cmd = [g:termdebugger, '-quiet', '-tty', pty, run]
   echomsg 'executing "' . join(cmd) . '"'
   let s:gdbbuf = term_start(cmd, {
 	\ 'exit_cb': function('s:EndDebug'),
@@ -104,6 +110,11 @@ func s:StartDebug(cmd)
   let s:gdbwin = win_getid(winnr())
+  " Set arguments to be run
+  if args isnot ''
+    call term_sendkeys(s:gdbbuf, 'set args ' . args . "\r")
+  endif
   " Connect gdb to the communication pty, using the GDB/MI interface
   call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r")
@@ -233,21 +244,22 @@ func s:CommOutput(chan, msg)
 " Install commands in the current window to control the debugger.
+" Add ! so it does not error if it runs several times
 func s:InstallCommands()
-  command Break call s:SetBreakpoint()
-  command Clear call s:ClearBreakpoint()
-  command Step call s:SendCommand('-exec-step')
-  command Over call s:SendCommand('-exec-next')
-  command Finish call s:SendCommand('-exec-finish')
-  command -nargs=* Run call s:Run(<q-args>)
-  command -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
-  command Stop call s:SendCommand('-exec-interrupt')
-  command Continue call s:SendCommand('-exec-continue')
-  command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>)
-  command Gdb call win_gotoid(s:gdbwin)
-  command Program call win_gotoid(s:ptywin)
-  command Source call s:GotoStartwinOrCreateIt()
-  command Winbar call s:InstallWinbar()
+  command! -buffer Break call s:SetBreakpoint()
+  command! -buffer Clear call s:ClearBreakpoint()
+  command! -buffer Step call s:SendCommand('-exec-step')
+  command! -buffer Over call s:SendCommand('-exec-next')
+  command! -buffer Finish call s:SendCommand('-exec-finish')
+  command! -buffer -nargs=* Run call s:Run(<q-args>)
+  command! -buffer -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
+  command! -buffer Stop call s:SendCommand('-exec-interrupt')
+  command! -buffer Continue call s:SendCommand('-exec-continue')
+  command! -buffer -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>)
+  command! -buffer Gdb call win_gotoid(s:gdbwin)
+  command! -buffer Program call win_gotoid(s:ptywin)
+  command! -buffer Source call s:GotoStartwinOrCreateIt()
+  command! -buffer Winbar call s:InstallWinbar()
   " TODO: can the K mapping be restored?
   nnoremap K :Evaluate<CR>

Raspunde prin e-mail lui