-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow vimfiles to work with native macOS vim diffopt #213
Conversation
vimrc
Outdated
if has('mac') && $VIM == '/usr/share/vim' | ||
" Built-in vim doesn't support diffopt internal options | ||
" ref: https://github.com/thoughtbot/dotfiles/issues/655#issuecomment-605019271 | ||
set diffopt-=internal |
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.
Must come before setting +vertical or throws errors.
The linked article I saw that the line |
Those other two options also throw errors sadly:
I was pretty sure I tested that, but thanks for keeping me honest :) |
Was this with the bogus set diffopt=indent-heuristic
set diffopt=algorithm:histogram |
Here's the full list supported according to
|
No I made sure
|
That's a helpful list. Compared to my build of Vim on ubuntu, these are missing in the Mac list:
I don't see any of these options being used in the rest of Vimfiles anywhere (plugins or whatnot). My other question has to do with the meaning of this test: if has('mac') && $VIM == '/usr/share/vim' Is this trying to detect a build of Vim that ships with OS X (vs. a self-compiled one that presumably supports if has("mac") || has("macunix") I'm not clear on the distinction between Also, I'm curious how the following test passes on Mac's Vim without the internal diff feature being present: if v:version > 801 || (v:version == 801 && has('patch-8.1.0360')) Did Apple patch out the feature? It doesn't appear to be configurable in the Vim source ( If we can't rely on the |
Maybe something like this would detect the ability to use function! HasInternalDiff()
let parts = split(&diffopt, ',')
let using_internal = (count(parts, 'internal') == 1)
try
set diffopt+=internal
if !using_internal
set diffopt-=internal
endif
return 1
catch /E474:/
set diffopt-=internal
return 0
endtry
endfunction
if HasInternalDiff()
" Use the new internal diff feature with options:
" - indent-heuristic: uses indentation to improve diffs.
" - algorithm:histogram: an improved patience algorithm as used in Git.
set diffopt+=internal
set diffopt+=indent-heuristic
set diffopt+=algorithm:histogram
endif
set diffopt+=vertical |
Yeah, admittedly, I didn't like that In any case, I like your suggestion better, so let me give that a shot now and report back. As an aside, I think Apple patched it out due to GPL issues: agude/dotfiles#2 (comment). But that's just trusting some random person on the internets opinion. It somewhat makes sense, but annoying to say the least... |
Or any other vim build that doesnt support "diffopt=internal"
5fe064f
to
f126c5f
Compare
Ok that worked and was a much cleaner approach. I just force pushed a change adopting it. Tested on MacOS Catalina and Big Sur, and on my Ubuntu 20.04 machine. |
Sold; thanks for tracking this down :-) |
Thanks Mike! |
FWIW, this bug just bit me on Monterey 12.3.1 as well, and it's still the same. |
As-in, it is still broken? |
Still broken, yep. GPL most likely reason that makes sense, and why we'll never see a fix. vim from source it is, then. |
Hmm, I wonder why this was working fine for me. I've been working on Linux mostly lately, I'll check my Mac this weekend and see what happens. I think the fix @drmikehenry suggested and merged worked around the limitation. |
You can work around it sort-of with that code yes, and you can get 'vanilla' diff, but you'll never be able to do |
@craigmac I'm not sure I understand the complaint. This wasn't about trying to make something that isn't supported work. It was about gracefully adding in bits that would work. In this case, the |
You are correct. The issue is that macOS shipped Vim has the necessary patch level and feature that is supposed to support the new xdiff backed options algorithm:patience and indent-heuristic, yet it those appear in the diffopt we get errors. I filed an issue with Vim. |
Tested on MacOS BigSur and Catalina. Also, tested on Ubuntu 20.04 with custom built (
buildtool
) vim: