vim: fix clang-format script

This commit is contained in:
Mathieu Maret 2020-11-17 11:48:32 +01:00
parent e623aa6e12
commit d4304e93d0

View File

@ -44,7 +44,6 @@ if vim.eval('exists("g:clang_format_path")') == "1":
# 'clang-format --help' for a list of supported styles. The default looks for # 'clang-format --help' for a list of supported styles. The default looks for
# a '.clang-format' or '_clang-format' file to indicate the style that should be # a '.clang-format' or '_clang-format' file to indicate the style that should be
# used. # used.
style = 'file'
fallback_style = None fallback_style = None
if vim.eval('exists("g:clang_format_fallback_style")') == "1": if vim.eval('exists("g:clang_format_fallback_style")') == "1":
fallback_style = vim.eval('g:clang_format_fallback_style') fallback_style = vim.eval('g:clang_format_fallback_style')
@ -55,6 +54,7 @@ def get_buffer(encoding):
return [ line.decode(encoding) for line in vim.current.buffer ] return [ line.decode(encoding) for line in vim.current.buffer ]
def main(): def main():
style = 'file'
# Get the current text. # Get the current text.
encoding = vim.eval("&encoding") encoding = vim.eval("&encoding")
buf = get_buffer(encoding) buf = get_buffer(encoding)
@ -121,7 +121,7 @@ def main():
lines = lines[1:] lines = lines[1:]
sequence = difflib.SequenceMatcher(None, buf, lines) sequence = difflib.SequenceMatcher(None, buf, lines)
for op in reversed(sequence.get_opcodes()): for op in reversed(sequence.get_opcodes()):
if op[0] is not 'equal': if op[0] != 'equal':
vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]] vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
if output.get('IncompleteFormat'): if output.get('IncompleteFormat'):
print('clang-format: incomplete (syntax errors)') print('clang-format: incomplete (syntax errors)')