-
Notifications
You must be signed in to change notification settings - Fork 107
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 support for cmake-format. #163
base: master
Are you sure you want to change the base?
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
f98a511
to
19eb49f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're able to run the vimdoc tool from http://github.com/google/vimdoc to generate help files from your comments, that would be helpful.
" Generate formatted output. | ||
let l:input = join(getline(1, line('$')), "\n") | ||
let l:result = maktaba#syscall#Create(l:cmd).WithStdin(l:input).Call() | ||
let l:formatted = split(l:result.stdout, "\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to use split
's keepempty argument here, split(STDOUT, "\n", 1)
, so you have consistent results if the first or last line is empty.
let l:formatted = split(l:result.stdout, "\n") | ||
|
||
" Overwrite buffer. | ||
call maktaba#buffer#Overwrite(1, line('$'), l:formatted[0:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the [0:]
slicing for? Should be a no-op except for making a copy of the list before passing it to Overwrite, which AFAIK isn't needed.
|
||
"" | ||
" The path to the cmake-format configuration file for cmake-format to use. | ||
" See https://cmake-format.readthedocs.io/en/latest/installation.html for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like actually https://cmake-format.readthedocs.io/en/latest/configuration.html has the details and installation.html doesn't say much about it.
" The path to the cmake-format configuration file for cmake-format to use. | ||
" See https://cmake-format.readthedocs.io/en/latest/installation.html for | ||
" details. | ||
call s:plugin.Flag('cmake_format_config', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flag is global, so it will be a single value used for every file you edit. Is that what you'd want?
By my reading of https://cmake-format.readthedocs.io/en/latest/configuration.html, you can pass multiple config files, and that's independent of the automatic detection of files like \.?cmake-format(.yaml|.json|.py)
that it finds on the path? Can you confirm if an explicit config overrides any automatic config detection and note that in the doc comments?
@antmusco I'd really like to have support for cmake-format, so if you could pick this up again, I'd be very grateful :) Please let me know if I can help! |
Signed-off-by: Ari Archer <[email protected]>
@morxa looks like this got abandoned. If you'd like to pick up the changes and send your own PR we can finish the review and try to get something merged. |
Includes
autoload/codefmt/cmakeformat.vim
which adds support forcmake-format
for formatting CMake files. Adds two additional flags,cmake_format_executable
, which defaults tocmake-format
, andcmake_format_config
, which defaults to the empty string (i.e. default formatter).Addresses issue #162