From 856f581114f676e1093e64c145af0e128dc8c9e3 Mon Sep 17 00:00:00 2001 From: Martin Kolman Date: Tue, 16 Jul 2013 16:35:12 +0200 Subject: Initial commit --- autoload/ShowTrailingWhitespace.vim | 110 ++++++++++ autoload/ShowTrailingWhitespace/Filter.vim | 30 +++ autoload/pathogen.vim | 328 +++++++++++++++++++++++++++++ 3 files changed, 468 insertions(+) create mode 100644 autoload/ShowTrailingWhitespace.vim create mode 100644 autoload/ShowTrailingWhitespace/Filter.vim create mode 100644 autoload/pathogen.vim (limited to 'autoload') diff --git a/autoload/ShowTrailingWhitespace.vim b/autoload/ShowTrailingWhitespace.vim new file mode 100644 index 0000000..cb7c5a8 --- /dev/null +++ b/autoload/ShowTrailingWhitespace.vim @@ -0,0 +1,110 @@ +" ShowTrailingWhitespace.vim: Detect unwanted whitespace at the end of lines. +" +" DEPENDENCIES: +" +" Copyright: (C) 2012 Ingo Karkat +" The VIM LICENSE applies to this script; see ':help copyright'. +" +" Maintainer: Ingo Karkat +" +" REVISION DATE REMARKS +" 1.00.004 06-Mar-2012 Toggle to value 2 when enabled but the buffer is +" filtered from showing trailing whitespace. +" 003 05-Mar-2012 Introduce g:ShowTrailingWhitespace_FilterFunc to +" disable highlighting for non-persisted and +" nomodifiable buffers. +" 002 02-Mar-2012 Introduce b:ShowTrailingWhitespace_ExtraPattern +" to be able to avoid some matches (e.g. a +" in column 1 in a buffer with filetype=diff) and +" ShowTrailingWhitespace#SetLocalExtraPattern() to +" set it. +" 001 25-Feb-2012 file creation +let s:save_cpo = &cpo +set cpo&vim + +function! ShowTrailingWhitespace#Pattern( isInsertMode ) + return (exists('b:ShowTrailingWhitespace_ExtraPattern') ? b:ShowTrailingWhitespace_ExtraPattern : '') . + \ (a:isInsertMode ? '\s\+\%#\@ 1 ? 0 : 2) + endif + endif + + call ShowTrailingWhitespace#Set(l:newState, a:isGlobal) +endfunction + +function! ShowTrailingWhitespace#SetLocalExtraPattern( pattern ) + let b:ShowTrailingWhitespace_ExtraPattern = a:pattern + call s:DetectAll() +endfunction + +" vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : diff --git a/autoload/ShowTrailingWhitespace/Filter.vim b/autoload/ShowTrailingWhitespace/Filter.vim new file mode 100644 index 0000000..2f0dc20 --- /dev/null +++ b/autoload/ShowTrailingWhitespace/Filter.vim @@ -0,0 +1,30 @@ +" ShowTrailingWhitespace/Filter.vim: Exclude certain buffers from detection. +" +" DEPENDENCIES: +" +" Copyright: (C) 2012 Ingo Karkat +" The VIM LICENSE applies to this script; see ':help copyright'. +" +" Maintainer: Ingo Karkat +" +" REVISION DATE REMARKS +" 1.00.002 06-Mar-2012 Modularize conditionals. +" Also do not normally show 'binary' buffers. +" 001 05-Mar-2012 file creation + +function! s:IsPersistedBuffer() + return ! (&l:buftype ==# 'nofile' || &l:buftype ==# 'nowrite') +endfunction +function! s:IsScratchBuffer() + return (bufname('') =~# '\[Scratch]') +endfunction +function! s:IsForcedShow() + return (ShowTrailingWhitespace#IsSet() == 2) +endfunction + +function! ShowTrailingWhitespace#Filter#Default() + let l:isShownNormally = &l:modifiable && ! &l:binary && (s:IsPersistedBuffer() || s:IsScratchBuffer()) + return l:isShownNormally || s:IsForcedShow() +endfunction + +" vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim new file mode 100644 index 0000000..57ca1bd --- /dev/null +++ b/autoload/pathogen.vim @@ -0,0 +1,328 @@ +" 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 `call 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) + if &verbose + echohl WarningMsg + echomsg a:msg + echohl NONE + endif +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')) + helptags `=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: -- cgit