Move the vim example to a separate plugin folder
When Powerline is installed as a package in the system-wide site-packages folder it can easily be enabled by adding a simple python statement to the user's vimrc file. Otherwise it can be added by doing a :source path/to/plugin/vim/powerline.vim in vimrc, but the other way of doing it works without specifying the full path as long as Powerline is installed somewhere in sys.path.
This commit is contained in:
parent
175fb1b58e
commit
f074c1fb29
|
@ -1,2 +1,3 @@
|
|||
recursive-include powerline *.json
|
||||
recursive-include plugin *.vim
|
||||
exclude powerline/tests/*.xml
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
import os
|
||||
import vim
|
||||
|
||||
vim.command('source ' + os.path.join(os.path.abspath(os.path.dirname(__file__)), 'powerline.vim'))
|
|
@ -1,5 +1,9 @@
|
|||
" Powerline vim example
|
||||
" Run with :source %
|
||||
" Powerline vim plugin
|
||||
"
|
||||
" If Powerline is installed in a Python search path, load the plugin by
|
||||
" adding the following line to your .vimrc:
|
||||
"
|
||||
" python import plugin.vim.load_vim_plugin
|
||||
|
||||
python import sys, vim, os
|
||||
python sys.path.append(vim.eval('expand("<sfile>:h:h:h")'))
|
||||
|
@ -22,14 +26,14 @@ endfunction
|
|||
function! s:UpdateAllWindows()
|
||||
for w in range(1, winnr('$'))
|
||||
" getwinvar() returns empty string for undefined variables.
|
||||
" Use has_key(getwinvar(w, ''), 'powerline') if you care about variable
|
||||
" being really defined (currently with w:powerline=='' it will throw
|
||||
" Use has_key(getwinvar(w, ''), 'powerline') if you care about variable
|
||||
" being really defined (currently with w:powerline=='' it will throw
|
||||
" E706: variable type mismatch).
|
||||
if getwinvar(w, 'powerline') is# ''
|
||||
call setwinvar(w, 'powerline', {})
|
||||
endif
|
||||
|
||||
call setwinvar(w, '&statusline', '%!Powerline('.w.')')
|
||||
call setwinvar(w, '&statusline', '%!Powerline('. w .')')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
@ -38,4 +42,3 @@ augroup Powerline
|
|||
autocmd BufEnter,BufWinEnter,WinEnter * let w:current = 1 | call s:UpdateAllWindows()
|
||||
autocmd BufLeave,BufWinLeave,WinLeave * let w:current = 0
|
||||
augroup END
|
||||
" vim: ft=vim noet
|
Loading…
Reference in New Issue