1
0
mirror of https://github.com/amix/vimrc synced 2025-07-09 10:45:00 +08:00

Updated vimrc

This commit is contained in:
amix
2015-07-13 11:22:46 +01:00
parent 9a2843c2a5
commit d7752b59ae
301 changed files with 4699 additions and 7969 deletions

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_c_autoload") || !exists("g:loaded_syntastic_plugin")
if exists('g:loaded_syntastic_c_autoload') || !exists('g:loaded_syntastic_plugin')
finish
endif
let g:loaded_syntastic_c_autoload = 1
@ -21,8 +21,8 @@ function! syntastic#c#ReadConfig(file) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: looking for', a:file)
" search upwards from the current file's directory
let config = findfile(a:file, '.;')
if config == ''
let config = syntastic#util#findFileInParent(a:file, expand('%:p:h', 1))
if config ==# ''
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: file not found')
return ''
endif
@ -44,7 +44,7 @@ function! syntastic#c#ReadConfig(file) abort " {{{2
endtry
" filter out empty lines and comments
call filter(lines, 'v:val !~ ''\v^(\s*#|$)''')
call filter(lines, 'v:val !~# ''\v^(\s*#|$)''')
" remove leading and trailing spaces
call map(lines, 'substitute(v:val, ''\m^\s\+'', "", "")')
@ -53,7 +53,7 @@ function! syntastic#c#ReadConfig(file) abort " {{{2
let parameters = []
for line in lines
let matches = matchstr(line, '\m\C^\s*-I\s*\zs.\+')
if matches != ''
if matches !=# ''
" this one looks like an absolute path
if match(matches, '\m^\%(/\|\a:\)') != -1
call add(parameters, '-I' . matches)
@ -120,9 +120,9 @@ endfunction " }}}2
" register a handler dictionary object
function! s:_registerHandler(regex, function, args) abort " {{{2
let handler = {}
let handler["regex"] = a:regex
let handler["func"] = function(a:function)
let handler["args"] = a:args
let handler['regex'] = a:regex
let handler['func'] = function(a:function)
let handler['args'] = a:args
call add(s:handlers, handler)
endfunction " }}}2
@ -223,10 +223,10 @@ function! s:_get_cflags(ft, ck, opts) abort " {{{2
" check if the user manually set some cflags
let b_cflags = s:_get_checker_var('b', a:ft, a:ck, 'cflags', '')
if b_cflags == ''
" check whether to search for include files at all
if !s:_get_checker_var('g', a:ft, a:ck, 'no_include_search', 0)
if a:ft ==# 'c' || a:ft ==# 'cpp'
if b_cflags ==# ''
if a:ft ==# 'c' || a:ft ==# 'cpp'
" check whether to search for include files at all
if !s:_get_checker_var('g', a:ft, a:ck, 'no_include_search', 0)
" refresh the include file search if desired
if s:_get_checker_var('g', a:ft, a:ck, 'auto_refresh_includes', 0)
let flags .= ' ' . s:_search_headers()
@ -280,15 +280,15 @@ function! s:_search_headers() abort " {{{2
" search current buffer
for line in lines
let file = matchstr(line, '\m"\zs\S\+\ze"')
if file != ''
if file !=# ''
call add(files, file)
continue
endif
for handler in s:handlers
if line =~# handler["regex"]
let includes .= call(handler["func"], handler["args"])
call add(found, handler["regex"])
if line =~# handler['regex']
let includes .= call(handler['func'], handler['args'])
call add(found, handler['regex'])
break
endif
endfor
@ -296,7 +296,7 @@ function! s:_search_headers() abort " {{{2
" search included headers
for hfile in files
if hfile != ''
if hfile !=# ''
let filename = expand('%:p:h', 1) . syntastic#util#Slash() . hfile
try
@ -308,14 +308,14 @@ function! s:_search_headers() abort " {{{2
call filter(lines, 'v:val =~# ''\m^\s*#\s*include''')
for handler in s:handlers
if index(found, handler["regex"]) != -1
if index(found, handler['regex']) != -1
continue
endif
for line in lines
if line =~# handler["regex"]
let includes .= call(handler["func"], handler["args"])
call add(found, handler["regex"])
if line =~# handler['regex']
let includes .= call(handler['func'], handler['args'])
call add(found, handler['regex'])
break
endif
endfor

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_log_autoload") || !exists("g:loaded_syntastic_plugin")
if exists('g:loaded_syntastic_log_autoload') || !exists('g:loaded_syntastic_plugin')
finish
endif
let g:loaded_syntastic_log_autoload = 1
@ -11,19 +11,19 @@ let s:one_time_notices_issued = []
" Public functions {{{1
function! syntastic#log#info(msg) abort " {{{2
echomsg "syntastic: info: " . a:msg
echomsg 'syntastic: info: ' . a:msg
endfunction " }}}2
function! syntastic#log#warn(msg) abort " {{{2
echohl WarningMsg
echomsg "syntastic: warning: " . a:msg
echomsg 'syntastic: warning: ' . a:msg
echohl None
endfunction " }}}2
function! syntastic#log#error(msg) abort " {{{2
execute "normal \<Esc>"
echohl ErrorMsg
echomsg "syntastic: error: " . a:msg
echomsg 'syntastic: error: ' . a:msg
echohl None
endfunction " }}}2
@ -88,9 +88,9 @@ function! syntastic#log#debugShowOptions(level, names) abort " {{{2
let leader = s:_log_timestamp()
call s:_logRedirect(1)
let vlist = copy(type(a:names) == type("") ? [a:names] : a:names)
let vlist = copy(type(a:names) == type('') ? [a:names] : a:names)
if !empty(vlist)
call map(vlist, "'&' . v:val . ' = ' . strtrans(string(eval('&' . v:val)))")
call map(vlist, "'&' . v:val . ' = ' . strtrans(string(eval('&' . v:val))) . (s:_is_modified(v:val) ? ' (!)' : '')")
echomsg leader . join(vlist, ', ')
endif
call s:_logRedirect(0)
@ -104,10 +104,10 @@ function! syntastic#log#debugShowVariables(level, names) abort " {{{2
let leader = s:_log_timestamp()
call s:_logRedirect(1)
let vlist = type(a:names) == type("") ? [a:names] : a:names
let vlist = type(a:names) == type('') ? [a:names] : a:names
for name in vlist
let msg = s:_format_variable(name)
if msg != ''
if msg !=# ''
echomsg leader . msg
endif
endfor
@ -123,6 +123,21 @@ function! syntastic#log#debugDump(level) abort " {{{2
call syntastic#log#debugShowVariables( a:level, sort(keys(g:_SYNTASTIC_DEFAULTS)) )
endfunction " }}}2
function! syntastic#log#ndebug(level, title, messages) abort " {{{2
if s:_isDebugEnabled(a:level)
return
endif
call syntastic#log#error(a:title)
if type(a:messages) == type([])
for msg in a:messages
echomsg msg
endfor
else
echomsg a:messages
endif
endfunction " }}}2
" }}}1
" Private functions {{{1
@ -140,7 +155,7 @@ let s:_isDebugEnabled = function(exists('*and') ? 's:_isDebugEnabled_smart' : 's
lockvar s:_isDebugEnabled
function! s:_logRedirect(on) abort " {{{2
if exists("g:syntastic_debug_file")
if exists('g:syntastic_debug_file')
if a:on
try
execute 'redir >> ' . fnameescape(expand(g:syntastic_debug_file, 1))
@ -174,6 +189,20 @@ function! s:_format_variable(name) abort " {{{2
return join(vals, ', ')
endfunction " }}}2
function! s:_is_modified(name) abort " {{{2
if !exists('s:option_defaults')
let s:option_defaults = {}
endif
if !has_key(s:option_defaults, a:name)
let opt_save = eval('&' . a:name)
execute 'set ' . a:name . '&'
let s:option_defaults[a:name] = eval('&' . a:name)
execute 'let &' . a:name . ' = ' . string(opt_save)
endif
return s:option_defaults[a:name] !=# eval('&' . a:name)
endfunction " }}}2
" }}}1
let &cpo = s:save_cpo

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_postprocess_autoload") || !exists("g:loaded_syntastic_plugin")
if exists('g:loaded_syntastic_postprocess_autoload') || !exists('g:loaded_syntastic_plugin')
finish
endif
let g:loaded_syntastic_postprocess_autoload = 1

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_preprocess_autoload") || !exists("g:loaded_syntastic_plugin")
if exists('g:loaded_syntastic_preprocess_autoload') || !exists('g:loaded_syntastic_plugin')
finish
endif
let g:loaded_syntastic_preprocess_autoload = 1
@ -13,14 +13,14 @@ function! syntastic#preprocess#cabal(errors) abort " {{{2
let star = 0
for err in a:errors
if star
if err == ''
if err ==# ''
let star = 0
else
let out[-1] .= ' ' . err
endif
else
call add(out, err)
if err =~ '\m^*\s'
if err =~# '\m^*\s'
let star = 1
endif
endif
@ -68,10 +68,15 @@ function! syntastic#preprocess#flow(errors) abort " {{{2
let false = 0
let null = ''
let idx = 0
while idx < len(a:errors) && a:errors[idx][0] != '{'
let idx += 1
endwhile
" A hat tip to Marc Weber for this trick
" http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
try
let errs = eval(join(a:errors, ''))
let errs = eval(join(a:errors[idx :], ''))
catch
let errs = {}
endtry
@ -88,7 +93,7 @@ function! syntastic#preprocess#flow(errors) abort " {{{2
\ m['path'] . ':' .
\ m['line'] . ':' .
\ m['start'] . ':' .
\ (m['line'] ==# m['endline'] ? m['end'] . ':' : '') .
\ (m['line'] ==# m['endline'] && str2nr(m['end']) > 0 ? m['end'] . ':' : '') .
\ ' ' . m['descr']
if len(t)
@ -123,8 +128,15 @@ endfunction " }}}2
" @vimlint(EVL102, 0, l:false)
" @vimlint(EVL102, 0, l:null)
function! syntastic#preprocess#iconv(errors) abort " {{{2
return
\ (has('iconv') || has('iconv/dyn')) && &encoding !=# '' && &encoding !=# 'utf-8' ?
\ map(a:errors, 'iconv(v:val, "utf-8", &encoding)') :
\ a:errors
endfunction " }}}2
function! syntastic#preprocess#killEmpty(errors) abort " {{{2
return filter(copy(a:errors), 'v:val != ""')
return filter(copy(a:errors), 'v:val !=# ""')
endfunction " }}}2
function! syntastic#preprocess#perl(errors) abort " {{{2
@ -204,7 +216,7 @@ function! syntastic#preprocess#rparse(errors) abort " {{{2
" remove uninteresting lines and handle continuations
let i = 0
while i < len(errlist)
if i > 0 && errlist[i][:1] == ' ' && errlist[i] !~ '\m\s\+\^$'
if i > 0 && errlist[i][:1] ==# ' ' && errlist[i] !~# '\m\s\+\^$'
let errlist[i-1] .= errlist[i][1:]
call remove(errlist, i)
elseif errlist[i] !~# '\m^\(Lint:\|Lint checking:\|Error in\) '
@ -224,7 +236,7 @@ function! syntastic#preprocess#rparse(errors) abort " {{{2
call add(out, 'E:' . fname . ':' . line . ': ' . parts[1])
endfor
endif
if len(parts) >= 5 && parts[4] != ''
if len(parts) >= 5 && parts[4] !=# ''
call add(out, 'E:' . fname . ':0: ' . parts[1] . ' - ' . parts[4] . ' messages not shown')
endif
elseif match(e, '\m^Lint checking: ') == 0

View File

@ -1,4 +1,4 @@
if exists('g:loaded_syntastic_util_autoload') || !exists("g:loaded_syntastic_plugin")
if exists('g:loaded_syntastic_util_autoload') || !exists('g:loaded_syntastic_plugin')
finish
endif
let g:loaded_syntastic_util_autoload = 1
@ -21,7 +21,7 @@ endfunction " }}}2
" Get directory separator
function! syntastic#util#Slash() abort " {{{2
return (!exists("+shellslash") || &shellslash) ? '/' : '\'
return (!exists('+shellslash') || &shellslash) ? '/' : '\'
endfunction " }}}2
function! syntastic#util#CygwinPath(path) abort " {{{2
@ -53,19 +53,19 @@ function! syntastic#util#tmpdir() abort " {{{2
if (has('unix') || has('mac')) && executable('mktemp')
" TODO: option "-t" to mktemp(1) is not portable
let tmp = $TMPDIR != '' ? $TMPDIR : $TMP != '' ? $TMP : '/tmp'
let tmp = $TMPDIR !=# '' ? $TMPDIR : $TMP !=# '' ? $TMP : '/tmp'
let out = split(syntastic#util#system('mktemp -q -d ' . tmp . '/vim-syntastic-' . getpid() . '-XXXXXXXX'), "\n")
if v:shell_error == 0 && len(out) == 1
let tempdir = out[0]
endif
endif
if tempdir == ''
if tempdir ==# ''
if has('win32') || has('win64')
let tempdir = $TEMP . syntastic#util#Slash() . 'vim-syntastic-' . getpid()
elseif has('win32unix')
let tempdir = syntastic#util#CygwinPath('/tmp/vim-syntastic-' . getpid())
elseif $TMPDIR != ''
elseif $TMPDIR !=# ''
let tempdir = $TMPDIR . '/vim-syntastic-' . getpid()
else
let tempdir = '/tmp/vim-syntastic-' . getpid()
@ -97,7 +97,7 @@ function! syntastic#util#rmrf(what) abort " {{{2
\ has('win16') || has('win95') || has('dos16') || has('dos32') ? 'deltree /Y' : ''
endif
if s:rmrf != ''
if s:rmrf !=# ''
silent! call syntastic#util#system(s:rmrf . ' ' . syntastic#util#shescape(a:what))
else
call s:_rmrf(a:what)
@ -120,7 +120,7 @@ endfunction " }}}2
function! syntastic#util#parseShebang() abort " {{{2
for lnum in range(1, 5)
let line = getline(lnum)
if line =~ '^#!'
if line =~# '^#!'
let line = substitute(line, '\v^#!\s*(\S+/env(\s+-\S+)*\s+)?', '', '')
let exe = matchstr(line, '\m^\S*\ze')
let args = split(matchstr(line, '\m^\S*\zs.*'))
@ -140,8 +140,8 @@ function! syntastic#util#var(name, ...) abort " {{{2
endfunction " }}}2
" Parse a version string. Return an array of version components.
function! syntastic#util#parseVersion(version) abort " {{{2
return map(split(matchstr( a:version, '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.'), 'str2nr(v:val)')
function! syntastic#util#parseVersion(version, ...) abort " {{{2
return map(split(matchstr( a:version, a:0 ? a:1 : '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.'), 'str2nr(v:val)')
endfunction " }}}2
" Verify that the 'installed' version is at least the 'required' version.
@ -164,7 +164,7 @@ function! syntastic#util#compareLexi(a, b) abort " {{{2
return a_element > b_element ? 1 : -1
endif
endfor
" Everything matched, so it is at least the required version.
" still here, thus everything matched
return 0
endfunction " }}}2
@ -190,7 +190,7 @@ function! syntastic#util#wideMsg(msg) abort " {{{2
"This is here because it is possible for some error messages to
"begin with \n which will cause a "press enter" prompt.
let msg = substitute(a:msg, "\n", "", "g")
let msg = substitute(a:msg, "\n", '', 'g')
"convert tabs to spaces so that the tabs count towards the window
"width as the proper amount of characters
@ -226,13 +226,23 @@ function! syntastic#util#bufIsActive(buffer) abort " {{{2
return 0
endfunction " }}}2
" start in directory a:where and walk up the parent folders until it
" finds a file matching a:what; return path to that file
function! syntastic#util#findInParent(what, where) abort " {{{2
" start in directory a:where and walk up the parent folders until it finds a
" file named a:what; return path to that file
function! syntastic#util#findFileInParent(what, where) abort " {{{2
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let file = findfile(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return file
endfunction " }}}2
" start in directory a:where and walk up the parent folders until it finds a
" file matching a:what; return path to that file
function! syntastic#util#findGlobInParent(what, where) abort " {{{2
let here = fnamemodify(a:where, ':p')
let root = syntastic#util#Slash()
if syntastic#util#isRunningWindows() && here[1] == ':'
if syntastic#util#isRunningWindows() && here[1] ==# ':'
" The drive letter is an ever-green source of fun. That's because
" we don't care about running syntastic on Amiga these days. ;)
let root = fnamemodify(root, ':p')
@ -240,7 +250,7 @@ function! syntastic#util#findInParent(what, where) abort " {{{2
endif
let old = ''
while here != ''
while here !=# ''
let p = split(globpath(here, a:what, 1), '\n')
if !empty(p)
@ -284,7 +294,7 @@ endfunction " }}}2
" Escape arguments
function! syntastic#util#argsescape(opt) abort " {{{2
if type(a:opt) == type('') && a:opt != ''
if type(a:opt) == type('') && a:opt !=# ''
return [a:opt]
elseif type(a:opt) == type([])
return map(copy(a:opt), 'syntastic#util#shescape(v:val)')
@ -323,11 +333,10 @@ function! syntastic#util#dictFilter(errors, filter) abort " {{{2
endtry
endfunction " }}}2
" Return a [high, low] list of integers, representing the time
" (hopefully high resolution) since program start
" TODO: This assumes reltime() returns a list of integers.
" Return a [seconds, fractions] list of strings, representing the
" (hopefully high resolution) time since program start
function! syntastic#util#stamp() abort " {{{2
return reltime(g:_SYNTASTIC_START)
return split( split(reltimestr(reltime(g:_SYNTASTIC_START)))[0], '\.' )
endfunction " }}}2
" }}}1
@ -345,14 +354,14 @@ function! s:_translateFilter(filters) abort " {{{2
endfor
if conditions == []
let conditions = ["1"]
let conditions = ['1']
endif
return len(conditions) == 1 ? conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
endfunction " }}}2
function! s:_translateElement(key, term) abort " {{{2
let fkey = a:key
if fkey[0] == '!'
if fkey[0] ==# '!'
let fkey = fkey[1:]
let not = 1
else
@ -377,13 +386,13 @@ function! s:_translateElement(key, term) abort " {{{2
let op = not ? ' =~# ' : ' !~# '
let ret = 'bufname(str2nr(v:val["bufnr"]))'
let mod = fkey[4:]
if mod != ''
if mod !=# ''
let ret = 'fnamemodify(' . ret . ', ' . string(mod) . ')'
endif
let ret .= op . string(a:term)
else
call syntastic#log#warn('quiet_messages: ignoring invalid key ' . strtrans(string(fkey)))
let ret = "1"
let ret = '1'
endif
return ret
endfunction " }}}2