1. ZyX_I
  2. aurum

Commits

ZyX_I  committed 9cb8ed0

aurum: Added :AuVimDiff command

  • Participants
  • Parent commits c9f2d97
  • Branches default

Comments (0)

Files changed (1)

File plugin/aurum.vim

View file
                 \                                'complete': s:glogcomp})
     let s:annfunc={}
     call s:_f.command.add('AuAnnotate', s:annfunc, {'nargs': '*'})
+    let s:difffunc={}
+    call s:_f.command.add('AuVimDiff', s:difffunc, {'nargs': '*'})
     "▶2 Autocommands
     call FraworLoad('@/autocommands')
     let s:auefunc={}
     elseif command is# 'file'
         let [repo, rev, file]=s:F.comm.repotuplesplit(tail, 2)
         setlocal buftype=nofile
-        call setline('.', repo.functions.readfile(repo, rev, file))
+        let fcontents=repo.functions.readfile(repo, rev, file)
+        if empty(fcontents[-1])
+            call remove(fcontents, -1)
+        else
+            setlocal binary noendofline
+        endif
+        call setline('.', fcontents)
     "▶4 annotate command
     elseif command is# 'annotate'
         let [repo, rev, file]=s:F.comm.repotuplesplit(tail, 2)
     let repo=s:F.comm.getrepo('')
     let file=bufname('%')
     let file=s:_r.os.path.relpath(file, repo.path)
+    let file=join(s:_r.os.path.split(file)[1:], '/')
     setlocal scrollbind
     execute 'leftabove 42vsplit '.fnameescape(
-                \'aurum://annotate:'.escape(repo.path, '\:').
-                \                ':.:'.file)
+                \'aurum://annotate::.:'.file)
     setlocal scrollbind
 endfunction
+"▶3 difffunc
+function s:difffunc.function(...)
+    let repo=s:F.comm.getrepo('')
+    let file=bufname('%')
+    let file=s:_r.os.path.relpath(file, repo.path)
+    let file=join(s:_r.os.path.split(file)[1:], '/')
+    let rev1=repo.functions.getrevhex(repo, get(a:000, 0, '.'))
+    let rev2=a:0>1?repo.functions.getrevhex(repo, a:2):0
+    if rev2 is 0
+        execute 'diffsplit '.fnameescape('aurum://file::'.rev1.':'.file)
+    else
+        execute 'edit '.fnameescape('aurum://file::'.rev1.':'.file)
+        execute 'diffsplit '.fnameescape('aurum://file::'.rev2.':'.file)
+    endif
+endfunction
 "▶3 aubwfunc
 function s:aubwfunc.function()
     let buf=+expand('<abuf>')