diff --git a/clang_format.py b/clang_format.py index d1539de..0d11cb8 100644 --- a/clang_format.py +++ b/clang_format.py @@ -186,6 +186,7 @@ def load_settings(): # We set these globals. global binary global style + global fallback_style global format_on_save global languages settings_global = sublime.load_settings(settings_file) @@ -194,6 +195,7 @@ def load_settings(): # Load settings, with defaults. binary = load('binary', default_binary) style = load('style', styles[0]) + fallback_style = load('fallback_style', None) format_on_save = load('format_on_save', False) languages = load('languages', ['C', 'C++', 'C++11', 'JavaScript']) @@ -231,6 +233,9 @@ def run(self, edit, whole_buffer=False): else: command = [binary, '-style', _style] + if fallback_style: + command.extend(['-fallback-style', fallback_style]) + regions = [] if whole_buffer: regions = [sublime.Region(0, self.view.size())] diff --git a/clang_format.sublime-settings b/clang_format.sublime-settings index cbfe217..147fe2d 100644 --- a/clang_format.sublime-settings +++ b/clang_format.sublime-settings @@ -17,6 +17,11 @@ "style": "Google", + // If style is set to 'File', but not '.clang-format' file is found, this style + // is used instead. Use 'none' to skip formatting in this case. + + "fallback_style": "Google", + // Setting this to true will run the formatter on every save. If you want to // only enable this for a given project, try checking out the package // "Project-Specific".