[PATCH] Use LLVM when the buffer isn't associated with a file.
Nico Weber
thakis at chromium.org
Sun Mar 9 21:48:36 PDT 2014
Is this correct? Right now, when I open a new buffer in vim with its pwd
somewhere in my llvm or chromium checkout, clang-format will find the
.clang-format file that's somewhere in a parent directory of the pwd and
use the style from there. With this change, it looks like vim would always
use style llvm instead of the style selected in a .clang-format file for
unnamed buffers.
On Sat, Mar 8, 2014 at 10:07 PM, Ahmed Charles <acharles at outlook.com> wrote:
> Hi djasper,
>
> This allows formatting of buffers before saving them without warnings.
>
> http://llvm-reviews.chandlerc.com/D3019
>
> Files:
> tools/clang-format/clang-format.py
>
> Index: tools/clang-format/clang-format.py
> ===================================================================
> --- tools/clang-format/clang-format.py
> +++ tools/clang-format/clang-format.py
> @@ -29,8 +29,8 @@
> # Change this to format according to other formatting styles. See the
> output of
> # '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
> -# used.
> -style = 'file'
> +# used if the vim buffer is associated with a file, or LLVM otherwise.
> +style = None
>
> def main():
> # Get the current text.
> @@ -52,9 +52,15 @@
> startupinfo.wShowWindow = subprocess.SW_HIDE
>
> # Call formatter.
> - command = [binary, '-lines', lines, '-style', style, '-cursor',
> str(cursor)]
> + command = [binary, '-lines', lines, '-cursor', str(cursor)]
> if vim.current.buffer.name:
> command.extend(['-assume-filename', vim.current.buffer.name])
> + if style:
> + command.extend(['-style', style])
> + elif vim.current.buffer.name:
> + command.extend(['-style', 'file'])
> + else:
> + command.extend(['-style', 'LLVM'])
> p = subprocess.Popen(command,
> stdout=subprocess.PIPE, stderr=subprocess.PIPE,
> stdin=subprocess.PIPE, startupinfo=startupinfo)
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140309/734d23d9/attachment.html>
More information about the cfe-commits
mailing list