Update 2026-01-25 09:38 OpenBSD/amd64-t14
This commit is contained in:
@@ -8,74 +8,37 @@
|
||||
" | || || | | | | |__ | _ || _ || | | |
|
||||
" |____| |_||_| |_| |_____||_| |_||_| |_||_| |_|
|
||||
"
|
||||
" Last Change: 2024/02/14
|
||||
" Version: 9.7 (on or after patch-8.1.1418 and nvim-0.5.0)
|
||||
" Last Change: 2025/10/01
|
||||
" Version: 10.0 (on or after vim 9.0 and nvim 0.7.0)
|
||||
" Author: Rick Howe (Takumi Ohtani) <rdcxy754@ybb.ne.jp>
|
||||
" Copyright: (c) 2014-2024 Rick Howe
|
||||
" Copyright: (c) 2014-2025 Rick Howe
|
||||
" License: MIT
|
||||
|
||||
" This 9.x version requires:
|
||||
" * the OptionSet autocommand event triggered with the diff option
|
||||
" patch-8.0.0736 (nvim-0.3.0), patch-8.1.0414 (nvim-0.3.2)
|
||||
" * window ID argument in matchaddpos()/matchdelete()/getmatches()
|
||||
" patch-8.1.0218 (nvim-0.3.5), patch-8.1.1084 (nvim-0.4.4)
|
||||
" * the DiffUpdated autocommand event
|
||||
" patch-8.1.0397 (nvim-0.3.2)
|
||||
" * the win_execute() function
|
||||
" patch-8.1.1418 (nvim-0.5.0)
|
||||
if exists('g:loaded_diffchar') || !has('diff') || v:version < 800 ||
|
||||
\!exists('*win_execute')
|
||||
if exists('g:loaded_diffchar') || !has('diff') ||
|
||||
\(v:version < 900 && !has('nvim-0.7.0'))
|
||||
let g:loaded_diffchar = 0
|
||||
finish
|
||||
endif
|
||||
let g:loaded_diffchar = 9.7
|
||||
let g:loaded_diffchar = 10.0
|
||||
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpo&vim
|
||||
|
||||
" Options
|
||||
if !exists('g:DiffUnit') " a type of diff unit
|
||||
" let g:DiffUnit = 'Char' " any single character
|
||||
" let g:DiffUnit = 'Word1' " \w\+ word and any \W single character
|
||||
" let g:DiffUnit = 'Word2' " non-space and space words
|
||||
" let g:DiffUnit = 'Word3' " \< or \> character class boundaries
|
||||
" let g:DiffUnit = 'word' " see word
|
||||
" let g:DiffUnit = 'WORD' " see WORD
|
||||
" let g:DiffUnit = '[{del}]' " a list of unit delimiters (e.g. "[,:\t<>]")
|
||||
" let g:DiffUnit = '/{pat}/' " a pattern to split (e.g. '/.\{4}\zs/')
|
||||
endif
|
||||
|
||||
if !exists('g:DiffColors') " matching colors for changed units
|
||||
" let g:DiffColors = 0 " hl-DiffText only
|
||||
" let g:DiffColors = 1 " hl-DiffText + a few (3, 4, ...)
|
||||
" let g:DiffColors = 2 " hl-DiffText + several (7, 8, ...)
|
||||
" let g:DiffColors = 3 " hl-DiffText + many (11, 12, ...)
|
||||
" let g:DiffColors = 100 " all available highlight groups in random order
|
||||
" let g:DiffColors = [{hlg}] " a list of your favorite highlight groups
|
||||
endif
|
||||
|
||||
if !exists('g:DiffPairVisible') " a visibility of corresponding diff units
|
||||
" let g:DiffPairVisible = 0 " disable
|
||||
" let g:DiffPairVisible = 1 " highlight
|
||||
" let g:DiffPairVisible = 2 " highlight + echo
|
||||
" let g:DiffPairVisible = 3 " highlight + popup/floating at cursor pos
|
||||
" let g:DiffPairVisible = 4 " highlight + popup/floating at mouse pos
|
||||
endif
|
||||
|
||||
" Keymaps
|
||||
for [key, plg, cmd] in [
|
||||
\['[b', '<Plug>JumpDiffCharPrevStart',
|
||||
\':<C-U>call diffchar#JumpDiffChar(0, 0)'],
|
||||
\':<C-U>call diffchar#JumpDiffChar(0)'],
|
||||
\[']b', '<Plug>JumpDiffCharNextStart',
|
||||
\':<C-U>call diffchar#JumpDiffChar(1, 0)'],
|
||||
\':<C-U>call diffchar#JumpDiffChar(1)'],
|
||||
\['[e', '<Plug>JumpDiffCharPrevEnd',
|
||||
\':<C-U>call diffchar#JumpDiffChar(0, 1)'],
|
||||
\':<C-U>call diffchar#JumpDiffChar(2)'],
|
||||
\[']e', '<Plug>JumpDiffCharNextEnd',
|
||||
\':<C-U>call diffchar#JumpDiffChar(1, 1)'],
|
||||
\':<C-U>call diffchar#JumpDiffChar(3)'],
|
||||
\['<Leader>g', '<Plug>GetDiffCharPair',
|
||||
\':<C-U>call diffchar#CopyDiffCharPair(0)'],
|
||||
\['<Leader>p', '<Plug>PutDiffCharPair',
|
||||
\':<C-U>call diffchar#CopyDiffCharPair(1)']]
|
||||
if !hasmapto(plg, 'n') && empty(maparg(key, 'n'))
|
||||
if !hasmapto(plg, 'n') && maparg(key, 'n') =~ '^$\|_defaults.lua'
|
||||
if get(g:, 'DiffCharDoMapping', 1)
|
||||
call execute('nmap <silent> ' . key . ' ' . plg)
|
||||
endif
|
||||
@@ -91,6 +54,18 @@ call execute(g:DiffCharInitEvent)
|
||||
call execute('autocmd diffchar VimEnter * ++once
|
||||
\ if &diff | call diffchar#ToggleDiffModeSync(1) | endif')
|
||||
|
||||
" remove 'inline' from &diffopt if set only by default not to disable plugin
|
||||
let inl = 'inline'
|
||||
if &diffopt =~ inl
|
||||
let dip = split(&diffopt, ',')
|
||||
set diffopt&
|
||||
let def = split(&diffopt, ',')
|
||||
if match(filter(copy(dip), 'index(def, v:val) == -1'), inl) == -1
|
||||
call filter(dip, 'v:val !~ inl')
|
||||
endif
|
||||
let &diffopt = join(dip, ',')
|
||||
endif
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user