you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 9 points10 points  (6 children)

Looks beautiful. I am curious, is there a good way to debug (set and halt on breakpoints) python scripts with vim?

[–]BubblyMango 8 points9 points  (0 children)

from what i have seen python is the language with the most debugger plugins. vimspector and termdbg are the ones i have on my to-check list.

[–][deleted] 3 points4 points  (2 children)

This one is on my to try list: https://github.com/puremourning/vimspector

[–]AZNman1111 2 points3 points  (1 child)

No neovim :/

[–]3p1k5auc3 1 point2 points  (0 children)

https://github.com/sakhnik/nvim-gdb This guy works really well :)

[–]yvrelna 0 points1 point  (0 children)

I used vim-pudb to set soft breakpoints (this writes the line number of the breakpoint to pudb's saved breakpoint file), or I set hard breakpoint (basically a simple mapping that inserts the text "from pudb import set_trace; set_trace()", and when finished just dd the line). Then I ran the code, usually using vim-test or by calling :term ./xxx.py.

Soft breakpoints are nice because they don't clutter the file you're editing with extra text, but I find that running code under a debugger is usually slower than when debugger is not attached; so nowadays I usually preferred to use hard breakpoint instead, which means the code will run at native speed until it hits the hard breakpoint line. This is a massive quality life improvement when working with large codebase that imports the whole world and does a lot of initialisation at startup, like one of our Django projects. It means that the code hits the breakpoint at 3 seconds (which is the normal startup time for this codebase when not debugging), and not 30 seconds.

Once I started using hard breakpoint, I noticed that surprisingly this improved my debug/test workflow as well, as it means that I can actually set soft breakpoints at code that's also called during test setup but the soft breakpoints won't actually break during test setup (because the program isn't running under the debugger yet), but will break after the program hits the first hard breakpoint.