From e244b7034dac97d8546faeb0e889ab5868801614 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Sun, 6 Dec 2015 10:35:45 +0100 Subject: improved ascii tablesc --- vim/autoload/pathogen.vim | 326 ++++++++++++++++++++++++++++++++++++++++++++++ vim/bundle/tabular | 1 + vimrc | 15 +++ 3 files changed, 342 insertions(+) create mode 100644 vim/autoload/pathogen.vim create mode 160000 vim/bundle/tabular diff --git a/vim/autoload/pathogen.vim b/vim/autoload/pathogen.vim new file mode 100644 index 0000000..7b89cca --- /dev/null +++ b/vim/autoload/pathogen.vim @@ -0,0 +1,326 @@ +" pathogen.vim - path option manipulation +" Maintainer: Tim Pope +" Version: 2.2 + +" Install in ~/.vim/autoload (or ~\vimfiles\autoload). +" +" For management of individually installed plugins in ~/.vim/bundle (or +" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your +" .vimrc is the only other setup necessary. +" +" The API is documented inline below. For maximum ease of reading, +" :set foldmethod=marker + +if exists("g:loaded_pathogen") || &cp + finish +endif +let g:loaded_pathogen = 1 + +function! s:warn(msg) + echohl WarningMsg + echomsg a:msg + echohl NONE +endfunction + +" Point of entry for basic default usage. Give a relative path to invoke +" pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke +" pathogen#surround(). For backwards compatibility purposes, a full path that +" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories() +" instead. +function! pathogen#infect(...) abort " {{{1 + for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}'] + if path =~# '^[^\\/]\+$' + call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') + call pathogen#incubate(path . '/{}') + elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$' + call pathogen#incubate(path) + elseif path =~# '[\\/]\%({}\|\*\)$' + call pathogen#surround(path) + else + call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') + call pathogen#surround(path . '/{}') + endif + endfor + call pathogen#cycle_filetype() + return '' +endfunction " }}}1 + +" Split a path into a list. +function! pathogen#split(path) abort " {{{1 + if type(a:path) == type([]) | return a:path | endif + let split = split(a:path,'\\\@"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags')) + silent! execute 'helptags' pathogen#fnameescape(dir.'/doc') + endif + endfor + endfor +endfunction " }}}1 + +command! -bar Helptags :call pathogen#helptags() + +" Execute the given command. This is basically a backdoor for --remote-expr. +function! pathogen#execute(...) abort " {{{1 + for command in a:000 + execute command + endfor + return '' +endfunction " }}}1 + +" Like findfile(), but hardcoded to use the runtimepath. +function! pathogen#runtime_findfile(file,count) abort "{{{1 + let rtp = pathogen#join(1,pathogen#split(&rtp)) + let file = findfile(a:file,rtp,a:count) + if file ==# '' + return '' + else + return fnamemodify(file,':p') + endif +endfunction " }}}1 + +" Backport of fnameescape(). +function! pathogen#fnameescape(string) abort " {{{1 + if exists('*fnameescape') + return fnameescape(a:string) + elseif a:string ==# '-' + return '\-' + else + return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','') + endif +endfunction " }}}1 + +if exists(':Vedit') + finish +endif + +let s:vopen_warning = 0 + +function! s:find(count,cmd,file,lcd) " {{{1 + let rtp = pathogen#join(1,pathogen#split(&runtimepath)) + let file = pathogen#runtime_findfile(a:file,a:count) + if file ==# '' + return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" + endif + if !s:vopen_warning + let s:vopen_warning = 1 + let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE' + else + let warning = '' + endif + if a:lcd + let path = file[0:-strlen(a:file)-2] + execute 'lcd `=path`' + return a:cmd.' '.pathogen#fnameescape(a:file) . warning + else + return a:cmd.' '.pathogen#fnameescape(file) . warning + endif +endfunction " }}}1 + +function! s:Findcomplete(A,L,P) " {{{1 + let sep = pathogen#separator() + let cheats = { + \'a': 'autoload', + \'d': 'doc', + \'f': 'ftplugin', + \'i': 'indent', + \'p': 'plugin', + \'s': 'syntax'} + if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) + let request = cheats[a:A[0]].a:A[1:-1] + else + let request = a:A + endif + let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*' + let found = {} + for path in pathogen#split(&runtimepath) + let path = expand(path, ':p') + let matches = split(glob(path.sep.pattern),"\n") + call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') + call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]') + for match in matches + let found[match] = 1 + endfor + endfor + return sort(keys(found)) +endfunction " }}}1 + +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1) +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1) + +" vim:set et sw=2: diff --git a/vim/bundle/tabular b/vim/bundle/tabular new file mode 160000 index 0000000..60f2564 --- /dev/null +++ b/vim/bundle/tabular @@ -0,0 +1 @@ +Subproject commit 60f25648814f0695eeb6c1040d97adca93c4e0bb diff --git a/vimrc b/vimrc index 3dab4fb..1d40d5e 100644 --- a/vimrc +++ b/vimrc @@ -152,3 +152,18 @@ autocmd FileType debcontrol set expandtab autocmd BufNewFile,BufRead /home/sre/src/linux/* set tabstop=8 shiftwidth=8 softtabstop=8 autocmd BufNewFile,BufRead /home/sre/src/linux-*/* set tabstop=8 shiftwidth=8 softtabstop=8 + +execute pathogen#infect() + +inoremap :call align()a + +function! s:align() + let p = '^\s*|\s.*\s|\s*$' + if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) + let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) + let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) + Tabularize/|/l1 + normal! 0 + call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) + endif +endfunction -- cgit v1.2.3