1. ZyX_I
  2. aurum

Commits

ZyX_I  committed 4a61e94

Added some mappings to aurum://status buffer
Added options to :AuStatus
Some fixes

  • Participants
  • Parent commits 34c56aa
  • Branches default

Comments (0)

Files changed (4)

File ftplugin/aurumannotate.vim

View file
  • Ignore whitespace
 setlocal nonumber norelativenumber
 setlocal noswapfile
 setlocal nomodeline
-if exists('s:_pluginloaded')
+if exists('s:_pluginloaded') && empty(getline('.'))
     call s:F.setup()
 endif
 execute frawor#Setup('0.0', {'@aurum': '0.0',
             \     'Open': {'lhs':  'o',   'rhs': s:F.getrhs('open'         )},
             \}, {'silent': 1})
 "▶1
-call frawor#Lockvar(s:, '')
+call frawor#Lockvar(s:, '_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File ftplugin/aurumgraphlog.vim

View file
  • Ignore whitespace
 setlocal nonumber norelativenumber
 setlocal noswapfile
 setlocal nomodeline
-if exists('s:_pluginloaded')
+if exists('s:_pluginloaded') && empty(getline('.'))
     call s:F.setup()
 endif
 execute frawor#Setup('0.0', {'@aurum': '0.0',

File ftplugin/aurumstatus.vim

View file
  • Ignore whitespace
 setlocal nolist nowrap
 setlocal noswapfile
 setlocal nomodeline
-if exists('s:_pluginloaded')
+if exists('s:_pluginloaded') && empty(getline('.'))
     call s:F.setup()
 endif
 execute frawor#Setup('0.0', {'@aurum': '0.0',
             \            '@/mappings': '0.0',
             \        '@/autocommands': '0.0',
-            \               '@/table': '0.0',})
+            \                  '@/os': '0.0',})
 "▶1 setup
 let s:statchars={
             \ 'deleted': '!',
             \ 'unknown': '?',
         \}
+let s:defshow=['modified', 'added', 'removed', 'deleted', 'unknown', 'ignored']
 function s:F.setup()
     let bvar=s:_r.aurum.bufvars[bufnr('%')]
-    let status=bvar.repo.functions.status(bvar.repo, bvar.rev1, bvar.rev2)
-    for [type, files] in items(status)
+    let status=bvar.repo.functions.status(bvar.repo, get(bvar.opts, 'rev1', 0),
+                \                                    get(bvar.opts, 'rev2', 0))
+    let bvar.types=[]
+    let show=get(bvar.opts, 'show', s:defshow)
+    for [type, files] in filter(items(status), 'index(show, v:val[0])!=-1')
         let char=has_key(s:statchars, type)? s:statchars[type]: toupper(type[0])
-        call append('$', map(copy(files), 'char." ".v:val'))
+        for file in files
+            let ignore=0
+            if has_key(bvar.opts, 'files')
+                let ignore=1
+                for pattern in bvar.opts.files
+                    if file=~#pattern
+                        let ignore=0
+                        break
+                    endif
+                endfor
+            endif
+            if ignore
+                continue
+            endif
+            call append('$', char.' '.file)
+            let bvar.types+=[type]
+        endfor
     endfor
-    1 delete _
+    if empty(bvar.types)
+        call append('$', 'No changes found')
+    endif
+    silent 1 delete _
     setlocal readonly nomodifiable
     augroup AuStatusNoInsert
         autocmd InsertEnter <buffer> :call feedkeys("\e", 'n')
 endfunction
 let s:_augroups+=['AuStatusNoInsert']
 call s:F.setup()
+"▶1 runmap
+let s:noacttypes{
+            \   'open': ['deleted'],
+            \'revopen': ['added', 'ignored'],
+            \   'diff': ['deleted', 'removed', 'added', 'ignored', 'unknown'],
+        \}
+let s:noacttypes.vimdiff=s:noacttypes.diff
+function s:F.runmap(action)
+    let bvar=s:_r.aurum.bufvars[bufnr('%')]
+    if empty(bvar.types)
+        return ''
+    endif
+    let rev1=get(bvar.opts, 'rev1')
+    let rev2=get(bvar.opts, 'rev2')
+    if rev1 is 0
+        let rev1=''
+    endif
+    if rev2 is 0
+        let rev2=''
+    endif
+    if empty(rev1) && empty(rev2)
+        let rev1='.'
+    endif
+    let file=getline('.')[2:]
+    let epath=escape(bvar.repo.path, ':\')
+    if index(s:noacttypes[a:action], bvar.types[line('.')-1])!=-1
+        return ''
+    endif
+    if a:action is# 'open'
+        return ':edit '.fnameescape(s:_r.os.path.join(bvar.repo.path,file))."\n"
+    elseif a:action is# 'revopen'
+        return ':e '.fnameescape('aurum://file:'.epath.':'.rev1.':'.file)."\n"
+    elseif a:action is# 'diff'
+        return ':edit '.fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.':'.
+                    \               escape(file, '\;:')."\n")
+    elseif a:action is# 'vimdiff'
+        if empty(rev2)
+            let file2=fnameescape(s:_r.os.path.join(bvar.repo.path, file))
+        else
+            let file2=fnameescape('aurum://file:'.epath.':'.rev2.':'.file)
+        endif
+        return ':edit '.fnameescape('aurum://file:'.epath.':'.rev1.':'.file).
+                    \"\n:diffsplit ".file2."\n"
+    endif
+endfunction
+"▶1 AuStatus mapping group
+call s:_f.mapgroup.add('AuStatus', {
+            \  'Open': {'lhs': '<CR>', 'rhs': [   'open']},
+            \ 'ROpen': {'lhs': 'o',    'rhs': ['revopen']},
+            \  'Diff': {'lhs': 'd',    'rhs': [   'diff']},
+            \ 'Vdiff': {'lhs': 'D',    'rhs': ['vimdiff']},
+            \}, {'func': s:F.runmap})
 "▶1
-call frawor#Lockvar(s:, '')
+call frawor#Lockvar(s:, '_r')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File plugin/aurum.vim

View file
  • Ignore whitespace
     let s:difffunc={}
     call s:_f.command.add('AuVimDiff', s:difffunc, {'nargs': '*'})
     let s:statfunc={}
-    call s:_f.command.add('AuStatus', s:statfunc, {'nargs': '*'})
+    let s:statcomp=[]
+    call s:_f.command.add('AuStatus', s:statfunc, {'nargs': '*',
+                \                                  'complete': s:statcomp})
     "▶2 Autocommands
     call FraworLoad('@/autocommands')
     let s:auefunc={}
                     \       'files': filelist,}
         setlocal filetype=diff
         call repo.functions.difftobuffer(repo, buf, rev1, rev2, filelist, opts)
-    "▶4 status command (repo:rev1:rev2:files)
+    "▶4 status command (repo:opts)
     elseif command is# 'status'
-        let [repo, rev1, rev2, files]=s:F.comm.repotuplesplit(tail, 3)
-        if empty(rev1)
-            let rev1=0
+        let [repo, opts]=s:F.comm.repotupleoptssplit(tail, 0)
+        let buf=bufnr('%')
+        if has_key(opts, 'files')
+            let opts.files=map(split(opts.files, '\v%(\\@<!\\%(\\\\)*)@<!;'),
+                        \      's:F.comm.globtopattern(v:val)')
         endif
-        if empty(rev2)
-            let rev2=0
+        if has_key(opts, 'show')
+            let opts.show=split(opts.show, ';')
         endif
-        let buf=bufnr('%')
-        let s:bufvars[buf]={'repo': repo, 'rev1': rev1, 'rev2': rev2,
-                    \      'files': map(split(files,'\v%(\\@<!\\%(\\\\)*)@<!;'),
-                    \                   's:F.comm.globtopattern(v:val)'),}
+        for key in filter(['rev1', 'rev2'], 'has_key(opts, v:val)')
+            let opts[key]=repo.functions.getrevhex(repo, opts[key])
+        endfor
+        let s:bufvars[buf]={'repo': repo, 'opts': opts,}
         setlocal filetype=aurumstatus bufhidden=wipe
         runtime ftplugin/aurumstatus.vim
     "▶4 noop command (do nothing)
     setlocal filetype=aurumgraphlog bufhidden=wipe
     runtime ftplugin/aurumgraphlog.vim
 endfunction
