Source

aurum / test / vimrc

syntax on
let s:outfile=fnamemodify(g:outfile, ':p')
function s:Run(bang, write, cmd)
    let reporoot='./'.g:curtest.'repo'
    let olddir=fnamemodify('.', ':p')
    if !a:bang
        execute 'silent cd' fnameescape(reporoot)
    endif
    try
        execute a:cmd
        if exists('g:postcmd')
            execute 'silent' g:postcmd
        endif
    finally
        if !a:bang
            execute 'silent cd' fnameescape(olddir)
        endif
        if a:write
            execute 'silent write! ++ff=unix >> '.fnameescape(s:outfile)
        endif
    endtry
endfunction
command -nargs=1 -bang Run :call s:Run(<bang>0, 1, <q-args>)
command -nargs=1 -bang R   :call s:Run(<bang>0, 0, <q-args>)
function WriteFile(...)
    let r=[]
    if filereadable(s:outfile)
        let r+=readfile(s:outfile, 'b')
        if !empty(r) && empty(r[-1])
            call remove(r, -1)
        endif
    endif
    if type(a:1)==type([])
        let r+=a:1
    else
        let r+=a:000
    endif
    if !empty(r) && !empty(r[-1])
        let r+=['']
    endif
    call writefile(r, s:outfile, 'b')
    return ''
endfunction
command -nargs=1 -bar W call WriteFile(<q-args>)
function s:WriteTip(writecom, cmd)
    let tipname=get(g:, 'tipname', 'tip')
    execute 'R AuLog limit 1 revision '.tipname
    setlocal modifiable noreadonly
    if !a:writecom
        g/Commited/delete _
    endif
    normal! gg0f:"_de
    if !empty(a:cmd)
        execute a:cmd
    endif
    call WriteFile(getline(1, line('$')-1))
    bwipeout!
endfunction
command -nargs=? -bar -bang WT :call s:WriteTip(<bang>0, <q-args>)
function s:WriteWindows()
    let wcur=winnr()
    let wprev=winnr('#')
    let r=[]
    for w in range(1, winnr('$'))
        let buf=winbufnr(w)
        let bn=bufname(buf)
        if empty(getbufvar(buf, '&buftype')) && !empty(bn)
            let bn=fnamemodify(bn, ':p')
        endif
        let r+=[((w==wcur)?('*'):((w==wprev)?('#'):(' '))).w.': '.bn]
    endfor
    return WriteFile(r)
endfunction
let g:aurum_diffopts={'dates': 0}
command -nargs=0 -bar WW :call s:WriteWindows()
function s:WriteTabs()
    let tcur=tabpagenr()
    let r=[]
    for t in range(1, tabpagenr('$'))
        let bs=tabpagebuflist(t)
        let wcur=tabpagewinnr(t)
        let wprev=tabpagewinnr(t, '#')
        for w in range(1, tabpagewinnr(t, '$'))
            let s  = ((t==tcur)?('*'):(' ')).t
            let s .= ((w==wcur)?('*'):((w==wprev)?('#'):(' '))).w
            let bn=bufname(bs[w-1])
            if empty(getbufvar(bs[w-1], '&buftype')) && !empty(bn)
                let bn=fnamemodify(bn, ':p')
            endif
            let s .= ': '.bn
            let r+=[s]
        endfor
    endfor
    return WriteFile(r)
endfunction
command -nargs=0 -bar WTabs :call s:WriteTabs()
function s:WriteBuffers()
    call WriteFile(map(filter(range(1, bufnr('$')), 'bufexists(v:val)'),
                \      '"*="[v:val=='.bufnr('%').'].bufname(v:val)'))
endfunction
command -nargs=0 -bar WB :call s:WriteBuffers()
function s:Try(cmd)
    try
        execute a:cmd
    catch
        call WriteFile(v:exception)
    endtry
endfunction
command -nargs=1 Try :call s:Try(<q-args>)
let $HGRC=''
let $HGRCPATH=''
let $EMAIL='ZyX <kp-pav@yandex.ru>'
let g:mapleader=','
let g:maplocalleader=','
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.