[PATCH] Use LLVM when the buffer isn't associated with a file.
Ahmed Charles
acharles at outlook.com
Sat Mar 8 22:07:40 PST 2014
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3019.1.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140308/426e91c4/attachment.bin>
More information about the cfe-commits
mailing list