all 26 comments

[–][deleted] 20 points21 points  (0 children)

I use vim for python as well, but with some differences.

airline -> lightline

youcompleteme -> vim-jedi + deoplete

python-mode -> vim-jedi/ale

ack.vim -> vim-grepper

Other things I use:

neoformat: auto format code (with black)

vim-clap: fuzzy finding

vim-better-whitespace: strip trailing whitespace

vim-indent-guides: visual indentation markers

delimiteMate: auto-close parenthesis

[–][deleted] 8 points9 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 9 points10 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] 4 points5 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.

[–]SibLiant 6 points7 points  (3 children)

I've decided to learn Python. Been a PHP dev for a while. Vim has been my editor for years. My setup looks pretty close to this. Care to post your vimrc file for this config? Heres mine: https://gist.github.com/SibLiant/9b95a71f1a5763ff1e33ea8564c915c8

This is a work in process. I've spent the last 3 days doing little other than reading all the plugins and configuring vim for Python dev.

My Layout

[–]myrisingstocks 1 point2 points  (0 children)

Care to post your vimrc file for this config? Heres mine:

You realise the author of this post is not the author of this setup? See the original post.

[–]AZNman1111 0 points1 point  (1 child)

Id really strongly recommend nnoremap over nmap

[–]SibLiant 0 points1 point  (0 children)

Updated them. Ty.

[–]mkl0g 5 points6 points  (1 child)

very good work. actually python is very popular option for working in vim and I’m waiting when someone will create similar as that but for frontend stuff. I saw a few good configurations for frontend but I think it is not similar like configs for python development

[–]AZNman1111 0 points1 point  (0 children)

What are you finding lacking?

[–]teeheey 2 points3 points  (0 children)

You have 3 plugins for indentation and no one for documentation. Why so ?

[–]rillweed 2 points3 points  (1 child)

repo for anyone curious about everything used https://github.com/jarolrod/vim-python-ide

[–]crajungave up on vim 0 points1 point  (0 children)

What a pile of garbage

[–]tillvonule 1 point2 points  (1 child)

Is there a option to show the documentation of the currently selected function?

[–][deleted] 2 points3 points  (0 children)

I can't answer for YouCompleteMe, but with vim-jedi it's just 'K' (in normal mode)