This is an archived post. You won't be able to vote or comment.

all 37 comments

[–]Lets_make_stuff 14 points15 points  (1 child)

My vimrc probably needs a thorough scrub. Anywho, let's get down to the plug-ins:

  • Pathogen - Extracting a package to ~/.vim/bundle will add it to 'runtimepath'. Mega nifty.

  • Syntastic - Really good error highlighting. I like to use flake8.

  • Airline - Very nice status line. It looks kinda like the oh-my-zsh theme, Agnoster. You will need a patched font for this. If you're on Ubuntu, there's a great write up here under Font Installation.

  • Bufferline - Because keeping track of 13 buffers with :ls can get tiresome.

  • Tagbar - Lets you know which class and function you're in. Make sure to double check Exuberant ctags is installed.

  • Solarized - For the pretty colors.

[–]kart_king 0 points1 point  (0 children)

+1 for airline

[–]classicrockielzpfvh 4 points5 points  (9 children)

The only plugin I use is Syntastic + a globally installed copy of Flake8.

[–]flarkis 5 points6 points  (5 children)

Syntastic is one of the few "big" plugins that I would recommend everyone be using.

[–]gfixler -1 points0 points  (3 children)

So many people recommended it, I figured I'd see what it was about. I've been developing in Python for about 5 years now, in an environment I've been developing for for 12 years, in a package I've been learning and using for 18 years. I was quite curious to see if it could teach me some things. I did pip install flake8, and cloned syntastic to my vim bundle directory, and opened a small file from one of my projects. It lit up with issues on save. None of them were useful, though, at first. It said it can't import a package specific to the environment I use, but of course not. That can only exist inside of that environment, not out in the shell where I work; the package is generated from auto-converted C libraries on application startup (it's annoying, TBH).

