[cfe-dev] Slightly improved clang-format vim integration

Tobias Grosser tobias at grosser.es
Tue Sep 17 06:48:14 PDT 2013


On 09/17/2013 03:12 PM, Steffen Prohaska wrote:
> On Sep 17, 2013, at 10:10 AM, Daniel Jasper <djasper at google.com> wrote:
>
>> So, remind me again, because it seems to have escaped from this discussion: Why is it a benefit to load this as a python module?
>
> My main reason was that with Python runtimepath handling (vim >= 7.3.1163), I think it's easier to install and use as a module.
>
>
>> I think the capabilities to configure the plugin with global variables is obvious, but it seems unrelated to this being loaded as a module.
>
> True, and maybe it's not worth breaking compatibility.
>
>
>> + #     let g:clang_format_style = '{ BasedOnStyle: llvm, IndentWitdh: 4 }'
>> IndentWidth..
>
> Thanks.  Fixed.
>
>
>> +  # Use g:clang_format_binary or default 'clang-format'.
>> +  binary = vim.eval(
>> +    'exists("g:clang_format_binary") ? g:clang_format_binary : "clang-format"')
>>
>> I think we should still default to a constant that is defined higher up in the file, possibly within the introductory paragraph. Yes, it can be configured setting the global options, but in some cases, it might be easier to change an easy to find constant in this file. Same for clang_format_style.
>
> How about the attached revision v4?  It's backward compatible.  The defaults for binary and style are specified after the imports.  The binary can be specified in a global vim var.  The style can be specified as an explicit function arg, a buffer-local vim var (useful for autocmd), or a global vim var.  The install instructions are kept simple.  Using a Python module is only mentioned later as an alternative.

This one works for me and also does not trigger require the user to 
perform a python include in the .vimrc file. So for me this patch works.

Thanks Steffen!

Tobias




More information about the cfe-dev mailing list