data['path'] in segment.get_function is empty? #409

omega opened this Issue Apr 8, 2013 · 4 comments


None yet

2 participants

omega commented Apr 8, 2013

I'm trying to write a custom segment, with mostly the information from #151 to go on. I've got it semiworking, but only by adding $HOME/.config/powerline to path in

I've tried to understand where that path is supposed to be set, but I can't seem to find it. Is something missing in my config?

ZyX-I commented Apr 8, 2013

There is paths configuration setting. But it would be much better if you designed your segment as a python package installable by pip from the very beginning and use pip install --user -e . on your plugin repo: you won’t need the setting in question in this case and it will ease distribution for python users. It is in any case bad idea to put the segment into ~/.config/powerline, segment code is not a powerline configuration.

If it is vim segment common variant is appending to sys.path from some script (e.g. plugin/foo.vim). Make sure you append before the first .render() call. This call happens each time statusline is redrawn.

omega commented Apr 9, 2013

Ok, thank you for the feedback. I was (as I said), working from the rather limited information on custom segments, but I gave your suggestion a stab here:

Any and all feedback is much appreciated, I haven't written much python lately

I chose to use the powerlinex namespace because of According to that, every dist needs to support namespace and I figured keeping it out of powerline namespace might be a good idea (the added x is a convention from the perl-world, so sorry if there is another convention in python land)

ZyX-I commented Apr 9, 2013

Note that choosing segment name equal to existing forces you to support all arguments of this segment (there are currently no), but makes theme more consistent.

If somebody needs to use different before for your segment to separate python virtual environments from perl ones all he needs is adding powerlinex.segment.plenv.virtualenv key to segment_data, thus having identical names is fine. But if one wants to separate them by providing different colors he has no options with your code. I would suggest to return [{'contents': line.split(" ")[0], 'highlight_group': ['perl_virtualenv', 'virtualenv']}] for this reason.

You should not also use os.getcwd(). Use requires_segment_info decorator, segment_info argument and function segment_info['getcwd'] from this argument.

omega commented Apr 9, 2013

Ok, thanks for the feedback. If you want to use the segment I wrote as an example, feel free to do so :)

@omega omega closed this Apr 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment