-
Notifications
You must be signed in to change notification settings - Fork 123
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
how to set a global .clang-format #95
Comments
Maybe you already have reached a solution to this. If you are using Another way is to have no specific What I am trying to describe is: #6 (comment) |
Another way is to use python to convert the let g:clang_format#detect_style_file = 1
let g:clang_format#enable_fallback_style = 0
func s:load_style()
let ret = {}
py3 << END
import json
import os
import re
import vim
import yaml
style_file = os.path.join(os.environ['HOME'], '.clang-format')
if os.path.isfile(style_file):
ret = vim.bindeval('ret')
with open(style_file, encoding='utf-8') as f:
styles = yaml.load(f.read(), Loader=yaml.CLoader)
ret['style'] = re.sub(r'\s{2,}', ' ', yaml.dump(styles, Dumper=yaml.CDumper, default_flow_style=True).replace('"', '""').replace('\n', ''))
END
let g:clang_format#extra_args = '-style="' . ret['style'] . '"'
endfunc
call s:load_style() This is for Windows. For Linux the quotes string should be quoted using |
This is an old topic, but this gives me error (
The style file works on the command line:
|
I am learning C/C++ so I have many folders to store my codes. Thus I wander if I can use one .clang-format file to format all my codes to avoid copying all my .clang-format into every folder.
The text was updated successfully, but these errors were encountered: