Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to pass --fallback-style to clang-format #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'])

Expand Down Expand Up @@ -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())]
Expand Down
5 changes: 5 additions & 0 deletions clang_format.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down