-
Notifications
You must be signed in to change notification settings - Fork 124
Add git_diff behavior #118
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
Conversation
Cleanup the WIP, with clean code, extended documentation and descriptive commit. |
7144b53
to
fdcbd03
Compare
16291ae
to
e591d20
Compare
Hi @rhysd , thanks for your complete report. I think I addressed all of your comments. Do you have other concerns about this PR? |
Thanks for all your comments, my vimscript is actually a bit rusty. I think I answered all your comments, feel free if you have any other requirements. |
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 good. Thank you for several updates.
When you edit a file tracked in git, it may happend that some tracked lines are not well formatted. If you modify this file, and you auto_format the file, lines with bad indentation will be formatted too. You will be end up with unrelated changes in your commit. It may even appear that these 'bad formatted lines' were indented like this with a purpose. To mitigate this issue, this commit proposes to only format diff'ed lines in a file. It roughly relies on git diff, and on clang-format '-lines' option. clang_format#format function has been modified to accept a list of ranges. It adds three new user options: - g:clang_format#auto_format_git_diff to enable this new behavior - g:clang_format#auto_format_git_diff_fallback to decide what to do in case of untracked file - g:clang_format#git to define non standard git path or options
Hello,
I am deploying the use of clang format in my team, and I am doing some experiments to use this tool, especially in editors.
Your addon is really great, but format the whole file could easily lead to unrelated diffs in some commits. Your option InsertLeave is actually ingenous, but depending on user movement it still could lead to large part of file reformating.
An easy way would be to integrate or mimic the tool clang-format-diff, and only format git diff chunks in the edited file.
This PR is still a work in progress, especially around the git integration and the possible options (for example, what to do in case of untracked file, fallback to whole file format or not). And no tests have been wrtten for the moment.
But I think it fits right in your system.
What do you think about this feature?