ZyX_I  committed c4fd840

@aurum/annotate, ftplugin/aurumannotate: Made them use cursorbind and open folds, locally set nowrap
syntax/aurumannotate: Added support for non-numeric revisions (they must not contain spaces though)

  • Participants
  • Parent commits a65a7be
  • Branches default

Comments (0)

Files changed (3)

File ftplugin/aurumannotate.vim

         if hasannbuf
+            let lnr=bvar.linenumbers[line('.')-1]
             call'silent edit', 'annotate', bvar.repo, hex, file)
-            setlocal scrollbind
+            execute lnr
+            setlocal scrollbind cursorbind
             let abuf=bufnr('%')
             let newbvar=s:_r.bufvars[abuf]
             execute bufwinnr(bvar.annbuf).'wincmd w'
         let'silent edit', 'file', bvar.repo, hex, file)
-        setlocal scrollbind
-        if hasannbuf
-            call s:_r.annotate.setannbuf(newbvar, abuf, bufnr('%'))
-        endif
         if exists('lnr')
             execute lnr
+        if hasannbuf
+            if exists('lnr')
+                call s:_r.annotate.foldopen()
+                setlocal scrollbind cursorbind nowrap
+            endif
+            call s:_r.annotate.setannbuf(newbvar, abuf, bufnr('%'))
+        endif
     "▶2 `update' action
     elseif a:action is# 'update'
         call s:_r.repo.update(bvar.repo, hex, v:count)

File plugin/aurum/annotate.vim

 let s:_augroups+=['AuAnnotateBW']
+"▶1 foldopen
+if has('folding')
+    function s:F.foldopen()
+        if &foldenable
+            try
+                " XXX Using silent! here because I am unable to catch E490 for 
+                " unknown reason
+                silent! %foldopen!
+            catch /^Vim:(foldopen):E490:/
+                " No folds found — ignore
+            endtry
+        endif
+    endfunction
+    function s:F.foldopen()
+        " Doing nothing if there is no folding support
+    endfunction
 "▶1 annfunc
 " TODO Investigate why wiping out annotate buffer causes consumption of next
 "      character under wine
             setlocal bufhidden=wipe
-    setlocal scrollbind
+    call s:F.foldopen()
+    setlocal scrollbind cursorbind nowrap
+    let lnr=line('.')
     let anwidth=min([42, winwidth(0)/2-1])
     call'silent leftabove '.anwidth.'vsplit', 'annotate', repo,
                 \ rev, file)
-    setlocal scrollbind
+    execute lnr
+    setlocal scrollbind cursorbind
     setlocal bufhidden=wipe
     let buf=bufnr('%')
     call s:F.setannbuf(s:_r.bufvars[buf], buf, annbuf)
             \ 'arguments': 2,
             \  'filetype': 'aurumannotate',})
 "▶1 Post resource
-call s:_f.postresource('annotate', {'setannbuf': s:F.setannbuf})
+call s:_f.postresource('annotate', {'setannbuf': s:F.setannbuf,
+            \                        'foldopen': s:F.foldopen,})
 call frawor#Lockvar(s:, '_r,_pluginloaded')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File syntax/aurumannotate.vim

-syn match auAnnRevision    /\v^\ *\d+\ / nextgroup=auAnnDescription
+syn match auAnnRevision    /\v^\ *\S+\ / nextgroup=auAnnDescription
 syn match auAnnDescription /\v.{31}/     nextgroup=auAnnDescNameSep contained
 syn match auAnnDescNameSep @\V / @       nextgroup=auAnnAuthor      contained
 syn match auAnnAuthor      /\v.*$/                                  contained