mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Use &encoding as powerline encoding in Vim
Among other benefits (i.e. correct fall back to ascii theme when Vim uses non-unicode encoding) this should also fix travis tests: apparently travis is not setting LANG or similar environment variables to some unicode locale, so tests are failing.
This commit is contained in:
parent
8f70811768
commit
9658e45eee
@ -225,7 +225,7 @@ def create_logger(common_config):
|
|||||||
return logger
|
return logger
|
||||||
|
|
||||||
|
|
||||||
def finish_common_config(common_config):
|
def finish_common_config(encoding, common_config):
|
||||||
'''Add default values to common config and expand ~ in paths
|
'''Add default values to common config and expand ~ in paths
|
||||||
|
|
||||||
:param dict common_config:
|
:param dict common_config:
|
||||||
@ -235,7 +235,7 @@ def finish_common_config(common_config):
|
|||||||
Copy of common configuration with all configuration keys and expanded
|
Copy of common configuration with all configuration keys and expanded
|
||||||
paths.
|
paths.
|
||||||
'''
|
'''
|
||||||
encoding = getpreferredencoding().lower()
|
encoding = encoding.lower()
|
||||||
if encoding.startswith('utf') or encoding.startswith('ucs'):
|
if encoding.startswith('utf') or encoding.startswith('ucs'):
|
||||||
default_top_theme = 'powerline'
|
default_top_theme = 'powerline'
|
||||||
else:
|
else:
|
||||||
@ -407,6 +407,12 @@ class Powerline(object):
|
|||||||
self.setup_kwargs = {}
|
self.setup_kwargs = {}
|
||||||
self.imported_modules = set()
|
self.imported_modules = set()
|
||||||
|
|
||||||
|
get_encoding = staticmethod(getpreferredencoding)
|
||||||
|
'''Get encoding used by the current application
|
||||||
|
|
||||||
|
Usually returns encoding of the current locale.
|
||||||
|
'''
|
||||||
|
|
||||||
def create_renderer(self, load_main=False, load_colors=False, load_colorscheme=False, load_theme=False):
|
def create_renderer(self, load_main=False, load_colors=False, load_colorscheme=False, load_theme=False):
|
||||||
'''(Re)create renderer object. Can be used after Powerline object was
|
'''(Re)create renderer object. Can be used after Powerline object was
|
||||||
successfully initialized. If any of the below parameters except
|
successfully initialized. If any of the below parameters except
|
||||||
@ -431,7 +437,7 @@ class Powerline(object):
|
|||||||
if load_main:
|
if load_main:
|
||||||
self._purge_configs('main')
|
self._purge_configs('main')
|
||||||
config = self.load_main_config()
|
config = self.load_main_config()
|
||||||
self.common_config = finish_common_config(config['common'])
|
self.common_config = finish_common_config(self.get_encoding(), config['common'])
|
||||||
if self.common_config != self.prev_common_config:
|
if self.common_config != self.prev_common_config:
|
||||||
common_config_differs = True
|
common_config_differs = True
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from locale import getpreferredencoding
|
||||||
|
|
||||||
from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY
|
from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY
|
||||||
from powerline.lib.config import ConfigLoader
|
from powerline.lib.config import ConfigLoader
|
||||||
from powerline import generate_config_finder, load_config, create_logger, PowerlineLogger, finish_common_config
|
from powerline import generate_config_finder, load_config, create_logger, PowerlineLogger, finish_common_config
|
||||||
@ -83,7 +85,7 @@ def get_main_config(args):
|
|||||||
|
|
||||||
def create_powerline_logger(args):
|
def create_powerline_logger(args):
|
||||||
config = get_main_config(args)
|
config = get_main_config(args)
|
||||||
common_config = finish_common_config(config['common'])
|
common_config = finish_common_config(getpreferredencoding(), config['common'])
|
||||||
logger = create_logger(common_config)
|
logger = create_logger(common_config)
|
||||||
return PowerlineLogger(use_daemon_threads=True, logger=logger, ext='config')
|
return PowerlineLogger(use_daemon_threads=True, logger=logger, ext='config')
|
||||||
|
|
||||||
|
@ -3,11 +3,14 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from itertools import count
|
||||||
|
|
||||||
|
import vim
|
||||||
|
|
||||||
from powerline.bindings.vim import vim_get_func, vim_getvar
|
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
|
||||||
import vim
|
|
||||||
from itertools import count
|
|
||||||
|
|
||||||
if not hasattr(vim, 'bindeval'):
|
if not hasattr(vim, 'bindeval'):
|
||||||
import json
|
import json
|
||||||
@ -71,6 +74,10 @@ class VimPowerline(Powerline):
|
|||||||
self.setup_kwargs.setdefault('_local_themes', []).append((key, config))
|
self.setup_kwargs.setdefault('_local_themes', []).append((key, config))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_encoding():
|
||||||
|
return vim.eval('&encoding')
|
||||||
|
|
||||||
def load_main_config(self):
|
def load_main_config(self):
|
||||||
return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides')
|
return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides')
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/vim -S
|
#!/usr/bin/vim -S
|
||||||
|
set encoding=utf-8
|
||||||
let g:powerline_config_path = expand('<sfile>:p:h:h') . '/powerline/config_files'
|
let g:powerline_config_path = expand('<sfile>:p:h:h') . '/powerline/config_files'
|
||||||
let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}}
|
let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}}
|
||||||
let g:powerline_theme_overrides__default = {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}}
|
let g:powerline_theme_overrides__default = {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/vim -S
|
#!/usr/bin/vim -S
|
||||||
set nocompatible
|
set encoding=utf-8
|
||||||
tabedit abc
|
tabedit abc
|
||||||
tabedit def
|
tabedit def
|
||||||
try
|
try
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/vim -S
|
#!/usr/bin/vim -S
|
||||||
|
set encoding=utf-8
|
||||||
source powerline/bindings/vim/plugin/powerline.vim
|
source powerline/bindings/vim/plugin/powerline.vim
|
||||||
edit abc
|
edit abc
|
||||||
tabedit def
|
tabedit def
|
||||||
|
@ -9,6 +9,7 @@ options = {
|
|||||||
'paste': 0,
|
'paste': 0,
|
||||||
'ambiwidth': 'single',
|
'ambiwidth': 'single',
|
||||||
'columns': 80,
|
'columns': 80,
|
||||||
|
'encoding': 'utf-8',
|
||||||
}
|
}
|
||||||
_last_bufnr = 0
|
_last_bufnr = 0
|
||||||
_highlights = {}
|
_highlights = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user