Respect segment.py highlight group handling in powerline-lint
Either `highlight_group` or `name` key is enough to determine highlight group for non-function segments, but powerline-lint requires `highlight_group`.
This commit is contained in:
parent
c7946cda3e
commit
4dd9c5196e
|
@ -527,10 +527,11 @@ type_keys = {
|
||||||
}
|
}
|
||||||
required_keys = {
|
required_keys = {
|
||||||
'function': set(),
|
'function': set(),
|
||||||
'string': set(('contents', 'highlight_group')),
|
'string': set(('contents',)),
|
||||||
'filler': set(('highlight_group',)),
|
'filler': set(),
|
||||||
}
|
}
|
||||||
function_keys = set(('args', 'module'))
|
function_keys = set(('args', 'module'))
|
||||||
|
highlight_keys = set(('highlight_group', 'name'))
|
||||||
|
|
||||||
|
|
||||||
def check_key_compatibility(segment, data, context, echoerr):
|
def check_key_compatibility(segment, data, context, echoerr):
|
||||||
|
@ -542,6 +543,8 @@ def check_key_compatibility(segment, data, context, echoerr):
|
||||||
problem_mark=segment_type.mark)
|
problem_mark=segment_type.mark)
|
||||||
return False, False, True
|
return False, False, True
|
||||||
|
|
||||||
|
hadproblem = False
|
||||||
|
|
||||||
keys = set(segment)
|
keys = set(segment)
|
||||||
if not ((keys - generic_keys) < type_keys[segment_type]):
|
if not ((keys - generic_keys) < type_keys[segment_type]):
|
||||||
unknown_keys = keys - generic_keys - type_keys[segment_type]
|
unknown_keys = keys - generic_keys - type_keys[segment_type]
|
||||||
|
@ -550,7 +553,7 @@ def check_key_compatibility(segment, data, context, echoerr):
|
||||||
problem='found keys not used with the current segment type: {0}'.format(
|
problem='found keys not used with the current segment type: {0}'.format(
|
||||||
', '.join((unicode(key) for key in unknown_keys))),
|
', '.join((unicode(key) for key in unknown_keys))),
|
||||||
problem_mark=list(unknown_keys)[0].mark)
|
problem_mark=list(unknown_keys)[0].mark)
|
||||||
return True, False, True
|
hadproblem = True
|
||||||
|
|
||||||
if not (keys > required_keys[segment_type]):
|
if not (keys > required_keys[segment_type]):
|
||||||
missing_keys = required_keys[segment_type] - keys
|
missing_keys = required_keys[segment_type] - keys
|
||||||
|
@ -558,9 +561,15 @@ def check_key_compatibility(segment, data, context, echoerr):
|
||||||
context_mark=context[-1][1].mark,
|
context_mark=context[-1][1].mark,
|
||||||
problem='found missing required keys: {0}'.format(
|
problem='found missing required keys: {0}'.format(
|
||||||
', '.join((unicode(key) for key in missing_keys))))
|
', '.join((unicode(key) for key in missing_keys))))
|
||||||
return True, False, True
|
hadproblem = True
|
||||||
|
|
||||||
return True, False, False
|
if not (segment_type == 'function' or (keys & highlight_keys)):
|
||||||
|
echoerr(context='Error while checking segments (key {key})'.format(key=context_key(context)),
|
||||||
|
context_mark=context[-1][1].mark,
|
||||||
|
problem='found missing keys required to determine highlight group. Either highlight_group or name key must be present')
|
||||||
|
hadproblem = True
|
||||||
|
|
||||||
|
return True, False, hadproblem
|
||||||
|
|
||||||
|
|
||||||
def check_segment_module(module, data, context, echoerr):
|
def check_segment_module(module, data, context, echoerr):
|
||||||
|
|
Loading…
Reference in New Issue