ZyX_I avatar ZyX_I committed 8b7eb97

@%Powerline/**/aurum: Added aurum:options segment
Added ft_aurumannotate and ft_aurumstatus subthemes
@%aurum/annotate: Added support for ft_aurumannotate subtheme
@%aurum/edit: Added support for aurum:options segment

Ref #53

Comments (0)

Files changed (7)

autoload/Powerline/Functions/aurum.vim

-execute frawor#Setup('0.0', {'autoload/aurum': '0.1'})
+execute frawor#Setup('0.0', {'@%aurum': '0.1',
+            \        '@%aurum/bufvars': '0.0',})
 function Powerline#Functions#aurum#GetBranch(symbol)
     let r=aurum#branch()
     return empty(r) ? '' : a:symbol.' '.r
     return empty(repo) ? '' : fnamemodify(repo.path, ':~')
 endfunction
 let s:_functions+=['Powerline#Functions#aurum#GetRepoPath']
+function Powerline#Functions#aurum#GetOptions()
+    return get(get(s:_r.bufvars, bufnr('%'), {}), 'ploptions', '')
+endfunction
+let s:_functions+=['Powerline#Functions#aurum#GetOptions']

autoload/Powerline/Matches.vim

+if exists('s:loading')
+	finish
+endif
+let s:loading=1
+call extend(g:Powerline#Matches#matches, {
+	\'ft_aurumstatus':   Pl#Match#Add('getwinvar(a:window, "&ft")', '^aurumstatus$'  ),
+	\'ft_aurumannotate': Pl#Match#Add('getwinvar(a:window, "&ft")', '^aurumannotate$'),
+\})
+unlet s:loading
+" vim: ft=vim ts=4 sts=4 sw=4 noet

autoload/Powerline/Segments/aurum.vim

-let g:Powerline#Segments#aurum#segments = Pl#Segment#Init(['aurum',
+let s:seg=expand('<sfile>:t:r')
+let g:Powerline#Segments#{s:seg}#segments = Pl#Segment#Init([s:seg,
             \ 1,
             \ Pl#Segment#Create('branch',     '%{Powerline#Functions#aurum#GetBranch("$BRANCH")}'),
             \ Pl#Segment#Create('status',     '%{Powerline#Functions#aurum#GetStatus()}'),
             \ Pl#Segment#Create('repository', '%{Powerline#Functions#aurum#GetRepoPath()}'),
+            \ Pl#Segment#Create('options',    '%{Powerline#Functions#aurum#GetOptions()}'),
             \])

autoload/Powerline/Themes/parts/aurum.vim

+source <sfile>:h:h:h/Matches.vim
+let Powerline#Themes#parts#aurum#part=[
+    \Pl#Theme#Buffer('ft_aurumstatus'
+            \ , ['static_str.name', 'Status']
+            \ , Pl#Segment#Truncate()
+            \ , 'aurum:repository'
+            \ , Pl#Segment#Split()
+            \ , 'aurum:options'
+    \),
+    \
+    \Pl#Theme#Buffer('ft_aurumannotate'
+            \ , ['static_str.name', 'Ann']
+            \ , Pl#Segment#Truncate()
+            \ , Pl#Segment#Split()
+            \ , 'aurum:options'
+    \),
+\]

autoload/aurum/annotate.vim

 scriptencoding utf-8
 execute frawor#Setup('1.0', {'@%aurum/cmdutils': '4.0',
             \                 '@%aurum/bufvars': '0.0',
-            \                    '@%aurum/edit': '1.0',
+            \                    '@%aurum/edit': '1.4',
             \                          '@aurum': '1.0',
             \                     '@/resources': '0.0',
             \                         '@/table': '0.1',})
     call s:F.setannbuf(s:_r.bufvars[bufnr('%')], annbuf)
 endfunction
 let s:_augroups+=['AuAnnotateBW']
+"▶1 plstrgen
+function s:F.plstrgen(bvar)
+    let cs=a:bvar.repo.functions.getcs(a:bvar.repo, a:bvar.rev)
+    let r=[cs.rev]
+    if !empty(get(cs, 'tags'))
+        let r+=['['.join(cs.tags).']']
+    endif
+    if !empty(get(cs, 'bookmarks'))
+        let r+=['['.join(cs.bookmarks).']']
+    endif
+    if cs.branch isnot# 'default'
+        let r+=['('.(cs.branch).')']
+    endif
+    return join(r)
+endfunction
 "▶1 aurum://annotate
 call s:_f.newcommand({'function': s:F.setup,
             \        'arguments': 2,
-            \         'filetype': 'aurumannotate',})
+            \         'filetype': 'aurumannotate',
+            \         'plstrgen': s:F.plstrgen,})
 "▶1 Post resource
 call s:_f.postresource('annotate', {'setannbuf': s:F.setannbuf,
             \                        'foldopen': s:F.foldopen,})

autoload/aurum/edit.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('1.3', {'@/resources': '0.0',
+execute frawor#Setup('1.4', {'@/resources': '0.0',
             \                       '@/os': '0.0',
             \               '@%aurum/repo': '5.0',
             \          '@%aurum/lineutils': '0.0',
                         \                 | endif
         augroup END
     endif
+    if exists('g:Powerline_loaded')
+        if has_key(a:cdescr, 'plstrgen')
+            let bvar.ploptions=a:cdescr.plstrgen(bvar)
+        endif
+    endif
     file
 endfunction
 let s:_augroups+=['AurumNoInsert']
         let cdescr.mgroup=a:cdescr.mgroup
         let cdescr.mmap=a:plugdict.g._f.mapgroup.map
     endif
-    "▶2 Function keys: `write'
-    if has_key(a:cdescr, 'write')
-        if !exists('*a:cdescr.write')
-            call s:_f.throw('nfun', cname, a:plugdict.id, 'write')
+    "▶2 Function keys: “write”, “plstrgen”
+    for key in ['write', 'plstrgen']
+        if has_key(a:cdescr, key)
+            if !exists('*a:cdescr.'.key)
+                call s:_f.throw('nfun', cname, a:plugdict.id, key)
+            endif
+            let cdescr[key]=a:cdescr[key]
         endif
-        let cdescr.write=a:cdescr.write
-    endif
+    endfor
     "▲2
     let cdescr.id=cname
     let cdescr.plid=a:plugdict.id
     1.1: Added “requiresbvar” _f.newcommand option.
     1.2: Added “mgroup” _f.newcommand option and mrun resource.
     1.3: Added prevbuf function.
+    1.4: Added “plstrgen” _f.newcommand option
 @%aurum/vimdiff:
     0.1: Added full, untracked, onlymodified and files options to |:AuVimDiff|
     0.2: Added _r.vimdiff.full.
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.