Author: sammccall Date: Fri May 17 00:22:55 2019 New Revision: 360996 URL: http://llvm.org/viewvc/llvm-project?rev=360996&view=rev Log: [ClangFormat] Editor integrations inherit default style from clang-format binary
Summary: This allows downstream customizations to the default style to work without needing to also modify the editor integrations. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49719 Modified: cfe/trunk/tools/clang-format/clang-format-sublime.py cfe/trunk/tools/clang-format/clang-format-test.el cfe/trunk/tools/clang-format/clang-format.el cfe/trunk/tools/clang-format/clang-format.py Modified: cfe/trunk/tools/clang-format/clang-format-sublime.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-sublime.py?rev=360996&r1=360995&r2=360996&view=diff ============================================================================== --- cfe/trunk/tools/clang-format/clang-format-sublime.py (original) +++ cfe/trunk/tools/clang-format/clang-format-sublime.py Fri May 17 00:22:55 2019 @@ -24,7 +24,7 @@ binary = 'clang-format' # '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' +style = None class ClangFormatCommand(sublime_plugin.TextCommand): def run(self, edit): @@ -32,7 +32,9 @@ class ClangFormatCommand(sublime_plugin. if encoding == 'Undefined': encoding = 'utf-8' regions = [] - command = [binary, '-style', style] + command = [binary] + if style: + command.extend(['-style', style]) for region in self.view.sel(): regions.append(region) region_offset = min(region.a, region.b) Modified: cfe/trunk/tools/clang-format/clang-format-test.el URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-test.el?rev=360996&r1=360995&r2=360996&view=diff ============================================================================== --- cfe/trunk/tools/clang-format/clang-format-test.el (original) +++ cfe/trunk/tools/clang-format/clang-format-test.el Fri May 17 00:22:55 2019 @@ -58,7 +58,6 @@ (should-not display) (should (equal args '("-output-replacements-xml" "-assume-filename" "foo.cpp" - "-style" "file" ;; Beginning of buffer, no byte-order mark. "-offset" "0" ;; We have two lines with 2Ã2Â bytes for the umlauts, Modified: cfe/trunk/tools/clang-format/clang-format.el URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=360996&r1=360995&r2=360996&view=diff ============================================================================== --- cfe/trunk/tools/clang-format/clang-format.el (original) +++ cfe/trunk/tools/clang-format/clang-format.el Fri May 17 00:22:55 2019 @@ -45,14 +45,14 @@ A string containing the name or the full :type '(file :must-match t) :risky t) -(defcustom clang-format-style "file" +(defcustom clang-format-style nil "Style argument to pass to clang-format. By default clang-format will load the style configuration from a file named .clang-format located in one of the parent directories of the buffer." :group 'clang-format - :type 'string + :type '(choice (string) (const nil)) :safe #'stringp) (make-variable-buffer-local 'clang-format-style) @@ -160,7 +160,7 @@ uses the function `buffer-file-name'." ;; https://bugs.llvm.org/show_bug.cgi?id=34667 ,@(and assume-file-name (list "-assume-filename" assume-file-name)) - "-style" ,style + ,@(and style (list "-style" style)) "-offset" ,(number-to-string file-start) "-length" ,(number-to-string (- file-end file-start)) "-cursor" ,(number-to-string cursor)))) Modified: cfe/trunk/tools/clang-format/clang-format.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=360996&r1=360995&r2=360996&view=diff ============================================================================== --- cfe/trunk/tools/clang-format/clang-format.py (original) +++ cfe/trunk/tools/clang-format/clang-format.py Fri May 17 00:22:55 2019 @@ -44,7 +44,7 @@ if vim.eval('exists("g:clang_format_path # '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' +style = None fallback_style = None if vim.eval('exists("g:clang_format_fallback_style")') == "1": fallback_style = vim.eval('g:clang_format_fallback_style') @@ -91,9 +91,11 @@ def main(): startupinfo.wShowWindow = subprocess.SW_HIDE # Call formatter. - command = [binary, '-style', style, '-cursor', str(cursor)] + command = [binary, '-cursor', str(cursor)] if lines != ['-lines', 'all']: command += lines + if style: + command.extend(['-style', style]) if fallback_style: command.extend(['-fallback-style', fallback_style]) if vim.current.buffer.name: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits