Commits

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)

Comments (0)

Files changed (3)

ftplugin/aurumannotate.vim

             endif
         endif
         if hasannbuf
+            let lnr=bvar.linenumbers[line('.')-1]
             call s:_r.run('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'
         endif
         let existed=s:_r.run('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
         endif
+        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)

plugin/aurum/annotate.vim

     endif
 endfunction
 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
+else
+    function s:F.foldopen()
+        " Doing nothing if there is no folding support
+    endfunction
+endif
 "▶1 annfunc
 " TODO Investigate why wiping out annotate buffer causes consumption of next
 "      character under wine
             setlocal bufhidden=wipe
         endif
     endif
-    setlocal scrollbind
+    call s:F.foldopen()
+    setlocal scrollbind cursorbind nowrap
+    let lnr=line('.')
     let anwidth=min([42, winwidth(0)/2-1])
     call s:_r.run('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,})
 "▶1
 call frawor#Lockvar(s:, '_r,_pluginloaded')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

syntax/aurumannotate.vim

     finish
 endif
 
-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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.