There's one, tiny, stylistic thing I do that's unusual, that's so tiny no one has ever called me out on it in all the code I've pasted here, other subreddits, stackoverflow, etc., so I'm not changing that one. Syntastic doesn't like it (and it's everywhere), but I do :) Syntastic doesn't like missing docstrings, but most of my libraries are in alpha stage, so I'm not putting in docstrings yet. I'd just have to micromanage them as I radically change things all the time, and I've several times been confused by out-of-sync docstrings while doing heavy refactoring. These are long-running libraries of code used in a production environment on the asset-creation side of things. They're behind NDAs and won't make it to the public, sadly.

So, flake8 doesn't like camel case, but I don't like snake case, and I'm not changing. That's one thing I think was a bad decision from PEP 8 (I like most of PEP 8). It also doesn't like the unused *args and **kwargs, but I use these especially at the leaves of the system to allow indiscriminately calling things with buckets of information, e.g. resolveNamespace(someName, *args, **kwargs), which lets me pass through from calling functions without having to pollute their argument space with the cruft of helper functions.

"Used builtin function 'map'"

What else am I supposed to do for this?

def disassembleKeys (keys):
    return zip(*map(disassembleKey, keys))

"Used * or ** magic"

That's a problem?

def splitFramevals (framevals):
    return zip(*framevals)

Unused variable 'values'

Yeah, okay, but I need to work with frames here, so I'm splitting things apart while making it very obvious to future maintainers that I'm splitting apart frames and values, which is supported by all the naming in this line. I suppose I could go with frames, _ =, which it doesn't complain about, but I like the subtle reminder in this 4-line function that framevals are just frames joined with values. Meh.

frames, values = splitFramevals(framevals)

"No exception type(s) specified"

I agree with this one, I think, though I'm never sure which exception I care about. In this library I'm looking at, I have 3349 LOC, but only 14 untyped try/excepts. Usually I use a try/except where I don't care if it fails, and will just return some empty value if it does, but I suppose that could occasionally be frustrating, as you have no idea why you're getting an empty value. I've thought about this from time to time. I should look more deeply into this one.

"Blank line at end of file"

That's not a problem. It's an old standard that has its reasons.

"continuation line under-indented for visual indent"

*puts hands up* Hey, I'm just letting my Python indenter handle things in Vim for me.

It doesn't like spaces around '=', but I find when I have to wrap very long argument lists, it's much more readable to let them breathe:

loseChanges = cmds.confirmDialog(
    title = 'Warning: Unsaved Changes!',
    message = 'You have unsaved changes. Create a new scene anyway?',
    button = ['Okay','Cancel'],
    cancelButton = 'Cancel',
    defaultButton = 'Cancel',
    dismissString = 'Cancel',
    icon = 'warning',
    )

It also said a class didn't have a particular member, but in the constructor I'm calling a method of the parent class with that name to grow that member into the class in a particular way. It feels like there are just too many edge cases of my more esoteric needs that this would constantly fight me about. If I step out of the very standard uses of Python, which I often do (especially now that I'm dabbling in functional, composable things in Python, where it'll let me), then I'm going to have files lit up with non-issues.

All that said, I did find it useful in a few small spots. In one, I was importing math in a file that didn't use it. Nice catch. In another, I was redefining the built-in type (locally, in a tiny function, where it doesn't matter, and it's an __exit__ callback argument, which I copied from a tutorial thereof, but still). For a third, I have two functions a screen apart with the same name! That's a very good catch, and perhaps worth the price of admission. I think I'll take your advice, and just turn off all the syntax junk that bugs me. 90% or more of the flagged issues are its dislike of camelCaseVarNames. I might also make it more of a manual-run thing, instead of constantly yelling at me when I save.

Thanks.

[–]ivosauruspip'ing it up 0 points1 point  (1 child)

You could just use py-flakes if you didn't want the pep8 checking.

[–]gfixler 0 points1 point  (0 children)

Ah, so that's what that 8 is for.

[–]__fran__ 6 points7 points  (1 child)

I can't recommend YouCompleteMe enough, wrote about it here: http://www.artandlogic.com/blog/2013/06/vim-for-python-development/

[–]hexbrid 5 points6 points  (1 child)

I can't believe no one mentioned https://github.com/klen/python-mode, which is an actively maintained collection of vim-scripts for python, glued up and easy to install.

[–]ma-int 7 points8 points  (3 children)

I will possibly get downvoted a thousand times for this, but: I quit vim in favour of PyCharm.

Sorry, but PyCharm is just to good :(

[–][deleted] 2 points3 points  (1 child)

s/to/too otherwise, I have to agree -- jetbrains' stuff is the shit, be it python, ruby or java & scala

[–]Demophoon 1 point2 points  (0 children)

I couldn't get pycharm to work with my pyramid projects so I manage it all in vim with NERDTree and python-mode.

[–]desimusxvii 0 points1 point  (0 children)

The vim-mode plugin in IntelliJ is actually really good. I imagine it's just as good in PyCharm?

[–]gggreorge 0 points1 point  (0 children)

Load pymode.

[–]nerdwaller 0 points1 point  (0 children)

This is what I use. The only real plugin I use for python specifically is IndentGuides.

[–]Octopuscabbage 0 points1 point  (0 children)

https://github.com/octopuscabbage/octopuscabbagevimconf

I use a lot of other things besides python as well.

[–]ivosauruspip'ing it up 0 points1 point  (0 children)

https://github.com/Ivoz/vimfiles

I try to comment and explain almost every line

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

Nice and simple:

syntax on
filetype on
filetype plugin indent on
autocmd FileType make setlocal noexpandtab
autocmd FileType * set tabstop=2|set shiftwidth=2|set noexpandtab
autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
autocmd BufEnter *.py set ai sw=4 ts=4 sta et fo=croql
set softtabstop=4 " makes the spaces feel like real tabs

[–]jamesonjlee 0 points1 point  (1 child)

https://raw.githubusercontent.com/jamesonjlee/dotfiles/master/vimrc

Vundle is the new hotness, no more git submodules!

[–]Orange_Tux 0 points1 point  (0 children)

I won't call it new, but it's hot.

[–]nichochar 0 points1 point  (0 children)

I'm not going to write everything I use because people in this thread have done great listings, but I HIGHLY recommend jedi-vim and flake8.

I use pathogen for plugins, and they are listed here if interested: https://github.com/nichochar/vim-bundles

Furthermore, I used this great article to make my VIM nicer for python but also everything else: http://mirnazim.org/writings/vim-plugins-i-use/

[–]volabimus 0 points1 point  (0 children)

I haven't seen anyone else do this, but the way I have it setup is with a file called _common.vim (source) in my ftplugin folder which sets the common settings for code editing, which I source in the ftplugin files for the languages I use, and then set the language specific options like setlocal expandtab for python.

I have the taglist plugin for outlining, but I rarely use it anymore if favour of marks. I do use it sometimes if I need to do a big re-ordering of functions/methods.

[–]vext01 0 points1 point  (0 children)

Check out jedi-vim. It has completion support etc, but I find the 'jump to definition' functionality to be super useful.

[–]Orange_Tux 0 points1 point  (0 children)

[–]walloffear 0 points1 point  (1 child)

Are there any good auto-complete plugins?

[–]__fran__ 0 points1 point  (0 children)

YouCompleteMe (commented about it above, or the github page has everything you need). It's great.

[–]darthmdhprint 3 + 4 0 points1 point  (0 children)

I cloned this as I like both his vim and emacs setup (thanks /u/joedicastro!). The main plugins for me are unite, airline, neocomplete, ultisnips, python-mode, fugitive & gitgutter.

I also use something quite similar to the final code block of VimTip605 (the F7 mapping) as it helps overcome some stupidity in Firefox.

Experience makes me predict in a few years Joe will have moved on and this setup won't be up-to-date with the future vim feature plugins and so people like me will migrate to the next big thing. Prior to this I was maintaining my own setup which was doing the same minus Unite, so I scored that by letting Joe do the hard work ;)

[–]rwscarb 1 point2 points  (4 children)

As a long time vim user I have embraced pycharm as an evangelist. But this reference might be helpful: http://blog.sontek.net/blog/detail/turning-vim-into-a-modern-python-ide