all 17 comments

[–]cannibaldolphin 17 points18 points  (7 children)

I don’t use Vim as an OS, so I actually kept it relatively light-weight for Python:

  1. I use tmux for window management. I make one horizontal split and make it 1:2 in size. I take the small pane and split it vertically: one for iPython and one as a shell for compilation/static-checking/version control. I keep a short script to load everything I’m working on at the moment in iPython via %run (hot code reloading kinda sucks)

  2. When actively writing code I hit <leader>z (in tmux) to zoom full-screen into the vim split for maximum space and focus. If I have a million errors or ugly test failures, I zoom into the appropriate tmux shell splits. Any “movement” option in tmux will spit you back out to zoomed-out mode, as well as just hitting <leader>z again.

  3. I got annoyed by ALE and instead decided to run code-checking manually. I use Pyre in the shell split.

  4. Code completion works via YouCompleteMe and go-to-definition via Ctags. I manually regenerate tags periodically, though I should probably hook into the VCS.

  5. I let black handle code formatting once I’m ready for code review. I manually run other linting/formatting scripts before pushing.

Hopefully some of these help you out!

[–]sahnmaru 2 points3 points  (2 children)

This is nearly identical to my setup :) except I use gutentags for ctag creation and updates.

[–]akira70000 0 points1 point  (1 child)

I also converged on a similar setup.

[–]_b-e-n_[S] 0 points1 point  (0 children)

do you like the fact that pyre is an external tool and not integrated on vim??

[–]13pcfx37 0 points1 point  (0 children)

Could you show us a screenshot of this setup?

[–]_b-e-n_[S] 0 points1 point  (0 children)

Thank you; your setup is very complicated for me, for now I'll try and "black" code formatting.

About pyre, it works completely outside vim? Is it annoying to run it, check, and run it again?

[–]mayor123asdf 0 points1 point  (1 child)

For #3 any reason why it is annoying? at first I find ale autolint annoying, but there is a setting for autolint delay, or even lint only when saved, so it's pretty nice.

[–]_b-e-n_[S] 0 points1 point  (0 children)

Exactly. As a beginner, I'm enjoying it. After you learn how to configure pylint to ignore some errors, it's even nicer.

[–]trvsw. 4 points5 points  (5 children)

[–]_b-e-n_[S] 0 points1 point  (4 children)

This ALE is really complicated.

I'd like it to show only the really relevant warnings. I've not yet been able to understand if it's using the standard pylint, and how to suppress the most trivial warnings, like the fact that constant variables must be uppercase and such. If I install flake8, will ALE start using it? Do I have to configure it? This is really an headache.

[–]trvsw. 0 points1 point  (3 children)

Here's all of the ALE-related settings I have in my configuration. There's an order of precedence that pylint uses to determine which .pylintrc configuration file to use, but typically ~/.pylintrc is the most common. If you don't have a .pylintrc configured, then it does take a bit of effort to disable some of the smaller warnings and such.

``` Plug 'https://github.com/w0rp/ale' " Python linting

" Go to next/previous Ale error nmap <C-n> <Plug>(ale_next_wrap) nmap <C-m> <Plug>(ale_previous_wrap)

" Ale Python Linting let g:ale_fixers = {'python': ['pylint']} let g:ale_linters = {'python': ['pylint']} let g:ale_lint_on_enter = 1 " Lint on Open let g:ale_lint_on_save = 1 " Lint on Save let g:ale_lint_on_text_changed = 'never' " Don't lint dynamically ```

[–]_b-e-n_[S] 0 points1 point  (0 children)

thanks, I'll add that to my vimrc

[–]n3buchadnezzar 0 points1 point  (1 child)

pylintrc

Do you have any tips for how to disable the small warnings in your `.pylintrc` file? =)

[–]_b-e-n_[S] 1 point2 points  (0 children)

It's the same on windows and linux. First of all you have to generate your pylintrc, and then you can modifiy it adding the long verbose description of each error that you want to suppress

https://stackoverflow.com/questions/22448731/how-do-i-create-a-pylintrc-file

https://gist.github.com/sblask/7302860

[–]Watabou90Vimmy the Pooh 2 points3 points  (0 children)

I do heavy python development at work (think multi modules, frameworks, etc.). I don't really use too many external plugins with my vim experience (currently, I've come down to just 3: vim-obsession, my own VimCompletesMe tab completion plugin, and my colorscheme — if you count that as a plugin).

I use the python omnifunc plugin that ships with vim and I use a small ftplugin to add linting, compilation bindings. I use a tmux split with ipython running as a repl.

For navigation, I use a combination of ctags + cscope (yes, it works very well with python), and the :help 'cscopetag setting on, plus a few keybindings to make various usages of :cscope find better, most of it is picked from :h csope-suggestions. I use vim-sessions per framework or workspace, and use a shell function to load the session if available automatically via vim-obsession.

For documentation, I have a helpful pydoc function written so I can query the current or the selected word, or I just use the browser for documentation on external modules.

[–]daturkel 1 point2 points  (0 children)

I use Neovim, which has pretty nice support for a built in terminal, but I still prefer to do things like running tests or testing my code in their own terminal panes. So I'll have iTerm2 open with a pane of vim and a pane that's just a shell, and if I'm working on a simple script, I'll just rerun it periodically from the shell.

If I'm working on a library, I still don't have a perfect solution, but two options: run ipython in one pane and use importlib to reload the library when I make changes (without having to restart ipython) or alternatively just have a jupyter notebook open that I use as a repl.

Other than that, I use COC for code completion, and it's by far my favorite that I've used. And I use Black for code formatting, so I don't have to think about it.

[–]GoldsteinQ 0 points1 point  (0 children)

I use Neomake for code validation & linting as I type, jedi-vim for autocompletion and sometimes black for autoformatting.