Requested feature
It would be nice to be able to run custom commands when starting/stopping GDB through the termdebug plugin.
An example would be to be able to turn on line numbers when :Termdebug ... is issued and turn them off when typing quit in GDB.
Solution
Events like TermdebugStartPre, TermdebugStartPost, TermdebugStopPre, TermdebugStopPost should allow this quite easily.
Alternatives
To run custom commands upon starting termdebug I'm currently wrapping :Termdebug around a function and, e.g., call set nu from there.
To restore/undo those commands when termdebug terminates I currently don't have a solution. I thought about using the hidden buffer that the plugin uses to communicate with gdb but haven't looked into it yet.
If this is something interesting, with some pointers, I should be able to contribute to the issue myself.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.![]()
If this is something interesting, with some pointers, I should be able to contribute to the issue myself.
Check out $VIMRUNTIME/pack/dist/opt/termdebug/plugin/termdebug.vim.
For every new event you want the plugin to fire (TermdebugStartPre, TermdebugStartPost, TermdebugStopPre, TermdebugStopPost), add this kind of block:
if exists('#User#TermdebugStartPre')
doautocmd <nomodeline> User TermdebugStartPre
endif
Then the user can write this in their vimrc:
autocmd User TermdebugStartPre echomsg 'do something'
Example of a patch:
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index f80d9c396..45d4beaa2 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -108,6 +108,9 @@ func s:StartDebugCommand(bang, ...) endfunc func s:StartDebug_internal(dict) + if exists('#User#TermdebugStartPre') + doautocmd <nomodeline> User TermdebugStartPre + endif if exists('s:gdbwin') echoerr 'Terminal debugger already running, cannot run two' return
When you get something which works, don't forget to add some documentation in $VIMRUNTIME/doc/terminal.txt (:help terminal-debug).
@brammool if it's the same for you I can give it a try.
I already have somewhat of a working version, I just need to add some documentation and open a PR.
Related question, could we also add a new filetype for terminal window? I'd like to map some keys for gdb window and this kinda works, but only when g:termdebug_disasm_window is turned off, if I'm reading the code correctly. A new filetype like termdebug would be more robust.
—
Yeah, seems fine to me. 👍
I was also wondering about the window with the application output, maybe it should also have a custom filetype, like termdebug_program or something along these lines. I personally don't have any use for it right now, but maybe someone else does.
—
I know, but what I'm getting at is that someone might want to set up mappings there or register the job ID from that window to send keys to the program etc. Maybe I'm just overthinking it.
I guess this issue can be closed, since the Termdebug* events have been added when the PR #8711 was merged.
If there are other issues with the termdebug plugin, they should probably be dealt with in a dedicated and separate issue.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Please open a new issue if the newly added events are insufficient.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Closed #8709.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.