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

Allow vimfiles to work with native macOS vim diffopt #213

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Significant changes to vimfiles (newest changes first).
Changes marked with "BREAKING CHANGE" indicate an incompatible change that may
require adjustment of per-user settings.

2021-11-02
==========

- Fix diffopt errors when using native macOS vim, see
https://github.com/thoughtbot/dotfiles/issues/655

2021-10-19
==========

Expand Down
21 changes: 18 additions & 3 deletions vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,22 @@ set updatetime=1000
" Disallow octal numbers for increment/decrement (CTRL-a/CTRL-x).
set nrformats-=octal

" Perform vertically split diffs by default.
set diffopt+=vertical
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 v:version > 801 || (v:version == 801 && has('patch-8.1.0360'))
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.
Expand All @@ -997,6 +1009,9 @@ if v:version > 801 || (v:version == 801 && has('patch-8.1.0360'))
set diffopt+=algorithm:histogram
endif

" Perform vertically split diffs by default.
set diffopt+=vertical

" Unfortunately, do to some redirection that Vim uses underneath the hood, it
" can hide an error status of a command. This helps to preserve the error
" status so v:shell_error and the command can be tested for the success.
Expand Down