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 support for cmake-format. #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

antmusco
Copy link

@antmusco antmusco commented Sep 13, 2020

Includes autoload/codefmt/cmakeformat.vim which adds support for cmake-format for formatting CMake files. Adds two additional flags, cmake_format_executable, which defaults to cmake-format, and cmake_format_config, which defaults to the empty string (i.e. default formatter).

Addresses issue #162

@google-cla
Copy link

google-cla bot commented Sep 13, 2020

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.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Sep 13, 2020
@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 13, 2020
Copy link
Contributor

@dbarnett dbarnett left a 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")
Copy link
Contributor

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:])
Copy link
Contributor

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
Copy link
Contributor

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.

Comment on lines +75 to +78
" 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', '')
Copy link
Contributor

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?

@morxa
Copy link

morxa commented Jun 28, 2021

@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!

TruncatedDinoSour pushed a commit to TruncatedDinoSour/vim-codefmt that referenced this pull request Jan 15, 2022
Signed-off-by: Ari Archer <[email protected]>
@dbarnett
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants