mirror of
https://github.com/powerline/powerline.git
synced 2025-07-24 22:36:01 +02:00
Fix linting of highlight groups
Currently checks for highlight group existence do not work. With this commit tests will fail due to #1136.
This commit is contained in:
parent
b22562b028
commit
3b56cf748b
@ -233,6 +233,7 @@ segment_spec = Spec(
|
|||||||
segments=sub_segments_spec,
|
segments=sub_segments_spec,
|
||||||
).func(check_full_segment_data)
|
).func(check_full_segment_data)
|
||||||
sub_segments_spec.optional().list(segment_spec)
|
sub_segments_spec.optional().list(segment_spec)
|
||||||
|
del sub_segments_spec
|
||||||
segments_spec = Spec().optional().list(segment_spec).copy
|
segments_spec = Spec().optional().list(segment_spec).copy
|
||||||
segdict_spec = Spec(
|
segdict_spec = Spec(
|
||||||
left=segments_spec().context_message('Error while loading segments from left side (key {key})'),
|
left=segments_spec().context_message('Error while loading segments from left side (key {key})'),
|
||||||
@ -546,6 +547,8 @@ def check(paths=None, debug=False, echoerr=echoerr, require_ext=None):
|
|||||||
econfigs.get('__main__'),
|
econfigs.get('__main__'),
|
||||||
ecconfigs,
|
ecconfigs,
|
||||||
)
|
)
|
||||||
|
if not (mconfigs[0] or mconfigs[2]):
|
||||||
|
continue
|
||||||
config = None
|
config = None
|
||||||
for mconfig in mconfigs:
|
for mconfig in mconfigs:
|
||||||
if not mconfig:
|
if not mconfig:
|
||||||
@ -554,7 +557,7 @@ def check(paths=None, debug=False, echoerr=echoerr, require_ext=None):
|
|||||||
config = mergedicts_copy(config, mconfig)
|
config = mergedicts_copy(config, mconfig)
|
||||||
else:
|
else:
|
||||||
config = mconfig
|
config = mconfig
|
||||||
colorscheme_configs[colorscheme] = config
|
colorscheme_configs[ext][colorscheme] = config
|
||||||
|
|
||||||
theme_configs = dict2(loaded_configs['themes'])
|
theme_configs = dict2(loaded_configs['themes'])
|
||||||
top_theme_configs = dict(loaded_configs['top_themes'])
|
top_theme_configs = dict(loaded_configs['top_themes'])
|
||||||
|
@ -499,26 +499,27 @@ def check_segment_function(function_name, data, context, echoerr):
|
|||||||
return True, False, False
|
return True, False, False
|
||||||
|
|
||||||
|
|
||||||
def hl_exists(hl_group, data, context, echoerr, allow_gradients=False):
|
def hl_group_in_colorscheme(hl_group, cconfig, allow_gradients, data, context, echoerr):
|
||||||
havemarks(hl_group)
|
havemarks(hl_group, cconfig)
|
||||||
ext = data['ext']
|
|
||||||
if ext not in data['colorscheme_configs']:
|
|
||||||
# No colorschemes. Error was already reported, no need to report it
|
|
||||||
# twice
|
|
||||||
return []
|
|
||||||
r = []
|
|
||||||
for colorscheme, cconfig in data['colorscheme_configs'][ext].items():
|
|
||||||
if hl_group not in cconfig.get('groups', {}):
|
if hl_group not in cconfig.get('groups', {}):
|
||||||
r.append(colorscheme)
|
return False
|
||||||
elif not allow_gradients or allow_gradients == 'force':
|
elif not allow_gradients or allow_gradients == 'force':
|
||||||
group_config = cconfig['groups'][hl_group]
|
group_config = cconfig['groups'][hl_group]
|
||||||
|
while isinstance(group_config, unicode):
|
||||||
|
try:
|
||||||
|
group_config = cconfig['groups'][group_config]
|
||||||
|
except KeyError:
|
||||||
|
# No such group. Error was already reported when checking
|
||||||
|
# colorschemes.
|
||||||
|
return True
|
||||||
havemarks(group_config)
|
havemarks(group_config)
|
||||||
hadgradient = False
|
hadgradient = False
|
||||||
for ckey in ('fg', 'bg'):
|
for ckey in ('fg', 'bg'):
|
||||||
color = group_config.get(ckey)
|
color = group_config.get(ckey)
|
||||||
if not color:
|
if not color:
|
||||||
# No color. Error was already reported.
|
# No color. Error was already reported when checking
|
||||||
continue
|
# colorschemes.
|
||||||
|
return True
|
||||||
havemarks(color)
|
havemarks(color)
|
||||||
# Gradients are only allowed for function segments. Note that
|
# Gradients are only allowed for function segments. Note that
|
||||||
# whether *either* color or gradient exists should have been
|
# whether *either* color or gradient exists should have been
|
||||||
@ -535,8 +536,7 @@ def hl_exists(hl_group, data, context, echoerr, allow_gradients=False):
|
|||||||
problem='group {0} is using gradient {1} instead of a color'.format(hl_group, color),
|
problem='group {0} is using gradient {1} instead of a color'.format(hl_group, color),
|
||||||
problem_mark=color.mark
|
problem_mark=color.mark
|
||||||
)
|
)
|
||||||
r.append(colorscheme)
|
return False
|
||||||
continue
|
|
||||||
if allow_gradients == 'force' and not hadgradient:
|
if allow_gradients == 'force' and not hadgradient:
|
||||||
echoerr(
|
echoerr(
|
||||||
context='Error while checking highlight group in theme (key {key})'.format(
|
context='Error while checking highlight group in theme (key {key})'.format(
|
||||||
@ -545,7 +545,26 @@ def hl_exists(hl_group, data, context, echoerr, allow_gradients=False):
|
|||||||
problem='group {0} should have at least one gradient color, but it has no'.format(hl_group),
|
problem='group {0} should have at least one gradient color, but it has no'.format(hl_group),
|
||||||
problem_mark=group_config.mark
|
problem_mark=group_config.mark
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def hl_exists(hl_group, data, context, echoerr, allow_gradients=False):
|
||||||
|
havemarks(hl_group)
|
||||||
|
ext = data['ext']
|
||||||
|
if ext not in data['colorscheme_configs']:
|
||||||
|
# No colorschemes. Error was already reported, no need to report it
|
||||||
|
# twice
|
||||||
|
return []
|
||||||
|
r = []
|
||||||
|
found = False
|
||||||
|
for colorscheme, cconfig in data['colorscheme_configs'][ext].items():
|
||||||
|
if hl_group_in_colorscheme(hl_group, cconfig, allow_gradients, data, context, echoerr):
|
||||||
|
found = True
|
||||||
|
else:
|
||||||
r.append(colorscheme)
|
r.append(colorscheme)
|
||||||
|
if not found:
|
||||||
|
pass
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user