Commits

ZyX_I committed 8f81644

Made aurum://annotate actually populate a buffer, replaced auhidefunc.function() with &bufhidden=wipe

  • Participants
  • Parent commits d578b44

Comments (0)

Files changed (2)

File ftplugin/aurumannotate.vim

 "▶1 
 scriptencoding utf-8
+setlocal textwidth=0
+setlocal nolist nowrap
+setlocal concealcursor+=n conceallevel=2
+setlocal nonumber norelativenumber
+setlocal noswapfile
+setlocal nomodeline
 execute frawor#Setup('0.0', {'@aurum': '0.0',
             \            '@/mappings': '0.0',
-            \        '@/autocommands': '0.0',})
+            \        '@/autocommands': '0.0',
+            \               '@/table': '0.0',})
+"▶1 formatann :: repo, hex → String
+function s:F.formatann(repo, hex)
+    let cs=a:repo.changesets[a:hex]
+    let numlen=len(len(a:repo.cslist))
+    let description=matchstr(cs.description, '\v[^\r\n]+')
+    while s:_r.strdisplaywidth(description, numlen+1)>30
+        let description=substitute(description, '.$', '', '')
+    endwhile
+    if len(description)<len(cs.description)
+        let description.='...'
+    endif
+    return printf('%*u %s (by %s)', numlen, cs.rev, description, cs.user)
+endfunction
 "▶1 setup
 function s:F.setup()
     let bvar=s:_r.aurum.bufvars[bufnr('%')]
     let ann=bvar.repo.functions.annotate(bvar.repo, bvar.rev, bvar.file)
-    echom string(ann)
+    setlocal readonly
+    call map(ann, 's:F.formatann(bvar.repo, v:val)')
+    call setline('.', ann)
 endfunction
 let s:filetype=expand('<sfile>:t:r')
 call s:_f.augroup.add('AuAnnotate', [['FileType', s:filetype, 0, s:F.setup]])

File plugin/aurum.vim

     "▶2 Autocommands
     call FraworLoad('@/autocommands')
     let s:auefunc={}
-    let s:auhidefunc={}
     let s:aubwfunc={}
     call s:_f.augroup.add('Aurum', [['BufReadCmd', 'aurum://*',0, s:auefunc],
-                \                   ['BufHidden',  'aurum://*',1, s:auhidefunc],
                 \                   ['BufDelete',  'aurum://*',0, s:aubwfunc],
                 \                  ])
     "▲2
     if command is# 'glog'
         let repo=s:F.comm.getrepo(file)
         let s:bufvars[bufnr('%')]={'repo': repo}
-        setlocal filetype=aurumgraphlog buftype=nofile
+        setlocal buftype=nofile filetype=aurumgraphlog bufhidden=wipe
     elseif command is# 'file'
         let [repo, rev, file]=s:F.comm.reporevfilesplit(file)
         setlocal buftype=nofile
     elseif command is# 'annotate'
         let [repo, rev, file]=s:F.comm.reporevfilesplit(file)
         let s:bufvars[bufnr('%')]={'repo': repo, 'rev': rev, 'file': file}
-        setlocal filetype=aurumannotate buftype=nofile
-    endif
-endfunction
-"▶3 auhidefunc
-function s:auhidefunc.function()
-    let buf=+expand('<abuf>')
-    let file=substitute(expand('<amatch>'), '\V\^aurum://', '', '')
-    let command=matchstr(file, '\v^\w+')
-    if command is# 'glog'
-        let savedeventignore=&eventignore
-        set eventignore+=BufHidden
-        try
-            if bufnr('%')==buf
-                bnext
-            endif
-            execute 'bwipeout '.buf
-        finally
-            let &eventignore=savedeventignore
-        endtry
+        setlocal buftype=nofile filetype=aurumannotate bufhidden=wipe
     endif
 endfunction
 "▶3 aubwfunc