-let s:glogfunc['@FWC']=['[:*F.comm.getrepo(".") '.
-            \            '(either(path d, match @\v^\w+%(\+\w+)*\V://@)'.
-            \                            '|*F.comm.getrepo)]'.
-            \           ' { *?files   (type "")'.
-            \           '    ?date    match /\v%(\d\d?|\*)'.
-            \                                 '%(\.%(\d\d?|\*)'.
-            \                                 '%(\.%(\d\d%(\d\d)?|\*)'.
-            \                                 '%(\ %(\d\d?|\*)'.
-            \                                 '%(\:%(\d\d?|\*))?)?)?)?/'.
-            \           '    ?search  isreg'.
-            \           '  +2?rev     type "" type ""'.
-            \           '   !?merges'.
-            \           '    ?user    isreg'.
-            \           '    ?branch  type ""'.
-            \           '   !?patch'.
-            \           '    ?limit   range 1 inf'.
-            \           '   !?stat'.
-            \           '   !?showfiles'.
-            \           '   !?showrenames'.
-            \           ' }',
-            \'filter']
+let s:repoarg=':*F.comm.getrepo(".") (either(path d, '.
+            \                               'match @\v^\w+%(\+\w+)*\V://@) '.
+            \                        '|*F.comm.getrepo)'
+let s:glogfunc['@FWC']=['['.s:repoarg.']'.
+            \           '{ *?files   (type "")'.
+            \           '   ?date    match /\v%(\d\d?|\*)'.
+            \                                '%(\.%(\d\d?|\*)'.
+            \                                '%(\.%(\d\d%(\d\d)?|\*)'.
+            \                                '%(\ %(\d\d?|\*)'.
+            \                                '%(\:%(\d\d?|\*))?)?)?)?/'.
+            \           '   ?search  isreg'.
+            \           ' +2?rev     type "" type ""'.
+            \           '  !?merges'.
+            \           '   ?user    isreg'.
+            \           '   ?branch  type ""'.
+            \           '  !?patch'.
+            \           '   ?limit   range 1 inf'.
+            \           '  !?stat'.
+            \           '  !?showfiles'.
+            \           '  !?showrenames'.
+            \           '}', 'filter']
 call add(s:glogcomp,
             \substitute(substitute(s:glogfunc['@FWC'][0],
             \'\V|*F.comm.getrepo',  '',           ''),
     let s:bufvars[bufnr('%')].annbuf=annbuf
 endfunction
 "▶3 statfunc
-function s:statfunc.function(...)
-    let repo=s:F.comm.getrepo(get(a:000, 0, ''))
-    let rev1=escape(get(a:000, 1, ''), '\:')
-    let rev2=escape(get(a:000, 2, ''), '\:')
-    let files=join(map(copy(a:000[3:]), 'escape(v:val, "\\;")'), ';')
-    execute 'new' fnameescape('aurum://status:'.escape(repo.path, '\:').':'.
-                \             rev1.':'.rev2.':'.files)
+function s:statfunc.function(repo, opts)
+    let opts=[]
+    for [key, value] in items(a:opts)
+        let opt=key.':'
+        if key is# 'files'
+            let opt.=join(map(copy(value), 'escape(v:val, "\\:;,")'), ';')
+        elseif key is# 'show'
+            let opt.=join(value, ';')
+        else
+            let opt.=escape(value, '\:,')
+        endif
+        call add(opts, opt)
+        unlet value
+    endfor
+    execute 'new' fnameescape('aurum://status:'.escape(a:repo.path, '\:').':'.
+                \             join(opts, ','))
 endfunction
+let s:statfunc['@FWC']=['['.s:repoarg.']'.
+            \           '{ *?files     (type "")'.
+            \           '   ?rev1      (type "")'.
+            \           '   ?rev2      (type "")'.
+            \           '  *?show      (in [modified added removed deleted '.
+            \                              'unknown ignored clean])'.
+            \           '}', 'filter']
+call add(s:statcomp,
+            \substitute(substitute(s:glogfunc['@FWC'][0],
+            \'\V|*F.comm.getrepo',  '',           ''),
+            \'\vfiles\s+\([^)]*\)', 'files path', ''))
 "▶3 difffunc
 function s:difffunc.function(...)
     let repo=s:F.comm.getrepo('')