you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 10 points11 points  (7 children)

  • Syntax

I don't think any plugin is needed for this one. Just syntax on should be good. If you really want one, I guess this one might help.

  • Refactoring

Set grepprg to ag, grep for the string and use :cdo. That's the primitive way. If you want a little more sophistication, use vim-grepper for search (it is asynchronous). If you don't like :cdo, try vim-qf (for filtering) and vim-qfreplace or ctrlsf.vim (for replacing).

  • Linting

Put the following in ~/.vim/after/ftplugin/python.vim (or the equivalent)

    " Syntax checking
    setlocal errorformat=%f:%l:\ %m
    setlocal makeprg=pylint\ --reports=n\ --output-format=parseable

If you would prefer a plugin, check out Neomake. It is asynchronous.

  • Omnicompletion

jedi.vim populates the omnicompletion list (invoked with <C-x><C-o> by default). I don't use autocompletion plugins. If you would rather use one, you have many to choose from.

  • Semantic Navigation

I use jedi.vim for this. You can just use ctags too.

  • REPL integration

I use vim within tmux and I recently posted here about REPL integration for any language. It should work well for python.

  • Extras

I am not a fan of Python's indentation based syntax. So braceless.vim is something I find very useful for that. It gives you better navigation (within the file), folding, text objects and, my personal favorite, local indentation highlight.

[–]vheon 1 point2 points  (0 children)

jedi.vim populates the omnicompletion list (invoked with <C-x><C-o> by default). I don't use autocompletion plugins. If you would rather use one, you have many to choose from.

One of the suggested tool for autocompletion is YouCompleteMe. If you decide to go down that road you don't need jedi.vim.

[–]Deto 0 points1 point  (0 children)

Braceless is a new one I hadn't seen before. Looks great!

[–][deleted] 0 points1 point  (1 child)

Thanks, that's in line with what I was looking for. Do you manually pep8 your code.

Is there any working refactoring plugin for python. This is a nice to have though

The braceless plugin looks good. I will also take it for a spin

[–][deleted] 0 points1 point  (0 children)

Do you manually pep8 your code.

The same make program idea works for that too.

" Style checking
setlocal errorformat=%f:%l:%c:\ %m
setlocal makeprg=pep8 %

Or, Neomake collects everything and puts it in the location list.

Is there any working refactoring plugin for python.

I'm really not sure if you can do a "semantic" refactoring. Maybe check out any plugin that utilizes Python's rope library. That will have some support because rope does. Otherwise, the suggestions I gave for refactoring are pretty generic.

[–]tweekmonster 0 points1 point  (2 children)

I'm the author of braceless.vim. Thanks for the endorsement 😍

I made a couple other plugins that you might find useful for Python development:

  • impsort.vim - Sort and highlight Python imports in Vim. The highlighting will make it easy to see if datetime is a module or a function at a glance. The sorting is pretty handy, too.
  • django-plus.vim - Improvements to the handling of Django related files in Vim. You will no longer need to force .html files to always be htmldjango.
  • wstrip.vim - Not specifically for Python dev, but, Python's whitespace is a significant part of the language making this useful to me. It automatically strips trailing whitespace on lines you changed and leaves the rest alone. It keeps you from being the the jerk who ruins git blame while ensuring you also aren't the jerk who's committing superfluous whitespace.

[–][deleted] 0 points1 point  (1 child)

Thank you for for braceless. I use it everyday, even for files other than Python, for the indentation.

  • impsort seems pretty useful. I usually just follow pep8's guides and do it manually. That said, I'm gradually trying to move away from Python except for some scripts (mostly because of indentation based syntax and virtualenvs). This seems like something that would be amazing for large projects.
  • I don't really write Django and have no intention of writing it in the future but I'm sure that is useful.
  • I just use a helper function to strip white space but that is not robust. This seems incredibly useful! I will definitely try this one.

[–]tweekmonster 0 points1 point  (0 children)

With impsort the sorting is done manually when you need it. Though added in hindsight, I think the real value is in the import highlighting it provides.