From 20ae6f8ea0b7dbb5e1ea89bdc024b1bd6841dd45 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 18 Dec 2014 12:31:03 +0100 Subject: [plugins] added Linediff --- plugin/linediff.vim | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 plugin/linediff.vim (limited to 'plugin') diff --git a/plugin/linediff.vim b/plugin/linediff.vim new file mode 100644 index 0000000..f154d6d --- /dev/null +++ b/plugin/linediff.vim @@ -0,0 +1,48 @@ +if exists("g:loaded_linediff") || &cp + finish +endif + +let g:loaded_linediff = '0.1.1' " version number +let s:keepcpo = &cpo +set cpo&vim + +" Initialized lazily to avoid executing the autoload file before it's really +" needed. +function! s:Init() + if !exists('s:differ_one') + let s:differ_one = linediff#differ#New('linediff_one', 1) + let s:differ_two = linediff#differ#New('linediff_two', 2) + endif +endfunction + +command! -range Linediff call s:Linediff(, ) +function! s:Linediff(from, to) + call s:Init() + + if s:differ_one.IsBlank() + call s:differ_one.Init(a:from, a:to) + elseif s:differ_two.IsBlank() + call s:differ_two.Init(a:from, a:to) + + call s:PerformDiff(s:differ_one, s:differ_two) + else + call s:differ_one.Reset() + call s:differ_two.Reset() + + call s:Linediff(a:from, a:to) + endif +endfunction + +command! LinediffReset call s:LinediffReset() +function! s:LinediffReset() + call s:differ_one.Reset() + call s:differ_two.Reset() +endfunction + +function! s:PerformDiff(one, two) + call a:one.CreateDiffBuffer("tabedit") + call a:two.CreateDiffBuffer("rightbelow vsplit") + + let a:one.other_differ = a:two + let a:two.other_differ = a:one +endfunction -- cgit v1.2.3