Move plugin loading with :source into separate file

This should resolve the issue with duplicate paths in sys.path by only
updating sys.path if the plugin is loaded using :source instead of
:python. sys.path is now updated in source_plugin.vim, which checks if
the user has Python installed, and updates sys.path before sourcing the
actual plugin file.

Refs #17.
Refs #19.
Refs #21.
This commit is contained in:
Kim Silkebækken 2013-01-02 08:38:28 +01:00
parent 2be52ed039
commit 7a7c971bd1
4 changed files with 15 additions and 12 deletions

View File

@ -64,4 +64,4 @@ location.
Add the following line to your ``vimrc``, where ``{path}`` is the path to
the main Powerline project directory::
source {path}/powerline/ext/vim/powerline.vim
source {path}/powerline/ext/vim/source_plugin.vim

View File

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
def source_plugin():
import os
import vim
vim.command('source ' + os.path.join(os.path.abspath(os.path.dirname(__file__)), 'powerline.vim'))
vim.command('source ' + vim.eval('fnameescape("' + os.path.join(os.path.abspath(os.path.dirname(__file__)), 'powerline.vim') + '")'))

View File

@ -1,13 +1,4 @@
if ! has('python')
echohl ErrorMsg
echomsg 'You need vim compiled with Python 2 support for Powerline to work. Please consult the documentation for more details.'
echohl None
finish
endif
python import sys, vim, os
python sys.path.append(vim.eval('expand("<sfile>:h:h:h:h")'))
python import uuid
python import uuid, vim
python from powerline.core import Powerline
python pl = Powerline('vim')

View File

@ -0,0 +1,11 @@
if ! has('python')
echohl ErrorMsg
echomsg 'You need vim compiled with Python 2 support for Powerline to work. Please consult the documentation for more details.'
echohl None
finish
endif
python import sys, vim
python sys.path.append(vim.eval('expand("<sfile>:h:h:h:h")'))
exec 'source '. fnameescape(expand('<sfile>:h') . '/powerline.vim')