mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Allow setting g:powerline_pyeval to PowerlinePyeval for testing
This commit is contained in:
parent
257732bd82
commit
fdf21feae1
@ -2,6 +2,7 @@
|
|||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
@ -11,9 +12,6 @@ from powerline.bindings.vim import vim_get_func, vim_getvar
|
|||||||
from powerline import Powerline, FailedUnicode
|
from powerline import Powerline, FailedUnicode
|
||||||
from powerline.lib import mergedicts
|
from powerline.lib import mergedicts
|
||||||
|
|
||||||
if not hasattr(vim, 'bindeval'):
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def _override_from(config, override_varname):
|
def _override_from(config, override_varname):
|
||||||
try:
|
try:
|
||||||
@ -134,7 +132,7 @@ class VimPowerline(Powerline):
|
|||||||
set_pycmd(pycmd)
|
set_pycmd(pycmd)
|
||||||
|
|
||||||
# pyeval() and vim.bindeval were both introduced in one patch
|
# pyeval() and vim.bindeval were both introduced in one patch
|
||||||
if not hasattr(vim, 'bindeval') and can_replace_pyeval:
|
if (not hasattr(vim, 'bindeval') and can_replace_pyeval) or pyeval == 'PowerlinePyeval':
|
||||||
vim.command(('''
|
vim.command(('''
|
||||||
function! PowerlinePyeval(e)
|
function! PowerlinePyeval(e)
|
||||||
{pycmd} powerline.do_pyeval()
|
{pycmd} powerline.do_pyeval()
|
||||||
@ -245,12 +243,13 @@ class VimPowerline(Powerline):
|
|||||||
def new_window(self):
|
def new_window(self):
|
||||||
return self.render(*self.win_idx(None))
|
return self.render(*self.win_idx(None))
|
||||||
|
|
||||||
if not hasattr(vim, 'bindeval'):
|
|
||||||
# Method for PowerlinePyeval function. Is here to reduce the number of
|
|
||||||
# requirements to __main__ globals to just one powerline object
|
|
||||||
# (previously it required as well vim and json)
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def do_pyeval():
|
def do_pyeval():
|
||||||
|
'''Evaluate python string passed to PowerlinePyeval
|
||||||
|
|
||||||
|
Is here to reduce the number of requirements to __main__ globals to just
|
||||||
|
one powerline object (previously it required as well vim and json).
|
||||||
|
'''
|
||||||
import __main__
|
import __main__
|
||||||
vim.command('return ' + json.dumps(eval(vim.eval('a:e'), __main__.__dict__)))
|
vim.command('return ' + json.dumps(eval(vim.eval('a:e'), __main__.__dict__)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user