More naming conventions.
This commit is contained in:
parent
64cce20838
commit
c4c56716fe
@ -62,7 +62,7 @@ endfunction " }}}2
|
||||
" GetLocList() for C-like compilers
|
||||
function! syntastic#c#GetLocList(filetype, subchecker, options) " {{{2
|
||||
try
|
||||
let flags = s:_getCflags(a:filetype, a:subchecker, a:options)
|
||||
let flags = s:_get_cflags(a:filetype, a:subchecker, a:options)
|
||||
catch /\m\C^Syntastic: skip checks$/
|
||||
return []
|
||||
endtry
|
||||
@ -70,9 +70,9 @@ function! syntastic#c#GetLocList(filetype, subchecker, options) " {{{2
|
||||
let makeprg = syntastic#util#shexpand(g:syntastic_{a:filetype}_compiler) .
|
||||
\ ' ' . flags . ' ' . syntastic#util#shexpand('%')
|
||||
|
||||
let errorformat = s:_getCheckerVar('g', a:filetype, a:subchecker, 'errorformat', a:options['errorformat'])
|
||||
let errorformat = s:_get_checker_var('g', a:filetype, a:subchecker, 'errorformat', a:options['errorformat'])
|
||||
|
||||
let postprocess = s:_getCheckerVar('g', a:filetype, a:subchecker, 'remove_include_errors', 0) ?
|
||||
let postprocess = s:_get_checker_var('g', a:filetype, a:subchecker, 'remove_include_errors', 0) ?
|
||||
\ ['filterForeignErrors'] : []
|
||||
|
||||
" process makeprg
|
||||
@ -91,25 +91,25 @@ function! s:_init() " {{{2
|
||||
let s:handlers = []
|
||||
let s:cflags = {}
|
||||
|
||||
call s:_regHandler('\m\<cairo', 's:_check_pkg', ['cairo', 'cairo'])
|
||||
call s:_regHandler('\m\<freetype', 's:_check_pkg', ['freetype', 'freetype2', 'freetype'])
|
||||
call s:_regHandler('\m\<glade', 's:_check_pkg', ['glade', 'libglade-2.0', 'libglade'])
|
||||
call s:_regHandler('\m\<glib', 's:_check_pkg', ['glib', 'glib-2.0', 'glib'])
|
||||
call s:_regHandler('\m\<gtk', 's:_check_pkg', ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
|
||||
call s:_regHandler('\m\<libsoup', 's:_check_pkg', ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
|
||||
call s:_regHandler('\m\<libxml', 's:_check_pkg', ['libxml', 'libxml-2.0', 'libxml'])
|
||||
call s:_regHandler('\m\<pango', 's:_check_pkg', ['pango', 'pango'])
|
||||
call s:_regHandler('\m\<SDL', 's:_check_pkg', ['sdl', 'sdl'])
|
||||
call s:_regHandler('\m\<opengl', 's:_check_pkg', ['opengl', 'gl'])
|
||||
call s:_regHandler('\m\<webkit', 's:_check_pkg', ['webkit', 'webkit-1.0'])
|
||||
call s:_registerHandler('\m\<cairo', 's:_checkPackage', ['cairo', 'cairo'])
|
||||
call s:_registerHandler('\m\<freetype', 's:_checkPackage', ['freetype', 'freetype2', 'freetype'])
|
||||
call s:_registerHandler('\m\<glade', 's:_checkPackage', ['glade', 'libglade-2.0', 'libglade'])
|
||||
call s:_registerHandler('\m\<glib', 's:_checkPackage', ['glib', 'glib-2.0', 'glib'])
|
||||
call s:_registerHandler('\m\<gtk', 's:_checkPackage', ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
|
||||
call s:_registerHandler('\m\<libsoup', 's:_checkPackage', ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
|
||||
call s:_registerHandler('\m\<libxml', 's:_checkPackage', ['libxml', 'libxml-2.0', 'libxml'])
|
||||
call s:_registerHandler('\m\<pango', 's:_checkPackage', ['pango', 'pango'])
|
||||
call s:_registerHandler('\m\<SDL', 's:_checkPackage', ['sdl', 'sdl'])
|
||||
call s:_registerHandler('\m\<opengl', 's:_checkPackage', ['opengl', 'gl'])
|
||||
call s:_registerHandler('\m\<webkit', 's:_checkPackage', ['webkit', 'webkit-1.0'])
|
||||
|
||||
call s:_regHandler('\m\<php\.h\>', 's:_check_php', [])
|
||||
call s:_regHandler('\m\<Python\.h\>', 's:_check_python', [])
|
||||
call s:_regHandler('\m\<ruby', 's:_check_ruby', [])
|
||||
call s:_registerHandler('\m\<php\.h\>', 's:_checkPhp', [])
|
||||
call s:_registerHandler('\m\<Python\.h\>', 's:_checkPython', [])
|
||||
call s:_registerHandler('\m\<ruby', 's:_checkRuby', [])
|
||||
endfunction " }}}2
|
||||
|
||||
" return a handler dictionary object
|
||||
function! s:_regHandler(regex, function, args) " {{{2
|
||||
" register a handler dictionary object
|
||||
function! s:_registerHandler(regex, function, args) " {{{2
|
||||
let handler = {}
|
||||
let handler["regex"] = a:regex
|
||||
let handler["func"] = function(a:function)
|
||||
@ -117,8 +117,75 @@ function! s:_regHandler(regex, function, args) " {{{2
|
||||
call add(s:handlers, handler)
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find library with 'pkg-config'
|
||||
" search possible libraries from first to last given
|
||||
" argument until one is found
|
||||
function! s:_checkPackage(name, ...) " {{{2
|
||||
if executable('pkg-config')
|
||||
if !has_key(s:cflags, a:name)
|
||||
for pkg in a:000
|
||||
let pkg_flags = system('pkg-config --cflags ' . pkg)
|
||||
" since we cannot necessarily trust the pkg-config exit code
|
||||
" we have to check for an error output as well
|
||||
if v:shell_error == 0 && pkg_flags !~? 'not found'
|
||||
let pkg_flags = ' ' . substitute(pkg_flags, "\n", '', '')
|
||||
let s:cflags[a:name] = pkg_flags
|
||||
return pkg_flags
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
return s:cflags[a:name]
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find PHP includes with 'php-config'
|
||||
function! s:_checkPhp() " {{{2
|
||||
if executable('php-config')
|
||||
if !has_key(s:cflags, 'php')
|
||||
let s:cflags['php'] = system('php-config --includes')
|
||||
let s:cflags['php'] = ' ' . substitute(s:cflags['php'], "\n", '', '')
|
||||
endif
|
||||
return s:cflags['php']
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find the python headers with distutils
|
||||
function! s:_checkPython() " {{{2
|
||||
if executable('python')
|
||||
if !has_key(s:cflags, 'python')
|
||||
let s:cflags['python'] = system('python -c ''from distutils import ' .
|
||||
\ 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''')
|
||||
let s:cflags['python'] = substitute(s:cflags['python'], "\n", '', '')
|
||||
let s:cflags['python'] = ' -I' . s:cflags['python']
|
||||
endif
|
||||
return s:cflags['python']
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find the ruby headers with 'rbconfig'
|
||||
function! s:_checkRuby() " {{{2
|
||||
if executable('ruby')
|
||||
if !has_key(s:cflags, 'ruby')
|
||||
let s:cflags['ruby'] = system('ruby -r rbconfig -e ' .
|
||||
\ '''puts RbConfig::CONFIG["rubyhdrdir"] || RbConfig::CONFIG["archdir"]''')
|
||||
let s:cflags['ruby'] = substitute(s:cflags['ruby'], "\n", '', '')
|
||||
let s:cflags['ruby'] = ' -I' . s:cflags['ruby']
|
||||
endif
|
||||
return s:cflags['ruby']
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Utilities {{{1
|
||||
|
||||
" resolve checker-related user variables
|
||||
function! s:_getCheckerVar(scope, filetype, subchecker, name, default) " {{{2
|
||||
function! s:_get_checker_var(scope, filetype, subchecker, name, default) " {{{2
|
||||
let prefix = a:scope . ':' . 'syntastic_'
|
||||
if exists(prefix . a:filetype . '_' . a:subchecker . '_' . a:name)
|
||||
return {a:scope}:syntastic_{a:filetype}_{a:subchecker}_{a:name}
|
||||
@ -130,10 +197,10 @@ function! s:_getCheckerVar(scope, filetype, subchecker, name, default) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
" resolve user CFLAGS
|
||||
function! s:_getCflags(ft, ck, opts) " {{{2
|
||||
function! s:_get_cflags(ft, ck, opts) " {{{2
|
||||
" determine whether to parse header files as well
|
||||
if has_key(a:opts, 'header_names') && expand('%') =~? a:opts['header_names']
|
||||
if s:_getCheckerVar('g', a:ft, a:ck, 'check_header', 0)
|
||||
if s:_get_checker_var('g', a:ft, a:ck, 'check_header', 0)
|
||||
let flags = get(a:opts, 'header_flags', '') . ' -c ' . syntastic#c#NullOutput()
|
||||
else
|
||||
" checking headers when check_header is unset: bail out
|
||||
@ -143,21 +210,21 @@ function! s:_getCflags(ft, ck, opts) " {{{2
|
||||
let flags = get(a:opts, 'main_flags', '')
|
||||
endif
|
||||
|
||||
let flags .= ' ' . s:_getCheckerVar('g', a:ft, a:ck, 'compiler_options', '') . ' ' . s:_getIncludeDirs(a:ft)
|
||||
let flags .= ' ' . s:_get_checker_var('g', a:ft, a:ck, 'compiler_options', '') . ' ' . s:_get_include_dirs(a:ft)
|
||||
|
||||
" check if the user manually set some cflags
|
||||
let b_cflags = s:_getCheckerVar('b', a:ft, a:ck, '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:_getCheckerVar('g', a:ft, a:ck, 'no_include_search', 0)
|
||||
if !s:_get_checker_var('g', a:ft, a:ck, 'no_include_search', 0)
|
||||
if a:ft ==# 'c' || a:ft ==# 'cpp'
|
||||
" refresh the include file search if desired
|
||||
if s:_getCheckerVar('g', a:ft, a:ck, 'auto_refresh_includes', 0)
|
||||
let flags .= ' ' . s:_searchHeaders()
|
||||
if s:_get_checker_var('g', a:ft, a:ck, 'auto_refresh_includes', 0)
|
||||
let flags .= ' ' . s:_search_headers()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_' . a:ft . '_includes')
|
||||
let b:syntastic_{a:ft}_includes = s:_searchHeaders()
|
||||
let b:syntastic_{a:ft}_includes = s:_search_headers()
|
||||
endif
|
||||
let flags .= ' ' . b:syntastic_{a:ft}_includes
|
||||
endif
|
||||
@ -169,7 +236,7 @@ function! s:_getCflags(ft, ck, opts) " {{{2
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let config_file = s:_getCheckerVar('g', a:ft, a:ck, 'config_file', '.syntastic_' . a:ft . '_config')
|
||||
let config_file = s:_get_checker_var('g', a:ft, a:ck, 'config_file', '.syntastic_' . a:ft . '_config')
|
||||
let flags .= ' ' . syntastic#c#ReadConfig(config_file)
|
||||
|
||||
return flags
|
||||
@ -177,7 +244,7 @@ endfunction " }}}2
|
||||
|
||||
" get the gcc include directory argument depending on the default
|
||||
" includes and the optional user-defined 'g:syntastic_c_include_dirs'
|
||||
function! s:_getIncludeDirs(filetype) " {{{2
|
||||
function! s:_get_include_dirs(filetype) " {{{2
|
||||
let include_dirs = []
|
||||
|
||||
if a:filetype =~# '\v^%(c|cpp|objc|objcpp)$' &&
|
||||
@ -195,7 +262,7 @@ endfunction " }}}2
|
||||
|
||||
" search the first 100 lines for include statements that are
|
||||
" given in the handlers dictionary
|
||||
function! s:_searchHeaders() " {{{2
|
||||
function! s:_search_headers() " {{{2
|
||||
let includes = ''
|
||||
let files = []
|
||||
let found = []
|
||||
@ -250,69 +317,6 @@ function! s:_searchHeaders() " {{{2
|
||||
return includes
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find library with 'pkg-config'
|
||||
" search possible libraries from first to last given
|
||||
" argument until one is found
|
||||
function! s:_check_pkg(name, ...) " {{{2
|
||||
if executable('pkg-config')
|
||||
if !has_key(s:cflags, a:name)
|
||||
for pkg in a:000
|
||||
let pkg_flags = system('pkg-config --cflags ' . pkg)
|
||||
" since we cannot necessarily trust the pkg-config exit code
|
||||
" we have to check for an error output as well
|
||||
if v:shell_error == 0 && pkg_flags !~? 'not found'
|
||||
let pkg_flags = ' ' . substitute(pkg_flags, "\n", '', '')
|
||||
let s:cflags[a:name] = pkg_flags
|
||||
return pkg_flags
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
return s:cflags[a:name]
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find PHP includes with 'php-config'
|
||||
function! s:_check_php() " {{{2
|
||||
if executable('php-config')
|
||||
if !has_key(s:cflags, 'php')
|
||||
let s:cflags['php'] = system('php-config --includes')
|
||||
let s:cflags['php'] = ' ' . substitute(s:cflags['php'], "\n", '', '')
|
||||
endif
|
||||
return s:cflags['php']
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find the ruby headers with 'rbconfig'
|
||||
function! s:_check_ruby() " {{{2
|
||||
if executable('ruby')
|
||||
if !has_key(s:cflags, 'ruby')
|
||||
let s:cflags['ruby'] = system('ruby -r rbconfig -e ' .
|
||||
\ '''puts RbConfig::CONFIG["rubyhdrdir"] || RbConfig::CONFIG["archdir"]''')
|
||||
let s:cflags['ruby'] = substitute(s:cflags['ruby'], "\n", '', '')
|
||||
let s:cflags['ruby'] = ' -I' . s:cflags['ruby']
|
||||
endif
|
||||
return s:cflags['ruby']
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find the python headers with distutils
|
||||
function! s:_check_python() " {{{2
|
||||
if executable('python')
|
||||
if !has_key(s:cflags, 'python')
|
||||
let s:cflags['python'] = system('python -c ''from distutils import ' .
|
||||
\ 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''')
|
||||
let s:cflags['python'] = substitute(s:cflags['python'], "\n", '', '')
|
||||
let s:cflags['python'] = ' -I' . s:cflags['python']
|
||||
endif
|
||||
return s:cflags['python']
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" default include directories
|
||||
|
@ -61,11 +61,11 @@ endfunction " }}}2
|
||||
" @vimlint(EVL102, 0, l:OLD_VAR)
|
||||
|
||||
function! syntastic#log#debug(level, msg, ...) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
if !s:_isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
||||
let leader = s:_logTimestamp()
|
||||
let leader = s:_log_timestamp()
|
||||
call s:_logRedirect(1)
|
||||
|
||||
if a:0 > 0
|
||||
@ -81,11 +81,11 @@ function! syntastic#log#debug(level, msg, ...) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debugShowOptions(level, names) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
if !s:_isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
||||
let leader = s:_logTimestamp()
|
||||
let leader = s:_log_timestamp()
|
||||
call s:_logRedirect(1)
|
||||
|
||||
let vlist = copy(type(a:names) == type("") ? [a:names] : a:names)
|
||||
@ -97,16 +97,16 @@ function! syntastic#log#debugShowOptions(level, names) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debugShowVariables(level, names) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
if !s:_isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
||||
let leader = s:_logTimestamp()
|
||||
let leader = s:_log_timestamp()
|
||||
call s:_logRedirect(1)
|
||||
|
||||
let vlist = type(a:names) == type("") ? [a:names] : a:names
|
||||
for name in vlist
|
||||
let msg = s:_formatVariable(name)
|
||||
let msg = s:_format_variable(name)
|
||||
if msg != ''
|
||||
echomsg leader . msg
|
||||
endif
|
||||
@ -116,7 +116,7 @@ function! syntastic#log#debugShowVariables(level, names) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debugDump(level) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
if !s:_isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
||||
@ -136,8 +136,8 @@ function! s:_isDebugEnabled_dumb(level) " {{{2
|
||||
return (g:syntastic_debug / a:level) % 2
|
||||
endfunction " }}}2
|
||||
|
||||
let s:isDebugEnabled = function(exists('*and') ? 's:_isDebugEnabled_smart' : 's:_isDebugEnabled_dumb')
|
||||
lockvar s:isDebugEnabled
|
||||
let s:_isDebugEnabled = function(exists('*and') ? 's:_isDebugEnabled_smart' : 's:_isDebugEnabled_dumb')
|
||||
lockvar s:_isDebugEnabled
|
||||
|
||||
function! s:_logRedirect(on) " {{{2
|
||||
if exists("g:syntastic_debug_file")
|
||||
@ -154,11 +154,15 @@ function! s:_logRedirect(on) " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_logTimestamp() " {{{2
|
||||
" }}}1
|
||||
|
||||
" Utilities {{{1
|
||||
|
||||
function! s:_log_timestamp() " {{{2
|
||||
return 'syntastic: ' . split(reltimestr(reltime(g:_SYNTASTIC_START)))[0] . ': '
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_formatVariable(name) " {{{2
|
||||
function! s:_format_variable(name) " {{{2
|
||||
let vals = []
|
||||
if exists('g:syntastic_' . a:name)
|
||||
call add(vals, 'g:syntastic_' . a:name . ' = ' . strtrans(string(g:syntastic_{a:name})))
|
||||
|
@ -141,14 +141,14 @@ endfunction " }}}2
|
||||
|
||||
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
|
||||
" and hope for the best :)
|
||||
let s:width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
|
||||
lockvar s:width
|
||||
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
|
||||
lockvar s:_width
|
||||
|
||||
function! syntastic#util#screenWidth(str, tabstop) " {{{2
|
||||
let chunks = split(a:str, "\t", 1)
|
||||
let width = s:width(chunks[-1])
|
||||
let width = s:_width(chunks[-1])
|
||||
for c in chunks[:-2]
|
||||
let cwidth = s:width(c)
|
||||
let cwidth = s:_width(c)
|
||||
let width += cwidth + a:tabstop - cwidth % a:tabstop
|
||||
endfor
|
||||
return width
|
||||
@ -166,7 +166,7 @@ function! syntastic#util#wideMsg(msg) " {{{2
|
||||
"convert tabs to spaces so that the tabs count towards the window
|
||||
"width as the proper amount of characters
|
||||
let chunks = split(msg, "\t", 1)
|
||||
let msg = join(map(chunks[:-2], 'v:val . repeat(" ", &tabstop - s:width(v:val) % &tabstop)'), '') . chunks[-1]
|
||||
let msg = join(map(chunks[:-2], 'v:val . repeat(" ", &tabstop - s:_width(v:val) % &tabstop)'), '') . chunks[-1]
|
||||
let msg = strpart(msg, 0, &columns - 1)
|
||||
|
||||
set noruler noshowcmd
|
||||
|
@ -154,7 +154,7 @@ let s:modemap = g:SyntasticModeMap.Instance()
|
||||
" @vimlint(EVL103, 1, a:argLead)
|
||||
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) " {{{2
|
||||
let checker_names = []
|
||||
for ft in s:resolveFiletypes()
|
||||
for ft in s:_resolve_filetypes()
|
||||
call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft))
|
||||
endfor
|
||||
return join(checker_names, "\n")
|
||||
@ -181,8 +181,8 @@ command! -nargs=* -complete=custom,s:CompleteCheckerName SyntasticCheck
|
||||
command! Errors call s:ShowLocList()
|
||||
command! -nargs=? -complete=custom,s:CompleteFiletypes SyntasticInfo
|
||||
\ call s:modemap.modeInfo(<f-args>) <bar>
|
||||
\ call s:registry.echoInfoFor(s:resolveFiletypes(<f-args>)) <bar>
|
||||
\ call s:explainSkip(<f-args>)
|
||||
\ call s:registry.echoInfoFor(s:_resolve_filetypes(<f-args>)) <bar>
|
||||
\ call s:_explain_skip(<f-args>)
|
||||
command! SyntasticReset
|
||||
\ call s:ClearCache() <bar>
|
||||
\ call s:notifiers.refresh(g:SyntasticLoclist.New([]))
|
||||
@ -256,7 +256,7 @@ function! s:UpdateErrors(auto_invoked, ...) " {{{2
|
||||
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'UpdateErrors' . (a:auto_invoked ? ' (auto)' : '') .
|
||||
\ ': ' . (a:0 ? join(a:000) : 'default checkers'))
|
||||
if s:skipFile()
|
||||
if s:_skip_file()
|
||||
return
|
||||
endif
|
||||
|
||||
@ -312,13 +312,13 @@ function! s:CacheErrors(checker_names) " {{{2
|
||||
call s:ClearCache()
|
||||
let newLoclist = g:SyntasticLoclist.New([])
|
||||
|
||||
if !s:skipFile()
|
||||
if !s:_skip_file()
|
||||
" debug logging {{{3
|
||||
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors')
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . getcwd())
|
||||
" }}}3
|
||||
|
||||
let filetypes = s:resolveFiletypes()
|
||||
let filetypes = s:_resolve_filetypes()
|
||||
let aggregate_errors = syntastic#util#var('aggregate_errors') || len(filetypes) > 1
|
||||
let decorate_errors = aggregate_errors && syntastic#util#var('id_checkers')
|
||||
let sort_aggregated_errors = aggregate_errors && syntastic#util#var('sort_aggregated_errors')
|
||||
@ -440,7 +440,7 @@ function! SyntasticMake(options) " {{{2
|
||||
let old_lc_all = $LC_ALL
|
||||
" }}}3
|
||||
|
||||
call s:bashHack()
|
||||
call s:_bash_hack()
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &errorformat = a:options['errorformat']
|
||||
@ -519,7 +519,7 @@ function! SyntasticMake(options) " {{{2
|
||||
let &shellredir = old_shellredir
|
||||
" }}}3
|
||||
|
||||
if !s:_running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD")
|
||||
if !s:_running_windows && (s:_os_name() =~ "FreeBSD" || s:_os_name() =~ "OpenBSD")
|
||||
call syntastic#util#redraw(g:syntastic_full_redraws)
|
||||
endif
|
||||
|
||||
@ -530,12 +530,12 @@ function! SyntasticMake(options) " {{{2
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'raw loclist:', errors)
|
||||
|
||||
if has_key(a:options, 'defaults')
|
||||
call s:addToErrors(errors, a:options['defaults'])
|
||||
call s:_add_to_errors(errors, a:options['defaults'])
|
||||
endif
|
||||
|
||||
" Add subtype info if present.
|
||||
if has_key(a:options, 'subtype')
|
||||
call s:addToErrors(errors, { 'subtype': a:options['subtype'] })
|
||||
call s:_add_to_errors(errors, { 'subtype': a:options['subtype'] })
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'Postprocess') && !empty(a:options['Postprocess'])
|
||||
@ -566,12 +566,12 @@ endfunction " }}}2
|
||||
|
||||
" Utilities {{{1
|
||||
|
||||
function! s:resolveFiletypes(...) " {{{2
|
||||
function! s:_resolve_filetypes(...) " {{{2
|
||||
let type = a:0 ? a:1 : &filetype
|
||||
return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:ignoreFile(filename) " {{{2
|
||||
function! s:_ignore_file(filename) " {{{2
|
||||
let fname = fnamemodify(a:filename, ':p')
|
||||
for pattern in g:syntastic_ignore_files
|
||||
if fname =~# pattern
|
||||
@ -582,20 +582,20 @@ function! s:ignoreFile(filename) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
" Skip running in special buffers
|
||||
function! s:skipFile() " {{{2
|
||||
function! s:_skip_file() " {{{2
|
||||
let fname = expand('%')
|
||||
let skip = get(b:, 'syntastic_skip_checks', 0) || (&buftype != '') ||
|
||||
\ !filereadable(fname) || getwinvar(0, '&diff') || s:ignoreFile(fname) ||
|
||||
\ !filereadable(fname) || getwinvar(0, '&diff') || s:_ignore_file(fname) ||
|
||||
\ fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions
|
||||
if skip
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'skipFile: skipping')
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '_skip_file: skipping checks')
|
||||
endif
|
||||
return skip
|
||||
endfunction " }}}2
|
||||
|
||||
" Explain why checks will be skipped for the current file
|
||||
function! s:explainSkip(...) " {{{2
|
||||
if !a:0 && s:skipFile()
|
||||
function! s:_explain_skip(...) " {{{2
|
||||
if !a:0 && s:_skip_file()
|
||||
let why = []
|
||||
let fname = expand('%')
|
||||
|
||||
@ -611,7 +611,7 @@ function! s:explainSkip(...) " {{{2
|
||||
if getwinvar(0, '&diff')
|
||||
call add(why, 'diff mode')
|
||||
endif
|
||||
if s:ignoreFile(fname)
|
||||
if s:_ignore_file(fname)
|
||||
call add(why, 'filename matching g:syntastic_ignore_files')
|
||||
endif
|
||||
if fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions
|
||||
@ -623,7 +623,7 @@ function! s:explainSkip(...) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
" Take a list of errors and add default values to them from a:options
|
||||
function! s:addToErrors(errors, options) " {{{2
|
||||
function! s:_add_to_errors(errors, options) " {{{2
|
||||
for err in a:errors
|
||||
for key in keys(a:options)
|
||||
if !has_key(err, key) || empty(err[key])
|
||||
@ -638,12 +638,12 @@ endfunction " }}}2
|
||||
" XXX: Is this still needed?
|
||||
" The script changes &shellredir to stop the screen
|
||||
" flicking when shelling out to syntax checkers.
|
||||
function! s:bashHack() " {{{2
|
||||
function! s:_bash_hack() " {{{2
|
||||
if g:syntastic_bash_hack
|
||||
if !exists('s:shell_is_bash')
|
||||
let s:shell_is_bash =
|
||||
\ !s:_running_windows &&
|
||||
\ (s:uname() !~# "FreeBSD") && (s:uname() !~# "OpenBSD") &&
|
||||
\ (s:_os_name() !~# "FreeBSD") && (s:_os_name() !~# "OpenBSD") &&
|
||||
\ &shell =~# '\m\<bash$'
|
||||
endif
|
||||
|
||||
@ -653,7 +653,7 @@ function! s:bashHack() " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:uname() " {{{2
|
||||
function! s:_os_name() " {{{2
|
||||
if !exists('s:_uname')
|
||||
let s:_uname = system('uname')
|
||||
lockvar s:_uname
|
||||
|
@ -30,7 +30,7 @@ function! g:SyntasticChecker.New(args) " {{{2
|
||||
if exists('*' . prefix . 'IsAvailable')
|
||||
let newObj._isAvailableFunc = function(prefix . 'IsAvailable')
|
||||
else
|
||||
let newObj._isAvailableFunc = function('SyntasticCheckerIsAvailableDefault')
|
||||
let newObj._isAvailableFunc = function('s:_isAvailableDefault')
|
||||
endif
|
||||
|
||||
if exists('*' . prefix . 'GetHighlightRegex')
|
||||
@ -181,9 +181,9 @@ endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Non-method functions {{{1
|
||||
" Private functions {{{1
|
||||
|
||||
function! SyntasticCheckerIsAvailableDefault() dict " {{{2
|
||||
function! s:_isAvailableDefault() dict " {{{2
|
||||
return executable(self.getExec())
|
||||
endfunction " }}}2
|
||||
|
||||
|
@ -38,7 +38,7 @@ endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
" Private functions {{{1
|
||||
|
||||
function! SyntasticRefreshCursor() " {{{2
|
||||
if !exists('b:syntastic_messages') || empty(b:syntastic_messages)
|
||||
@ -62,14 +62,14 @@ function! SyntasticRefreshCursor() " {{{2
|
||||
let b:syntastic_idx = -1
|
||||
endif
|
||||
|
||||
if s:_isSameIndex(l, b:syntastic_line, c, b:syntastic_idx, current_messages)
|
||||
if s:_is_same_index(l, b:syntastic_line, c, b:syntastic_idx, current_messages)
|
||||
return
|
||||
else
|
||||
let b:syntastic_line = l
|
||||
endif
|
||||
|
||||
if !empty(current_messages)
|
||||
let b:syntastic_idx = s:_findIndex(c, current_messages)
|
||||
let b:syntastic_idx = s:_find_index(c, current_messages)
|
||||
call syntastic#util#wideMsg(current_messages[b:syntastic_idx].text)
|
||||
else
|
||||
let b:syntastic_idx = -1
|
||||
@ -91,9 +91,9 @@ endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
" Utilities {{{1
|
||||
|
||||
function! s:_isSameIndex(line, old_line, column, idx, messages) " {{{2
|
||||
function! s:_is_same_index(line, old_line, column, idx, messages) " {{{2
|
||||
if a:old_line >= 0 && a:line == a:old_line && a:idx >= 0
|
||||
if len(a:messages) <= 1
|
||||
return 1
|
||||
@ -113,7 +113,7 @@ function! s:_isSameIndex(line, old_line, column, idx, messages) " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_findIndex(column, messages) " {{{2
|
||||
function! s:_find_index(column, messages) " {{{2
|
||||
let max = len(a:messages) - 1
|
||||
if max == 0
|
||||
return 0
|
||||
|
@ -43,10 +43,10 @@ endfunction " }}}2
|
||||
function! g:SyntasticLoclist.sort() " {{{2
|
||||
if !self._sorted
|
||||
for e in self._rawLoclist
|
||||
call s:_setScreenColumn(e)
|
||||
call s:_set_screen_column(e)
|
||||
endfor
|
||||
|
||||
call sort(self._rawLoclist, self._columns ? 's:_compareErrorItemsByColumns' : 's:_compareErrorItemsByLines')
|
||||
call sort(self._rawLoclist, self._columns ? 's:_compare_error_items_by_columns' : 's:_compare_error_items_by_lines')
|
||||
|
||||
let self._sorted = 1
|
||||
endif
|
||||
@ -243,9 +243,9 @@ function! g:SyntasticLoclist.messages(buf) " {{{2
|
||||
for l in keys(self._cachedMessages[b])
|
||||
if len(self._cachedMessages[b][l]) > 1
|
||||
for e in self._cachedMessages[b][l]
|
||||
call s:_setScreenColumn(e)
|
||||
call s:_set_screen_column(e)
|
||||
endfor
|
||||
call sort(self._cachedMessages[b][l], 's:_compareErrorItemsByColumns')
|
||||
call sort(self._cachedMessages[b][l], 's:_compare_error_items_by_columns')
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
@ -253,7 +253,7 @@ function! g:SyntasticLoclist.messages(buf) " {{{2
|
||||
|
||||
for b in keys(self._cachedMessages)
|
||||
for l in keys(self._cachedMessages[b])
|
||||
call s:_removeShadowedItems(self._cachedMessages[b][l])
|
||||
call s:_remove_shadowed_items(self._cachedMessages[b][l])
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
@ -320,7 +320,7 @@ endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Non-method functions {{{1
|
||||
" Public functions {{{1
|
||||
|
||||
function! SyntasticLoclistHide() " {{{2
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: hide')
|
||||
@ -329,13 +329,13 @@ endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
" Utilities {{{1
|
||||
|
||||
function! s:_translate(key, val) " {{{2
|
||||
return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val)
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_setScreenColumn(item) " {{{2
|
||||
function! s:_set_screen_column(item) " {{{2
|
||||
if !has_key(a:item, 'scol')
|
||||
let col = get(a:item, 'col', 0)
|
||||
if col != 0 && get(a:item, 'vcol', 0) == 0
|
||||
@ -352,7 +352,7 @@ function! s:_setScreenColumn(item) " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_removeShadowedItems(errors) " {{{2
|
||||
function! s:_remove_shadowed_items(errors) " {{{2
|
||||
" keep only the first message at a given column
|
||||
let i = 0
|
||||
while i < len(a:errors) - 1
|
||||
@ -384,7 +384,7 @@ function! s:_removeShadowedItems(errors) " {{{2
|
||||
endwhile
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_compareErrorItemsByColumns(a, b) " {{{2
|
||||
function! s:_compare_error_items_by_columns(a, b) " {{{2
|
||||
if a:a['bufnr'] != a:b['bufnr']
|
||||
" group by file
|
||||
return a:a['bufnr'] - a:b['bufnr']
|
||||
@ -402,7 +402,7 @@ function! s:_compareErrorItemsByColumns(a, b) " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:_compareErrorItemsByLines(a, b) " {{{2
|
||||
function! s:_compare_error_items_by_lines(a, b) " {{{2
|
||||
if a:a['bufnr'] != a:b['bufnr']
|
||||
" group by file
|
||||
return a:a['bufnr'] - a:b['bufnr']
|
||||
|
@ -138,7 +138,7 @@ endfunction " }}}2
|
||||
" not checked for availability (that is, the corresponding IsAvailable() are
|
||||
" not run).
|
||||
function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) " {{{2
|
||||
let ft = s:_normaliseFiletype(a:ftalias)
|
||||
let ft = s:_normalise_filetype(a:ftalias)
|
||||
call self._loadCheckersFor(ft)
|
||||
|
||||
let checkers_map = self._checkerMap[ft]
|
||||
@ -181,13 +181,13 @@ function! g:SyntasticRegistry.getKnownFiletypes() " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) " {{{2
|
||||
let ft = s:_normaliseFiletype(a:ftalias)
|
||||
let ft = s:_normalise_filetype(a:ftalias)
|
||||
call self._loadCheckersFor(ft)
|
||||
return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' ))
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) " {{{2
|
||||
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normaliseFiletype(v:val)' ))
|
||||
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normalise_filetype(v:val)' ))
|
||||
if len(ft_list) != 1
|
||||
let available = []
|
||||
let active = []
|
||||
@ -257,11 +257,11 @@ endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
" Utilities {{{1
|
||||
|
||||
"resolve filetype aliases, and replace - with _ otherwise we cant name
|
||||
"syntax checker functions legally for filetypes like "gentoo-metadata"
|
||||
function! s:_normaliseFiletype(ftalias) " {{{2
|
||||
function! s:_normalise_filetype(ftalias) " {{{2
|
||||
let ft = get(s:_DEFAULT_FILETYPE_MAP, a:ftalias, a:ftalias)
|
||||
let ft = get(g:syntastic_filetype_map, ft, ft)
|
||||
let ft = substitute(ft, '\m-', '_', 'g')
|
||||
|
Loading…
x
Reference in New Issue
Block a user