mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 00:34:49 +02:00
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:
parent
2be52ed039
commit
7a7c971bd1
@ -64,4 +64,4 @@ location.
|
|||||||
Add the following line to your ``vimrc``, where ``{path}`` is the path to
|
Add the following line to your ``vimrc``, where ``{path}`` is the path to
|
||||||
the main Powerline project directory::
|
the main Powerline project directory::
|
||||||
|
|
||||||
source {path}/powerline/ext/vim/powerline.vim
|
source {path}/powerline/ext/vim/source_plugin.vim
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
def source_plugin():
|
def source_plugin():
|
||||||
import os
|
import os
|
||||||
import vim
|
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') + '")'))
|
||||||
|
@ -1,13 +1,4 @@
|
|||||||
if ! has('python')
|
python import uuid, vim
|
||||||
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 from powerline.core import Powerline
|
python from powerline.core import Powerline
|
||||||
python pl = Powerline('vim')
|
python pl = Powerline('vim')
|
||||||
|
|
||||||
|
11
powerline/ext/vim/source_plugin.vim
Normal file
11
powerline/ext/vim/source_plugin.vim
Normal 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')
|
Loading…
x
Reference in New Issue
Block a user