Added vim-commentary and updarted the plugins.
commentary: Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion (for example, `gcap` to comment out a paragraph), and `gc` in visual mode to comment out the selection. That's it.
This commit is contained in:
parent
8c9210dca4
commit
0d8e7370bd
56 changed files with 1330 additions and 873 deletions
|
@ -80,6 +80,7 @@ I recommend reading the docs of these plugins to understand them better. Each of
|
|||
* [vim-fugitive](https://github.com/tpope/vim-fugitive): A Git wrapper so awesome, it should be illegal
|
||||
* [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2):
|
||||
Remove all clutter and focus only on the essential. Similar to iA Writer or Write Room [Read more here](http://amix.dk/blog/post/19744)
|
||||
* [vim-commentary](https://github.com/tpope/vim-commentary): Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion. `gcu` uncomments a set of adjacent commented lines.
|
||||
|
||||
|
||||
## Included color schemes
|
||||
|
|
|
@ -38,7 +38,7 @@ At the time of this writing, syntax checking plugins exist for ActionScript,
|
|||
Ada, AppleScript, AsciiDoc, ASM, BEMHTML, Bourne shell, C, C++, C#, Chef,
|
||||
CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dust, Elixir,
|
||||
Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe,
|
||||
Handlebars, HSS, HTML, Java, JavaScript, JSON, LESS, Lex, Limbo, LISP,
|
||||
Handlebars, HSS, HTML, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo, LISP,
|
||||
LLVM intermediate language, Lua, MATLAB, NASM, Objective-C, Objective-C++,
|
||||
OCaml, Perl, Perl POD, PHP, gettext Portable Object, Puppet, Python, Racket,
|
||||
reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX, Texinfo, Twig,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_c_autoload")
|
||||
if exists("g:loaded_syntastic_c_autoload") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_autoload = 1
|
||||
|
@ -10,14 +10,14 @@ set cpo&vim
|
|||
|
||||
" convenience function to determine the 'null device' parameter
|
||||
" based on the current operating system
|
||||
function! syntastic#c#NullOutput()
|
||||
function! syntastic#c#NullOutput() " {{{2
|
||||
let known_os = has('unix') || has('mac') || syntastic#util#isRunningWindows()
|
||||
return known_os ? '-o ' . syntastic#util#DevNull() : ''
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" read additional compiler flags from the given configuration file
|
||||
" the file format and its parsing mechanism is inspired by clang_complete
|
||||
function! syntastic#c#ReadConfig(file)
|
||||
function! syntastic#c#ReadConfig(file) " {{{2
|
||||
" search in the current file's directory upwards
|
||||
let config = findfile(a:file, '.;')
|
||||
if config == '' || !filereadable(config)
|
||||
|
@ -30,7 +30,7 @@ function! syntastic#c#ReadConfig(file)
|
|||
" try to read config file
|
||||
try
|
||||
let lines = readfile(config)
|
||||
catch /^Vim\%((\a\+)\)\=:E48[45]/
|
||||
catch /\m^Vim\%((\a\+)\)\=:E48[45]/
|
||||
return ''
|
||||
endtry
|
||||
|
||||
|
@ -57,12 +57,12 @@ function! syntastic#c#ReadConfig(file)
|
|||
endfor
|
||||
|
||||
return join(map(parameters, 'syntastic#util#shescape(v:val)'))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" GetLocList() for C-like compilers
|
||||
function! syntastic#c#GetLocList(filetype, subchecker, options)
|
||||
function! syntastic#c#GetLocList(filetype, subchecker, options) " {{{2
|
||||
try
|
||||
let flags = s:GetCflags(a:filetype, a:subchecker, a:options)
|
||||
let flags = s:getCflags(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)
|
|||
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:getCheckerVar('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:getCheckerVar('g', a:filetype, a:subchecker, 'remove_include_errors', 0) ?
|
||||
\ ['filterForeignErrors'] : []
|
||||
|
||||
" process makeprg
|
||||
|
@ -80,34 +80,45 @@ function! syntastic#c#GetLocList(filetype, subchecker, options)
|
|||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'postprocess': postprocess })
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
" initialize c/cpp syntax checker handlers
|
||||
function! s:Init()
|
||||
function! s:init() " {{{2
|
||||
let s:handlers = []
|
||||
let s:cflags = {}
|
||||
|
||||
call s:RegHandler('\m\<cairo', 'syntastic#c#CheckPKG', ['cairo', 'cairo'])
|
||||
call s:RegHandler('\m\<freetype', 'syntastic#c#CheckPKG', ['freetype', 'freetype2', 'freetype'])
|
||||
call s:RegHandler('\m\<glade', 'syntastic#c#CheckPKG', ['glade', 'libglade-2.0', 'libglade'])
|
||||
call s:RegHandler('\m\<glib', 'syntastic#c#CheckPKG', ['glib', 'glib-2.0', 'glib'])
|
||||
call s:RegHandler('\m\<gtk', 'syntastic#c#CheckPKG', ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
|
||||
call s:RegHandler('\m\<libsoup', 'syntastic#c#CheckPKG', ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
|
||||
call s:RegHandler('\m\<libxml', 'syntastic#c#CheckPKG', ['libxml', 'libxml-2.0', 'libxml'])
|
||||
call s:RegHandler('\m\<pango', 'syntastic#c#CheckPKG', ['pango', 'pango'])
|
||||
call s:RegHandler('\m\<SDL', 'syntastic#c#CheckPKG', ['sdl', 'sdl'])
|
||||
call s:RegHandler('\m\<opengl', 'syntastic#c#CheckPKG', ['opengl', 'gl'])
|
||||
call s:RegHandler('\m\<webkit', 'syntastic#c#CheckPKG', ['webkit', 'webkit-1.0'])
|
||||
call s:regHandler('\m\<cairo', 'syntastic#c#checkPKG', ['cairo', 'cairo'])
|
||||
call s:regHandler('\m\<freetype', 'syntastic#c#checkPKG', ['freetype', 'freetype2', 'freetype'])
|
||||
call s:regHandler('\m\<glade', 'syntastic#c#checkPKG', ['glade', 'libglade-2.0', 'libglade'])
|
||||
call s:regHandler('\m\<glib', 'syntastic#c#checkPKG', ['glib', 'glib-2.0', 'glib'])
|
||||
call s:regHandler('\m\<gtk', 'syntastic#c#checkPKG', ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
|
||||
call s:regHandler('\m\<libsoup', 'syntastic#c#checkPKG', ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
|
||||
call s:regHandler('\m\<libxml', 'syntastic#c#checkPKG', ['libxml', 'libxml-2.0', 'libxml'])
|
||||
call s:regHandler('\m\<pango', 'syntastic#c#checkPKG', ['pango', 'pango'])
|
||||
call s:regHandler('\m\<SDL', 'syntastic#c#checkPKG', ['sdl', 'sdl'])
|
||||
call s:regHandler('\m\<opengl', 'syntastic#c#checkPKG', ['opengl', 'gl'])
|
||||
call s:regHandler('\m\<webkit', 'syntastic#c#checkPKG', ['webkit', 'webkit-1.0'])
|
||||
|
||||
call s:RegHandler('\m\<php\.h\>', 'syntastic#c#CheckPhp', [])
|
||||
call s:RegHandler('\m\<Python\.h\>', 'syntastic#c#CheckPython', [])
|
||||
call s:RegHandler('\m\<ruby', 'syntastic#c#CheckRuby', [])
|
||||
endfunction
|
||||
call s:regHandler('\m\<php\.h\>', 'syntastic#c#checkPHP', [])
|
||||
call s:regHandler('\m\<Python\.h\>', 'syntastic#c#checkPython', [])
|
||||
call s:regHandler('\m\<ruby', 'syntastic#c#checkRuby', [])
|
||||
endfunction " }}}2
|
||||
|
||||
" return a handler dictionary object
|
||||
function! s:regHandler(regex, function, args) " {{{2
|
||||
let handler = {}
|
||||
let handler["regex"] = a:regex
|
||||
let handler["func"] = function(a:function)
|
||||
let handler["args"] = a:args
|
||||
call add(s:handlers, handler)
|
||||
endfunction " }}}2
|
||||
|
||||
" resolve checker-related user variables
|
||||
function! s:GetCheckerVar(scope, filetype, subchecker, name, default)
|
||||
function! s:getCheckerVar(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}
|
||||
|
@ -116,13 +127,13 @@ function! s:GetCheckerVar(scope, filetype, subchecker, name, default)
|
|||
else
|
||||
return a:default
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" resolve user CFLAGS
|
||||
function! s:GetCflags(ft, ck, opts)
|
||||
function! s:getCflags(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:getCheckerVar('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
|
||||
|
@ -132,21 +143,21 @@ function! s:GetCflags(ft, ck, opts)
|
|||
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:getCheckerVar('g', a:ft, a:ck, 'compiler_options', '') . ' ' . s:getIncludeDirs(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:getCheckerVar('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:getCheckerVar('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:getCheckerVar('g', a:ft, a:ck, 'auto_refresh_includes', 0)
|
||||
let flags .= ' ' . s:searchHeaders()
|
||||
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:searchHeaders()
|
||||
endif
|
||||
let flags .= ' ' . b:syntastic_{a:ft}_includes
|
||||
endif
|
||||
|
@ -158,15 +169,15 @@ function! s:GetCflags(ft, ck, opts)
|
|||
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:getCheckerVar('g', a:ft, a:ck, 'config_file', '.syntastic_' . a:ft . '_config')
|
||||
let flags .= ' ' . syntastic#c#ReadConfig(config_file)
|
||||
|
||||
return flags
|
||||
endfunction
|
||||
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)
|
||||
function! s:getIncludeDirs(filetype) " {{{2
|
||||
let include_dirs = []
|
||||
|
||||
if a:filetype =~# '\v^%(c|cpp|d|objc|objcpp)$' &&
|
||||
|
@ -180,11 +191,11 @@ function! s:GetIncludeDirs(filetype)
|
|||
endif
|
||||
|
||||
return join(map(syntastic#util#unique(include_dirs), 'syntastic#util#shescape("-I" . v:val)'))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" search the first 100 lines for include statements that are
|
||||
" given in the handlers dictionary
|
||||
function! s:SearchHeaders()
|
||||
function! s:searchHeaders() " {{{2
|
||||
let includes = ''
|
||||
let files = []
|
||||
let found = []
|
||||
|
@ -214,7 +225,7 @@ function! s:SearchHeaders()
|
|||
|
||||
try
|
||||
let lines = readfile(filename, '', 100)
|
||||
catch /^Vim\%((\a\+)\)\=:E484/
|
||||
catch /\m^Vim\%((\a\+)\)\=:E484/
|
||||
continue
|
||||
endtry
|
||||
|
||||
|
@ -237,12 +248,12 @@ function! s:SearchHeaders()
|
|||
endfor
|
||||
|
||||
return includes
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find library with 'pkg-config'
|
||||
" search possible libraries from first to last given
|
||||
" argument until one is found
|
||||
function! syntastic#c#CheckPKG(name, ...)
|
||||
function! syntastic#c#checkPKG(name, ...) " {{{2
|
||||
if executable('pkg-config')
|
||||
if !has_key(s:cflags, a:name)
|
||||
for pkg in a:000
|
||||
|
@ -260,10 +271,10 @@ function! syntastic#c#CheckPKG(name, ...)
|
|||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find PHP includes with 'php-config'
|
||||
function! syntastic#c#CheckPhp()
|
||||
function! syntastic#c#checkPHP() " {{{2
|
||||
if executable('php-config')
|
||||
if !has_key(s:cflags, 'php')
|
||||
let s:cflags['php'] = system('php-config --includes')
|
||||
|
@ -272,10 +283,10 @@ function! syntastic#c#CheckPhp()
|
|||
return s:cflags['php']
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find the ruby headers with 'rbconfig'
|
||||
function! syntastic#c#CheckRuby()
|
||||
function! syntastic#c#checkRuby() " {{{2
|
||||
if executable('ruby')
|
||||
if !has_key(s:cflags, 'ruby')
|
||||
let s:cflags['ruby'] = system('ruby -r rbconfig -e ' .
|
||||
|
@ -286,10 +297,10 @@ function! syntastic#c#CheckRuby()
|
|||
return s:cflags['ruby']
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" try to find the python headers with distutils
|
||||
function! syntastic#c#CheckPython()
|
||||
function! syntastic#c#checkPython() " {{{2
|
||||
if executable('python')
|
||||
if !has_key(s:cflags, 'python')
|
||||
let s:cflags['python'] = system('python -c ''from distutils import ' .
|
||||
|
@ -300,16 +311,7 @@ function! syntastic#c#CheckPython()
|
|||
return s:cflags['python']
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" return a handler dictionary object
|
||||
function! s:RegHandler(regex, function, args)
|
||||
let handler = {}
|
||||
let handler["regex"] = a:regex
|
||||
let handler["func"] = function(a:function)
|
||||
let handler["args"] = a:args
|
||||
call add(s:handlers, handler)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
|
@ -322,9 +324,9 @@ let s:default_includes = [
|
|||
\ '..' . syntastic#util#Slash() . 'include',
|
||||
\ '..' . syntastic#util#Slash() . 'includes' ]
|
||||
|
||||
call s:Init()
|
||||
call s:init()
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4 fdm=marker:
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_log_autoload")
|
||||
if exists("g:loaded_syntastic_log_autoload") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_log_autoload = 1
|
||||
|
@ -6,67 +6,37 @@ let g:loaded_syntastic_log_autoload = 1
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists("g:syntastic_debug")
|
||||
let g:syntastic_debug = 0
|
||||
endif
|
||||
|
||||
let s:global_options = [
|
||||
\ 'syntastic_aggregate_errors',
|
||||
\ 'syntastic_always_populate_loc_list',
|
||||
\ 'syntastic_auto_jump',
|
||||
\ 'syntastic_auto_loc_list',
|
||||
\ 'syntastic_check_on_open',
|
||||
\ 'syntastic_check_on_wq',
|
||||
\ 'syntastic_debug',
|
||||
\ 'syntastic_echo_current_error',
|
||||
\ 'syntastic_enable_balloons',
|
||||
\ 'syntastic_enable_highlighting',
|
||||
\ 'syntastic_enable_signs',
|
||||
\ 'syntastic_error_symbol',
|
||||
\ 'syntastic_filetype_map',
|
||||
\ 'syntastic_full_redraws',
|
||||
\ 'syntastic_id_checkers',
|
||||
\ 'syntastic_ignore_files',
|
||||
\ 'syntastic_loc_list_height',
|
||||
\ 'syntastic_mode_map',
|
||||
\ 'syntastic_quiet_messages',
|
||||
\ 'syntastic_reuse_loc_lists',
|
||||
\ 'syntastic_stl_format',
|
||||
\ 'syntastic_style_error_symbol',
|
||||
\ 'syntastic_style_warning_symbol',
|
||||
\ 'syntastic_warning_symbol' ]
|
||||
|
||||
let s:deprecation_notices_issued = []
|
||||
|
||||
" Public functions {{{1
|
||||
|
||||
function! syntastic#log#info(msg)
|
||||
function! syntastic#log#info(msg) " {{{2
|
||||
echomsg "syntastic: info: " . a:msg
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#warn(msg)
|
||||
function! syntastic#log#warn(msg) " {{{2
|
||||
echohl WarningMsg
|
||||
echomsg "syntastic: warning: " . a:msg
|
||||
echohl None
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#error(msg)
|
||||
function! syntastic#log#error(msg) " {{{2
|
||||
execute "normal \<Esc>"
|
||||
echohl ErrorMsg
|
||||
echomsg "syntastic: error: " . a:msg
|
||||
echohl None
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#deprecationWarn(msg)
|
||||
function! syntastic#log#deprecationWarn(msg) " {{{2
|
||||
if index(s:deprecation_notices_issued, a:msg) >= 0
|
||||
return
|
||||
endif
|
||||
|
||||
call add(s:deprecation_notices_issued, a:msg)
|
||||
call syntastic#log#warn(a:msg)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debug(level, msg, ...)
|
||||
function! syntastic#log#debug(level, msg, ...) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
@ -84,9 +54,9 @@ function! syntastic#log#debug(level, msg, ...)
|
|||
endif
|
||||
|
||||
call s:logRedirect(0)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debugShowOptions(level, names)
|
||||
function! syntastic#log#debugShowOptions(level, names) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
@ -94,15 +64,15 @@ function! syntastic#log#debugShowOptions(level, names)
|
|||
let leader = s:logTimestamp()
|
||||
call s:logRedirect(1)
|
||||
|
||||
let vlist = type(a:names) == type("") ? [a:names] : a:names
|
||||
let vlist = copy(type(a:names) == type("") ? [a:names] : a:names)
|
||||
if !empty(vlist)
|
||||
call map(copy(vlist), "'&' . v:val . ' = ' . strtrans(string(eval('&' . v:val)))")
|
||||
call map(vlist, "'&' . v:val . ' = ' . strtrans(string(eval('&' . v:val)))")
|
||||
echomsg leader . join(vlist, ', ')
|
||||
endif
|
||||
call s:logRedirect(0)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debugShowVariables(level, names)
|
||||
function! syntastic#log#debugShowVariables(level, names) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
@ -112,39 +82,44 @@ function! syntastic#log#debugShowVariables(level, names)
|
|||
|
||||
let vlist = type(a:names) == type("") ? [a:names] : a:names
|
||||
for name in vlist
|
||||
echomsg leader . s:formatVariable(name)
|
||||
let msg = s:formatVariable(name)
|
||||
if msg != ''
|
||||
echomsg leader . msg
|
||||
endif
|
||||
endfor
|
||||
|
||||
call s:logRedirect(0)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#log#debugDump(level)
|
||||
function! syntastic#log#debugDump(level) " {{{2
|
||||
if !s:isDebugEnabled(a:level)
|
||||
return
|
||||
endif
|
||||
|
||||
call syntastic#log#debugShowVariables(a:level, s:global_options)
|
||||
endfunction
|
||||
call syntastic#log#debugShowVariables( a:level, sort(keys(g:syntastic_defaults)) )
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
function! s:isDebugEnabled_smart(level)
|
||||
function! s:isDebugEnabled_smart(level) " {{{2
|
||||
return and(g:syntastic_debug, a:level)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:isDebugEnabled_dumb(level)
|
||||
function! s:isDebugEnabled_dumb(level) " {{{2
|
||||
" poor man's bit test for bit N, assuming a:level == 2**N
|
||||
return (g:syntastic_debug / a:level) % 2
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
let s:isDebugEnabled = function(exists('*and') ? 's:isDebugEnabled_smart' : 's:isDebugEnabled_dumb')
|
||||
|
||||
function! s:logRedirect(on)
|
||||
function! s:logRedirect(on) " {{{2
|
||||
if exists("g:syntastic_debug_file")
|
||||
if a:on
|
||||
try
|
||||
execute 'redir >> ' . fnameescape(expand(g:syntastic_debug_file))
|
||||
catch /^Vim\%((\a\+)\)\=:/
|
||||
catch /\m^Vim\%((\a\+)\)\=:/
|
||||
silent! redir END
|
||||
unlet g:syntastic_debug_file
|
||||
endtry
|
||||
|
@ -152,30 +127,33 @@ function! s:logRedirect(on)
|
|||
silent! redir END
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:logTimestamp_smart()
|
||||
function! s:logTimestamp_smart() " {{{2
|
||||
return 'syntastic: ' . split(reltimestr(reltime(g:syntastic_start)))[0] . ': '
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:logTimestamp_dumb()
|
||||
function! s:logTimestamp_dumb() " {{{2
|
||||
return 'syntastic: debug: '
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
let s:logTimestamp = function(has('reltime') ? 's:logTimestamp_smart' : 's:logTimestamp_dumb')
|
||||
|
||||
function! s:formatVariable(name)
|
||||
function! s:formatVariable(name) " {{{2
|
||||
let vals = []
|
||||
if exists('g:' . a:name)
|
||||
call add(vals, 'g:' . a:name . ' = ' . strtrans(string(g:{a:name})))
|
||||
if exists('g:syntastic_' . a:name)
|
||||
call add(vals, 'g:syntastic_' . a:name . ' = ' . strtrans(string(g:syntastic_{a:name})))
|
||||
endif
|
||||
if exists('b:' . a:name)
|
||||
call add(vals, 'b:' . a:name . ' = ' . strtrans(string(b:{a:name})))
|
||||
if exists('b:syntastic_' . a:name)
|
||||
call add(vals, 'b:syntastic_' . a:name . ' = ' . strtrans(string(b:syntastic_{a:name})))
|
||||
endif
|
||||
|
||||
return join(vals, ', ')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: set et sts=4 sw=4 fdm=marker:
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_postprocess_autoload")
|
||||
if exists("g:loaded_syntastic_postprocess_autoload") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_postprocess_autoload = 1
|
||||
|
@ -6,7 +6,9 @@ let g:loaded_syntastic_postprocess_autoload = 1
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! s:compareErrorItems(a, b)
|
||||
" Public functions {{{1
|
||||
|
||||
function! s:compareErrorItems(a, b) " {{{2
|
||||
if a:a['bufnr'] != a:b['bufnr']
|
||||
" group by files
|
||||
return a:a['bufnr'] - a:b['bufnr']
|
||||
|
@ -18,15 +20,15 @@ function! s:compareErrorItems(a, b)
|
|||
else
|
||||
return get(a:a, 'col', 0) - get(a:b, 'col', 0)
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" natural sort
|
||||
function! syntastic#postprocess#sort(errors)
|
||||
function! syntastic#postprocess#sort(errors) " {{{2
|
||||
return sort(copy(a:errors), 's:compareErrorItems')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" merge consecutive blanks
|
||||
function! syntastic#postprocess#compressWhitespace(errors)
|
||||
function! syntastic#postprocess#compressWhitespace(errors) " {{{2
|
||||
for e in a:errors
|
||||
let e['text'] = substitute(e['text'], "\001", '', 'g')
|
||||
let e['text'] = substitute(e['text'], '\n', ' ', 'g')
|
||||
|
@ -34,10 +36,10 @@ function! syntastic#postprocess#compressWhitespace(errors)
|
|||
endfor
|
||||
|
||||
return a:errors
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" remove spurious CR under Cygwin
|
||||
function! syntastic#postprocess#cygwinRemoveCR(errors)
|
||||
function! syntastic#postprocess#cygwinRemoveCR(errors) " {{{2
|
||||
if has('win32unix')
|
||||
for e in a:errors
|
||||
let e['text'] = substitute(e['text'], '\r', '', 'g')
|
||||
|
@ -45,23 +47,25 @@ function! syntastic#postprocess#cygwinRemoveCR(errors)
|
|||
endif
|
||||
|
||||
return a:errors
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" decode XML entities
|
||||
function! syntastic#postprocess#decodeXMLEntities(errors)
|
||||
function! syntastic#postprocess#decodeXMLEntities(errors) " {{{2
|
||||
for e in a:errors
|
||||
let e['text'] = syntastic#util#decodeXMLEntities(e['text'])
|
||||
endfor
|
||||
|
||||
return a:errors
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" filter out errors referencing other files
|
||||
function! syntastic#postprocess#filterForeignErrors(errors)
|
||||
function! syntastic#postprocess#filterForeignErrors(errors) " {{{2
|
||||
return filter(copy(a:errors), 'get(v:val, "bufnr") == ' . bufnr(''))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
if exists("g:loaded_syntastic_preprocess_autoload") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_preprocess_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Public functions {{{1
|
||||
|
||||
function! syntastic#preprocess#checkstyle(errors) " {{{2
|
||||
let out = []
|
||||
let fname = expand('%')
|
||||
for err in a:errors
|
||||
if match(err, '\m<error\>') > -1
|
||||
let line = str2nr(matchstr(err, '\m\<line="\zs\d\+\ze"'))
|
||||
if line == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let col = str2nr(matchstr(err, '\m\<column="\zs\d\+\ze"'))
|
||||
|
||||
let type = matchstr(err, '\m\<severity="\zs.\ze')
|
||||
if type !~? '^[EW]'
|
||||
let type = 'E'
|
||||
endif
|
||||
|
||||
let message = syntastic#util#decodeXMLEntities(matchstr(err, '\m\<message="\zs[^"]\+\ze"'))
|
||||
|
||||
call add(out, join([fname, type, line, col, message], ':'))
|
||||
elseif match(err, '\m<file name="') > -1
|
||||
let fname = syntastic#util#decodeXMLEntities(matchstr(err, '\v\<file name\="\zs[^"]+\ze"'))
|
||||
endif
|
||||
endfor
|
||||
return out
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#preprocess#cppcheck(errors) " {{{2
|
||||
return map(copy(a:errors), 'substitute(v:val, ''\v^\[[^]]+\]\zs( -\> \[[^]]+\])+\ze:'', "", "")')
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#preprocess#killEmpty(errors) " {{{2
|
||||
return filter(copy(a:errors), 'v:val != ""')
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#preprocess#perl(errors) " {{{2
|
||||
let out = []
|
||||
|
||||
for e in a:errors
|
||||
let parts = matchlist(e, '\v^(.*)\sat\s(.*)\sline\s(\d+)(.*)$')
|
||||
if !empty(parts)
|
||||
call add(out, parts[2] . ':' . parts[3] . ':' . parts[1] . parts[4])
|
||||
endif
|
||||
endfor
|
||||
|
||||
return syntastic#util#unique(out)
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#preprocess#validator(errors) " {{{2
|
||||
let out = []
|
||||
for e in a:errors
|
||||
let parts = matchlist(e, '\v^"([^"]+)"(.+)')
|
||||
if len(parts) >= 3
|
||||
" URL decode, except leave alone any "+"
|
||||
let parts[1] = substitute(parts[1], '\m%\(\x\x\)', '\=nr2char("0x".submatch(1))', 'g')
|
||||
let parts[1] = substitute(parts[1], '\m\\"', '"', 'g')
|
||||
let parts[1] = substitute(parts[1], '\m\\\\', '\\', 'g')
|
||||
call add(out, '"' . parts[1] . '"' . parts[2])
|
||||
endif
|
||||
endfor
|
||||
return out
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,4 +1,4 @@
|
|||
if exists('g:loaded_syntastic_util_autoload')
|
||||
if exists('g:loaded_syntastic_util_autoload') || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_util_autoload = 1
|
||||
|
@ -6,27 +6,23 @@ let g:loaded_syntastic_util_autoload = 1
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" 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')
|
||||
|
||||
" Public functions {{{1
|
||||
|
||||
function! syntastic#util#isRunningWindows()
|
||||
function! syntastic#util#isRunningWindows() " {{{2
|
||||
return has('win16') || has('win32') || has('win64')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#util#DevNull()
|
||||
function! syntastic#util#DevNull() " {{{2
|
||||
if syntastic#util#isRunningWindows()
|
||||
return 'NUL'
|
||||
endif
|
||||
return '/dev/null'
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Get directory separator
|
||||
function! syntastic#util#Slash() abort
|
||||
function! syntastic#util#Slash() abort " {{{2
|
||||
return (!exists("+shellslash") || &shellslash) ? '/' : '\'
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"search the first 5 lines of the file for a magic number and return a map
|
||||
"containing the args and the executable
|
||||
|
@ -38,7 +34,7 @@ endfunction
|
|||
"returns
|
||||
"
|
||||
"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
|
||||
function! syntastic#util#parseShebang()
|
||||
function! syntastic#util#parseShebang() " {{{2
|
||||
for lnum in range(1,5)
|
||||
let line = getline(lnum)
|
||||
|
||||
|
@ -50,25 +46,26 @@ function! syntastic#util#parseShebang()
|
|||
endfor
|
||||
|
||||
return { 'exe': '', 'args': [] }
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Get the value of a variable. Allow local variables to override global ones.
|
||||
function! syntastic#util#var(name)
|
||||
function! syntastic#util#var(name, ...) " {{{2
|
||||
return
|
||||
\ exists('b:syntastic_' . a:name) ? b:syntastic_{a:name} :
|
||||
\ exists('g:syntastic_' . a:name) ? g:syntastic_{a:name} : ''
|
||||
endfunction
|
||||
\ exists('g:syntastic_' . a:name) ? g:syntastic_{a:name} :
|
||||
\ a:0 > 0 ? a:1 : ''
|
||||
endfunction " }}}2
|
||||
|
||||
" Parse a version string. Return an array of version components.
|
||||
function! syntastic#util#parseVersion(version)
|
||||
function! syntastic#util#parseVersion(version) " {{{2
|
||||
return split(matchstr( a:version, '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Run 'command' in a shell and parse output as a version string.
|
||||
" Returns an array of version components.
|
||||
function! syntastic#util#getVersion(command)
|
||||
function! syntastic#util#getVersion(command) " {{{2
|
||||
return syntastic#util#parseVersion(system(a:command))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Verify that the 'installed' version is at least the 'required' version.
|
||||
"
|
||||
|
@ -76,7 +73,7 @@ endfunction
|
|||
" the "missing" elements will be assumed to be 0 for the purposes of checking.
|
||||
"
|
||||
" See http://semver.org for info about version numbers.
|
||||
function! syntastic#util#versionIsAtLeast(installed, required)
|
||||
function! syntastic#util#versionIsAtLeast(installed, required) " {{{2
|
||||
for idx in range(max([len(a:installed), len(a:required)]))
|
||||
let installed_element = get(a:installed, idx, 0)
|
||||
let required_element = get(a:required, idx, 0)
|
||||
|
@ -86,10 +83,14 @@ function! syntastic#util#versionIsAtLeast(installed, required)
|
|||
endfor
|
||||
" Everything matched, so it is at least the required version.
|
||||
return 1
|
||||
endfunction
|
||||
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')
|
||||
|
||||
"print as much of a:msg as possible without "Press Enter" prompt appearing
|
||||
function! syntastic#util#wideMsg(msg)
|
||||
function! syntastic#util#wideMsg(msg) " {{{2
|
||||
let old_ruler = &ruler
|
||||
let old_showcmd = &showcmd
|
||||
|
||||
|
@ -101,7 +102,7 @@ function! syntastic#util#wideMsg(msg)
|
|||
"width as the proper amount of characters
|
||||
let chunks = split(msg, "\t", 1)
|
||||
let msg = join(map(chunks[:-2], 'v:val . repeat(" ", &ts - s:width(v:val) % &ts)'), '') . chunks[-1]
|
||||
let msg = strpart(msg, 0, winwidth(0) - 1)
|
||||
let msg = strpart(msg, 0, &columns - 1)
|
||||
|
||||
set noruler noshowcmd
|
||||
call syntastic#util#redraw(0)
|
||||
|
@ -110,10 +111,10 @@ function! syntastic#util#wideMsg(msg)
|
|||
|
||||
let &ruler = old_ruler
|
||||
let &showcmd = old_showcmd
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Check whether a buffer is loaded, listed, and not hidden
|
||||
function! syntastic#util#bufIsActive(buffer)
|
||||
function! syntastic#util#bufIsActive(buffer) " {{{2
|
||||
" convert to number, or hell breaks loose
|
||||
let buf = str2nr(a:buffer)
|
||||
|
||||
|
@ -129,11 +130,11 @@ function! syntastic#util#bufIsActive(buffer)
|
|||
endfor
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
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)
|
||||
function! syntastic#util#findInParent(what, where) " {{{2
|
||||
let here = fnamemodify(a:where, ':p')
|
||||
|
||||
let root = syntastic#util#Slash()
|
||||
|
@ -162,10 +163,10 @@ function! syntastic#util#findInParent(what, where)
|
|||
endwhile
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Returns unique elements in a list
|
||||
function! syntastic#util#unique(list)
|
||||
function! syntastic#util#unique(list) " {{{2
|
||||
let seen = {}
|
||||
let uniques = []
|
||||
for e in a:list
|
||||
|
@ -175,20 +176,20 @@ function! syntastic#util#unique(list)
|
|||
endif
|
||||
endfor
|
||||
return uniques
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" A less noisy shellescape()
|
||||
function! syntastic#util#shescape(string)
|
||||
function! syntastic#util#shescape(string) " {{{2
|
||||
return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" A less noisy shellescape(expand())
|
||||
function! syntastic#util#shexpand(string)
|
||||
function! syntastic#util#shexpand(string) " {{{2
|
||||
return syntastic#util#shescape(expand(a:string))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" decode XML entities
|
||||
function! syntastic#util#decodeXMLEntities(string)
|
||||
function! syntastic#util#decodeXMLEntities(string) " {{{2
|
||||
let str = a:string
|
||||
let str = substitute(str, '\m<', '<', 'g')
|
||||
let str = substitute(str, '\m>', '>', 'g')
|
||||
|
@ -196,17 +197,17 @@ function! syntastic#util#decodeXMLEntities(string)
|
|||
let str = substitute(str, '\m'', "'", 'g')
|
||||
let str = substitute(str, '\m&', '\&', 'g')
|
||||
return str
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#util#redraw(full)
|
||||
function! syntastic#util#redraw(full) " {{{2
|
||||
if a:full
|
||||
redraw!
|
||||
else
|
||||
redraw
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! syntastic#util#dictFilter(errors, filter)
|
||||
function! syntastic#util#dictFilter(errors, filter) " {{{2
|
||||
let rules = s:translateFilter(a:filter)
|
||||
" call syntastic#log#debug(g:SyntasticDebugFilters, "applying filter:", rules)
|
||||
try
|
||||
|
@ -215,11 +216,13 @@ function! syntastic#util#dictFilter(errors, filter)
|
|||
let msg = matchstr(v:exception, '\m^Vim\%((\a\+)\)\=:\zs.*')
|
||||
call syntastic#log#error('quiet_messages: ' . msg)
|
||||
endtry
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
function! s:translateFilter(filters)
|
||||
function! s:translateFilter(filters) " {{{2
|
||||
let conditions = []
|
||||
for k in keys(a:filters)
|
||||
if type(a:filters[k]) == type([])
|
||||
|
@ -228,10 +231,14 @@ function! s:translateFilter(filters)
|
|||
call add(conditions, s:translateElement(k, a:filters[k]))
|
||||
endif
|
||||
endfor
|
||||
return len(conditions) == 1 ? conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
|
||||
endfunction
|
||||
|
||||
function! s:translateElement(key, term)
|
||||
if conditions == []
|
||||
let conditions = ["1"]
|
||||
endif
|
||||
return len(conditions) == 1 ? conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:translateElement(key, term) " {{{2
|
||||
if a:key ==? 'level'
|
||||
let ret = 'v:val["type"] !=? ' . string(a:term[0])
|
||||
elseif a:key ==? 'type'
|
||||
|
@ -241,11 +248,15 @@ function! s:translateElement(key, term)
|
|||
elseif a:key ==? 'file'
|
||||
let ret = 'bufname(str2nr(v:val["bufnr"])) !~# ' . string(a:term)
|
||||
else
|
||||
call syntastic#log#warn('quiet_messages: ignoring invalid key ' . strtrans(string(a:key)))
|
||||
let ret = "1"
|
||||
endif
|
||||
return ret
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: set et sts=4 sw=4 fdm=marker:
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -417,17 +417,16 @@ Default: {}
|
|||
|
||||
Use this option to filter out some of the messages produced by checkers. The
|
||||
option should be set to something like: >
|
||||
|
||||
let g:syntastic_quiet_messages = { "level": "warnings",
|
||||
\ "type": "style",
|
||||
\ "regex": '\m\[C03\d\d\]',
|
||||
\ "file": ['\m^/usr/include/', '\m\c\.h$'] }
|
||||
<
|
||||
|
||||
Each element turns off messages matching the patterns specified by the
|
||||
corresponding value. Values are lists, but if a list consist of a single
|
||||
element you can omit adding the brackets (e.g. you can write "style" instead of
|
||||
["style"]).
|
||||
element you can omit adding the brackets (e.g. you can write "style" instead
|
||||
of ["style"]). Elements with values [] or '' are ignored (this is useful for
|
||||
overriding filters, cf. |filter-overrides|).
|
||||
|
||||
"level" - takes one of two values, "warnings" or "errors"
|
||||
"type" - can be either "syntax" or "style"
|
||||
|
@ -436,9 +435,26 @@ element you can omit adding the brackets (e.g. you can write "style" instead of
|
|||
"file" - is matched against the filename the error refers to, as a case
|
||||
sensitive |regular-expression|.
|
||||
|
||||
If |'syntastic_id_checkers'| is set, filters are applied before error messages
|
||||
are labeled with the names of the checkers that created them.
|
||||
|
||||
There are also checker-specific variants of this option, providing finer
|
||||
control. They are named |'syntastic_<filetype>_<checker>_quiet_messages'|.
|
||||
|
||||
For a particular checker, if both a |'syntastic_quiet_messages'| filter and
|
||||
a checker-specific filter are present, they are both applied (to the list of
|
||||
errors produced by the said checker). In case of conflicting values for the
|
||||
same keys, the values of the checker-specific filters take precedence.
|
||||
|
||||
*filter-overrides*
|
||||
Since filter elements with values [] or '' are ignored, you can disable global
|
||||
filters for particular checkers, by setting the values of the corresponding
|
||||
elements in |'syntastic_<filetype>_<checker>_quiet_messages'| to [] or ''. For
|
||||
example, the following setting will silence all warnings, except for the
|
||||
ones produced by 'pylint': >
|
||||
let g:syntastic_quiet_messages = { "level": "warnings" }
|
||||
let g:syntastic_python_pylint_quiet_messages = { "level" : [] }
|
||||
<
|
||||
*'syntastic_stl_format'*
|
||||
Default: [Syntax: line:%F (%t)]
|
||||
Use this option to control what the syntastic statusline text contains. Several
|
||||
|
|
|
@ -19,9 +19,7 @@ if has('reltime')
|
|||
let g:syntastic_start = reltime()
|
||||
endif
|
||||
|
||||
runtime! plugin/syntastic/*.vim
|
||||
|
||||
let s:running_windows = syntastic#util#isRunningWindows()
|
||||
" Sanity checks {{{1
|
||||
|
||||
for s:feature in ['autocmd', 'eval', 'modify_fname', 'quickfix', 'user_commands']
|
||||
if !has(s:feature)
|
||||
|
@ -30,68 +28,52 @@ for s:feature in ['autocmd', 'eval', 'modify_fname', 'quickfix', 'user_commands'
|
|||
endif
|
||||
endfor
|
||||
|
||||
let s:running_windows = syntastic#util#isRunningWindows()
|
||||
if !s:running_windows && executable('uname')
|
||||
try
|
||||
let s:uname = system('uname')
|
||||
catch /^Vim\%((\a\+)\)\=:E484/
|
||||
catch /\m^Vim\%((\a\+)\)\=:E484/
|
||||
call syntastic#log#error("your shell " . &shell . " doesn't use traditional UNIX syntax for redirections")
|
||||
finish
|
||||
endtry
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_always_populate_loc_list")
|
||||
let g:syntastic_always_populate_loc_list = 0
|
||||
endif
|
||||
" }}}1
|
||||
|
||||
if !exists("g:syntastic_auto_jump")
|
||||
let g:syntastic_auto_jump = 0
|
||||
endif
|
||||
" Defaults {{{1
|
||||
|
||||
if !exists("g:syntastic_quiet_messages")
|
||||
let g:syntastic_quiet_messages = {}
|
||||
endif
|
||||
let g:syntastic_defaults = {
|
||||
\ 'aggregate_errors': 0,
|
||||
\ 'always_populate_loc_list': 0,
|
||||
\ 'auto_jump': 0,
|
||||
\ 'auto_loc_list': 2,
|
||||
\ 'bash_hack': 1,
|
||||
\ 'check_on_open': 0,
|
||||
\ 'check_on_wq': 1,
|
||||
\ 'debug': 0,
|
||||
\ 'echo_current_error': 1,
|
||||
\ 'enable_balloons': 1,
|
||||
\ 'enable_highlighting': 1,
|
||||
\ 'enable_signs': 1,
|
||||
\ 'error_symbol': '>>',
|
||||
\ 'filetype_map': {},
|
||||
\ 'full_redraws': !(has('gui_running') || has('gui_macvim')),
|
||||
\ 'id_checkers': 1,
|
||||
\ 'ignore_files': [],
|
||||
\ 'loc_list_height': 10,
|
||||
\ 'quiet_messages': {},
|
||||
\ 'reuse_loc_lists': (v:version >= 704),
|
||||
\ 'stl_format': '[Syntax: line:%F (%t)]',
|
||||
\ 'style_error_symbol': 'S>',
|
||||
\ 'style_warning_symbol': 'S>',
|
||||
\ 'warning_symbol': '>>'
|
||||
\ }
|
||||
|
||||
if !exists("g:syntastic_stl_format")
|
||||
let g:syntastic_stl_format = '[Syntax: line:%F (%t)]'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_check_on_open")
|
||||
let g:syntastic_check_on_open = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_check_on_wq")
|
||||
let g:syntastic_check_on_wq = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_aggregate_errors")
|
||||
let g:syntastic_aggregate_errors = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_id_checkers")
|
||||
let g:syntastic_id_checkers = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_loc_list_height")
|
||||
let g:syntastic_loc_list_height = 10
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_ignore_files")
|
||||
let g:syntastic_ignore_files = []
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_filetype_map")
|
||||
let g:syntastic_filetype_map = {}
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_full_redraws")
|
||||
let g:syntastic_full_redraws = !(has('gui_running') || has('gui_macvim'))
|
||||
endif
|
||||
|
||||
" TODO: not documented
|
||||
if !exists("g:syntastic_reuse_loc_lists")
|
||||
" a relevant bug has been fixed in one of the pre-releases of Vim 7.4
|
||||
let g:syntastic_reuse_loc_lists = (v:version >= 704)
|
||||
endif
|
||||
for s:key in keys(g:syntastic_defaults)
|
||||
if !exists('g:syntastic_' . s:key)
|
||||
let g:syntastic_{s:key} = g:syntastic_defaults[s:key]
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists("g:syntastic_quiet_warnings")
|
||||
call syntastic#log#deprecationWarn("variable g:syntastic_quiet_warnings is deprecated, please use let g:syntastic_quiet_messages = {'level': 'warnings'} instead")
|
||||
|
@ -105,6 +87,10 @@ if exists("g:syntastic_quiet_warnings")
|
|||
endif
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
|
||||
" Debug {{{1
|
||||
|
||||
let s:debug_dump_options = [
|
||||
\ 'shell',
|
||||
\ 'shellcmdflag',
|
||||
|
@ -119,7 +105,6 @@ if v:version > 703 || (v:version == 703 && has('patch446'))
|
|||
call add(s:debug_dump_options, 'shellxescape')
|
||||
endif
|
||||
|
||||
|
||||
" debug constants
|
||||
let g:SyntasticDebugTrace = 1
|
||||
let g:SyntasticDebugLoclist = 2
|
||||
|
@ -127,23 +112,26 @@ let g:SyntasticDebugNotifications = 4
|
|||
let g:SyntasticDebugAutocommands = 8
|
||||
let g:SyntasticDebugVariables = 16
|
||||
|
||||
" }}}1
|
||||
|
||||
runtime! plugin/syntastic/*.vim
|
||||
|
||||
let s:registry = g:SyntasticRegistry.Instance()
|
||||
let s:notifiers = g:SyntasticNotifiers.Instance()
|
||||
let s:modemap = g:SyntasticModeMap.Instance()
|
||||
|
||||
" Commands {{{1
|
||||
|
||||
" @vimlint(EVL103, 1, a:cursorPos)
|
||||
" @vimlint(EVL103, 1, a:cmdLine)
|
||||
" @vimlint(EVL103, 1, a:argLead)
|
||||
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
|
||||
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) " {{{2
|
||||
let checker_names = []
|
||||
for ft in s:ResolveFiletypes()
|
||||
for checker in s:registry.availableCheckersFor(ft)
|
||||
call add(checker_names, checker.getName())
|
||||
endfor
|
||||
for ft in s:resolveFiletypes()
|
||||
call extend(checker_names, keys(s:registry.getCheckersMap(ft)))
|
||||
endfor
|
||||
return join(checker_names, "\n")
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:cursorPos)
|
||||
" @vimlint(EVL103, 0, a:cmdLine)
|
||||
" @vimlint(EVL103, 0, a:argLead)
|
||||
|
@ -152,14 +140,13 @@ endfunction
|
|||
" @vimlint(EVL103, 1, a:cursorPos)
|
||||
" @vimlint(EVL103, 1, a:cmdLine)
|
||||
" @vimlint(EVL103, 1, a:argLead)
|
||||
function! s:CompleteFiletypes(argLead, cmdLine, cursorPos)
|
||||
return join(s:registry.knownFiletypes(), "\n")
|
||||
endfunction
|
||||
function! s:CompleteFiletypes(argLead, cmdLine, cursorPos) " {{{2
|
||||
return join(s:registry.getKnownFiletypes(), "\n")
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:cursorPos)
|
||||
" @vimlint(EVL103, 0, a:cmdLine)
|
||||
" @vimlint(EVL103, 0, a:argLead)
|
||||
|
||||
|
||||
command! SyntasticToggleMode call s:ToggleMode()
|
||||
command! -nargs=* -complete=custom,s:CompleteCheckerName SyntasticCheck
|
||||
\ call s:UpdateErrors(0, <f-args>) <bar>
|
||||
|
@ -167,12 +154,16 @@ command! -nargs=* -complete=custom,s:CompleteCheckerName SyntasticCheck
|
|||
command! Errors call s:ShowLocList()
|
||||
command! -nargs=? -complete=custom,s:CompleteFiletypes SyntasticInfo
|
||||
\ call s:modemap.echoMode() |
|
||||
\ call s:registry.echoInfoFor(s:ResolveFiletypes(<f-args>))
|
||||
\ call s:registry.echoInfoFor(s:resolveFiletypes(<f-args>))
|
||||
command! SyntasticReset
|
||||
\ call s:ClearCache() |
|
||||
\ call s:notifiers.refresh(g:SyntasticLoclist.New([]))
|
||||
command! SyntasticSetLoclist call g:SyntasticLoclist.current().setloclist()
|
||||
|
||||
" }}}1
|
||||
|
||||
" Autocommands and hooks {{{1
|
||||
|
||||
augroup syntastic
|
||||
autocmd BufReadPost * call s:BufReadPostHook()
|
||||
autocmd BufWritePost * call s:BufWritePostHook()
|
||||
|
@ -191,31 +182,30 @@ if v:version > 703 || (v:version == 703 && has('patch544'))
|
|||
augroup END
|
||||
endif
|
||||
|
||||
|
||||
function! s:BufReadPostHook()
|
||||
function! s:BufReadPostHook() " {{{2
|
||||
if g:syntastic_check_on_open
|
||||
call syntastic#log#debug(g:SyntasticDebugAutocommands,
|
||||
\ 'autocmd: BufReadPost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
|
||||
call s:UpdateErrors(1)
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:BufWritePostHook()
|
||||
function! s:BufWritePostHook() " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugAutocommands,
|
||||
\ 'autocmd: BufWritePost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
|
||||
call s:UpdateErrors(1)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:BufWinEnterHook()
|
||||
function! s:BufWinEnterHook() " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugAutocommands,
|
||||
\ 'autocmd: BufWinEnter, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))) .
|
||||
\ ', &buftype = ' . string(&buftype))
|
||||
if &buftype == ''
|
||||
call s:notifiers.refresh(g:SyntasticLoclist.current())
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:BufEnterHook()
|
||||
function! s:BufEnterHook() " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugAutocommands,
|
||||
\ 'autocmd: BufEnter, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))) .
|
||||
\ ', &buftype = ' . string(&buftype))
|
||||
|
@ -225,18 +215,22 @@ function! s:BufEnterHook()
|
|||
if &buftype == 'quickfix' && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
|
||||
call g:SyntasticLoclistHide()
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:QuitPreHook()
|
||||
function! s:QuitPreHook() " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugAutocommands,
|
||||
\ 'autocmd: QuitPre, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
|
||||
let b:syntastic_skip_checks = !g:syntastic_check_on_wq
|
||||
call g:SyntasticLoclistHide()
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Main {{{1
|
||||
|
||||
"refresh and redraw all the error info for this buf when saving or reading
|
||||
function! s:UpdateErrors(auto_invoked, ...)
|
||||
if s:SkipFile()
|
||||
function! s:UpdateErrors(auto_invoked, ...) " {{{2
|
||||
if s:skipFile()
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -248,15 +242,16 @@ function! s:UpdateErrors(auto_invoked, ...)
|
|||
|
||||
let loclist = g:SyntasticLoclist.current()
|
||||
|
||||
let w:syntastic_loclist_set = 0
|
||||
let do_jump = g:syntastic_auto_jump
|
||||
if g:syntastic_auto_jump == 2
|
||||
" populate loclist and jump {{{3
|
||||
let do_jump = syntastic#util#var('auto_jump')
|
||||
if do_jump == 2
|
||||
let first = loclist.getFirstIssue()
|
||||
let type = get(first, 'type', '')
|
||||
let do_jump = type ==? 'E'
|
||||
endif
|
||||
|
||||
if g:syntastic_always_populate_loc_list || do_jump
|
||||
let w:syntastic_loclist_set = 0
|
||||
if syntastic#util#var('always_populate_loc_list') || do_jump
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: setloclist (new)')
|
||||
call setloclist(0, loclist.getRaw())
|
||||
let w:syntastic_loclist_set = 1
|
||||
|
@ -273,150 +268,105 @@ function! s:UpdateErrors(auto_invoked, ...)
|
|||
endif
|
||||
endif
|
||||
endif
|
||||
" }}}3
|
||||
|
||||
call s:notifiers.refresh(loclist)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"clear the loc list for the buffer
|
||||
function! s:ClearCache()
|
||||
function! s:ClearCache() " {{{2
|
||||
call s:notifiers.reset(g:SyntasticLoclist.current())
|
||||
unlet! b:syntastic_loclist
|
||||
endfunction
|
||||
|
||||
function! s:ResolveFiletypes(...)
|
||||
let type = a:0 ? a:1 : &filetype
|
||||
return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"detect and cache all syntax errors in this buffer
|
||||
function! s:CacheErrors(checkers)
|
||||
function! s:CacheErrors(checker_names) " {{{2
|
||||
call s:ClearCache()
|
||||
let newLoclist = g:SyntasticLoclist.New([])
|
||||
|
||||
if !s:SkipFile()
|
||||
let active_checkers = 0
|
||||
let names = []
|
||||
|
||||
if !s:skipFile()
|
||||
" debug logging {{{3
|
||||
call syntastic#log#debugShowOptions(g:SyntasticDebugTrace, s:debug_dump_options)
|
||||
call syntastic#log#debugDump(g:SyntasticDebugVariables)
|
||||
call syntastic#log#debugShowVariables(g:SyntasticDebugTrace, 'syntastic_aggregate_errors')
|
||||
call syntastic#log#debugShowVariables(g:SyntasticDebugTrace, 'aggregate_errors')
|
||||
call syntastic#log#debug(g:SyntasticDebugTrace, 'getcwd() = ' . getcwd())
|
||||
" }}}3
|
||||
|
||||
let filetypes = s:ResolveFiletypes()
|
||||
let filetypes = s:resolveFiletypes()
|
||||
let aggregate_errors = syntastic#util#var('aggregate_errors')
|
||||
let decorate_errors = (aggregate_errors || len(filetypes) > 1) && syntastic#util#var('id_checkers')
|
||||
|
||||
for ft in filetypes
|
||||
let clist = empty(a:checkers) ? s:registry.getActiveCheckers(ft) : s:registry.getCheckers(ft, a:checkers)
|
||||
|
||||
for checker in clist
|
||||
let active_checkers += 1
|
||||
call syntastic#log#debug(g:SyntasticDebugTrace, 'CacheErrors: Invoking checker: ' . checker.getName())
|
||||
|
||||
let loclist = checker.getLocList()
|
||||
|
||||
if !loclist.isEmpty()
|
||||
if decorate_errors
|
||||
call loclist.decorate(checker.getName(), checker.getFiletype())
|
||||
endif
|
||||
call add(names, [checker.getName(), checker.getFiletype()])
|
||||
|
||||
let newLoclist = newLoclist.extend(loclist)
|
||||
|
||||
if !aggregate_errors
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let clist = []
|
||||
for type in filetypes
|
||||
call extend(clist, s:registry.getCheckers(type, a:checker_names))
|
||||
endfor
|
||||
|
||||
let names = []
|
||||
for checker in clist
|
||||
let type = checker.getFiletype()
|
||||
let name = checker.getName()
|
||||
call syntastic#log#debug(g:SyntasticDebugTrace, 'CacheErrors: Invoking checker: ' . type . '/' . name)
|
||||
|
||||
let loclist = checker.getLocList()
|
||||
|
||||
if !loclist.isEmpty()
|
||||
if decorate_errors
|
||||
call loclist.decorate(type, name)
|
||||
endif
|
||||
call add(names, [type, name])
|
||||
|
||||
let newLoclist = newLoclist.extend(loclist)
|
||||
|
||||
if !aggregate_errors
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
" set names {{{3
|
||||
if !empty(names)
|
||||
if len(syntastic#util#unique(map(copy(names), 'v:val[1]'))) == 1
|
||||
let type = names[0][1]
|
||||
let name = join(map(names, 'v:val[0]'), ', ')
|
||||
if len(syntastic#util#unique(map( copy(names), 'v:val[0]' ))) == 1
|
||||
let type = names[0][0]
|
||||
let name = join(map(names, 'v:val[1]'), ', ')
|
||||
call newLoclist.setName( name . ' ('. type . ')' )
|
||||
else
|
||||
" checkers from mixed types
|
||||
call newLoclist.setName(join(map(names, 'v:val[1] . "/" . v:val[0]'), ', '))
|
||||
call newLoclist.setName(join(map(names, 'v:val[0] . "/" . v:val[1]'), ', '))
|
||||
endif
|
||||
endif
|
||||
" }}}3
|
||||
|
||||
if !active_checkers
|
||||
if !empty(a:checkers)
|
||||
if len(a:checkers) == 1
|
||||
call syntastic#log#warn('checker ' . a:checkers[0] . ' is not active for filetype ' . &filetype)
|
||||
" issue warning about no active checkers {{{3
|
||||
if empty(clist)
|
||||
if !empty(a:checker_names)
|
||||
if len(a:checker_names) == 1
|
||||
call syntastic#log#warn('checker ' . a:checker_names[0] . ' is not available')
|
||||
else
|
||||
call syntastic#log#warn('checkers ' . join(a:checkers, ', ') . ' are not active for filetype ' . &filetype)
|
||||
call syntastic#log#warn('checkers ' . join(a:checker_names, ', ') . ' are not available')
|
||||
endif
|
||||
else
|
||||
call syntastic#log#debug(g:SyntasticDebugTrace, 'CacheErrors: no active checkers for filetype ' . &filetype)
|
||||
call syntastic#log#debug(g:SyntasticDebugTrace, 'CacheErrors: no checkers available for ' . &filetype)
|
||||
endif
|
||||
endif
|
||||
" }}}3
|
||||
|
||||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'aggregated:', newLoclist)
|
||||
|
||||
if type(g:syntastic_quiet_messages) == type({}) && !empty(g:syntastic_quiet_messages)
|
||||
call newLoclist.quietMessages(g:syntastic_quiet_messages)
|
||||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'filtered by g:syntastic_quiet_messages:', newLoclist)
|
||||
endif
|
||||
endif
|
||||
|
||||
let b:syntastic_loclist = newLoclist
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:ToggleMode()
|
||||
function! s:ToggleMode() " {{{2
|
||||
call s:modemap.toggleMode()
|
||||
call s:ClearCache()
|
||||
call s:UpdateErrors(1)
|
||||
call s:modemap.echoMode()
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"display the cached errors for this buf in the location list
|
||||
function! s:ShowLocList()
|
||||
function! s:ShowLocList() " {{{2
|
||||
call g:SyntasticLoclist.current().show()
|
||||
endfunction
|
||||
|
||||
"the script changes &shellredir and &shell to stop the screen flicking when
|
||||
"shelling out to syntax checkers. Not all OSs support the hacks though
|
||||
function! s:OSSupportsShellredirHack()
|
||||
return !s:running_windows && executable('/bin/bash') && (s:uname() !~ "FreeBSD") && (s:uname() !~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
function! s:IsRedrawRequiredAfterMake()
|
||||
return !s:running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
function! s:IgnoreFile(filename)
|
||||
let fname = fnamemodify(a:filename, ':p')
|
||||
for pattern in g:syntastic_ignore_files
|
||||
if fname =~# pattern
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Skip running in special buffers
|
||||
function! s:SkipFile()
|
||||
let force_skip = exists('b:syntastic_skip_checks') ? b:syntastic_skip_checks : 0
|
||||
let fname = expand('%')
|
||||
return force_skip || (&buftype != '') || !filereadable(fname) || getwinvar(0, '&diff') || s:IgnoreFile(fname)
|
||||
endfunction
|
||||
|
||||
function! s:uname()
|
||||
if !exists('s:uname')
|
||||
let s:uname = system('uname')
|
||||
endif
|
||||
return s:uname
|
||||
endfunction
|
||||
|
||||
"return a string representing the state of buffer according to
|
||||
"g:syntastic_stl_format
|
||||
"
|
||||
"return '' if no errors are cached for the buffer
|
||||
function! SyntasticStatuslineFlag()
|
||||
return g:SyntasticLoclist.current().getStatuslineFlag()
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"Emulates the :lmake command. Sets up the make environment according to the
|
||||
"options given, runs make, resets the environment, returns the location list
|
||||
|
@ -435,9 +385,10 @@ endfunction
|
|||
" 'postprocess' - a list of functions to be applied to the error list
|
||||
" 'cwd' - change directory to the given path before running the checker
|
||||
" 'returns' - a list of valid exit codes for the checker
|
||||
function! SyntasticMake(options)
|
||||
function! SyntasticMake(options) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugTrace, 'SyntasticMake: called with options:', a:options)
|
||||
|
||||
" save options and locale env variables {{{3
|
||||
let old_shell = &shell
|
||||
let old_shellredir = &shellredir
|
||||
let old_local_errorformat = &l:errorformat
|
||||
|
@ -445,13 +396,9 @@ function! SyntasticMake(options)
|
|||
let old_cwd = getcwd()
|
||||
let old_lc_messages = $LC_MESSAGES
|
||||
let old_lc_all = $LC_ALL
|
||||
" }}}3
|
||||
|
||||
if s:OSSupportsShellredirHack()
|
||||
"this is a hack to stop the screen needing to be ':redraw'n when
|
||||
"when :lmake is run. Otherwise the screen flickers annoyingly
|
||||
let &shellredir = '&>'
|
||||
let &shell = '/bin/bash'
|
||||
endif
|
||||
call s:bashHack()
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &errorformat = a:options['errorformat']
|
||||
|
@ -470,7 +417,7 @@ function! SyntasticMake(options)
|
|||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'checker output:', err_lines)
|
||||
|
||||
if has_key(a:options, 'preprocess')
|
||||
let err_lines = call(a:options['preprocess'], [err_lines])
|
||||
let err_lines = call('syntastic#preprocess#' . a:options['preprocess'], [err_lines])
|
||||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'preprocess:', err_lines)
|
||||
endif
|
||||
lgetexpr err_lines
|
||||
|
@ -482,12 +429,15 @@ function! SyntasticMake(options)
|
|||
endif
|
||||
|
||||
silent! lolder
|
||||
|
||||
" restore options {{{3
|
||||
let &errorformat = old_errorformat
|
||||
let &l:errorformat = old_local_errorformat
|
||||
let &shellredir = old_shellredir
|
||||
let &shell = old_shell
|
||||
" }}}3
|
||||
|
||||
if s:IsRedrawRequiredAfterMake()
|
||||
if !s:running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD")
|
||||
call syntastic#util#redraw(g:syntastic_full_redraws)
|
||||
endif
|
||||
|
||||
|
@ -498,12 +448,12 @@ function! SyntasticMake(options)
|
|||
endif
|
||||
|
||||
if has_key(a:options, 'defaults')
|
||||
call SyntasticAddToErrors(errors, a:options['defaults'])
|
||||
call s:addToErrors(errors, a:options['defaults'])
|
||||
endif
|
||||
|
||||
" Add subtype info if present.
|
||||
if has_key(a:options, 'subtype')
|
||||
call SyntasticAddToErrors(errors, { 'subtype': a:options['subtype'] })
|
||||
call s:addToErrors(errors, { 'subtype': a:options['subtype'] })
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'postprocess') && !empty(a:options['postprocess'])
|
||||
|
@ -514,10 +464,44 @@ function! SyntasticMake(options)
|
|||
endif
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"take a list of errors and add default values to them from a:options
|
||||
function! SyntasticAddToErrors(errors, options)
|
||||
"return a string representing the state of buffer according to
|
||||
"g:syntastic_stl_format
|
||||
"
|
||||
"return '' if no errors are cached for the buffer
|
||||
function! SyntasticStatuslineFlag() " {{{2
|
||||
return g:SyntasticLoclist.current().getStatuslineFlag()
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Utilities {{{1
|
||||
|
||||
function! s:resolveFiletypes(...) " {{{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
|
||||
let fname = fnamemodify(a:filename, ':p')
|
||||
for pattern in g:syntastic_ignore_files
|
||||
if fname =~# pattern
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction " }}}2
|
||||
|
||||
" Skip running in special buffers
|
||||
function! s:skipFile() " {{{2
|
||||
let force_skip = exists('b:syntastic_skip_checks') ? b:syntastic_skip_checks : 0
|
||||
let fname = expand('%')
|
||||
return force_skip || (&buftype != '') || !filereadable(fname) || getwinvar(0, '&diff') || s:ignoreFile(fname)
|
||||
endfunction " }}}2
|
||||
|
||||
" Take a list of errors and add default values to them from a:options
|
||||
function! s:addToErrors(errors, options) " {{{2
|
||||
for err in a:errors
|
||||
for key in keys(a:options)
|
||||
if !has_key(err, key) || empty(err[key])
|
||||
|
@ -527,6 +511,34 @@ function! SyntasticAddToErrors(errors, options)
|
|||
endfor
|
||||
|
||||
return a:errors
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
" The script changes &shellredir and &shell to stop the screen flicking when
|
||||
" shelling out to syntax checkers. Not all OSs support the hacks though.
|
||||
function! s:bashHack() " {{{2
|
||||
if !exists('s:bash')
|
||||
if !s:running_windows && (s:uname() !~# "FreeBSD") && (s:uname() !~# "OpenBSD")
|
||||
let s:bash =
|
||||
\ executable('/usr/local/bin/bash') ? '/usr/local/bin/bash' :
|
||||
\ executable('/bin/bash') ? '/bin/bash' : ''
|
||||
else
|
||||
let s:bash = ''
|
||||
endif
|
||||
endif
|
||||
|
||||
if g:syntastic_bash_hack && s:bash != ''
|
||||
let &shell = s:bash
|
||||
let &shellredir = '&>'
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:uname() " {{{2
|
||||
if !exists('s:uname')
|
||||
let s:uname = system('uname')
|
||||
endif
|
||||
return s:uname
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,40 +1,38 @@
|
|||
if exists("g:loaded_syntastic_notifier_autoloclist")
|
||||
if exists("g:loaded_syntastic_notifier_autoloclist") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_autoloclist = 1
|
||||
|
||||
if !exists("g:syntastic_auto_loc_list")
|
||||
let g:syntastic_auto_loc_list = 2
|
||||
endif
|
||||
|
||||
let g:SyntasticAutoloclistNotifier = {}
|
||||
|
||||
" Public methods {{{1
|
||||
"
|
||||
function! g:SyntasticAutoloclistNotifier.New()
|
||||
function! g:SyntasticAutoloclistNotifier.New() " {{{2
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticAutoloclistNotifier.refresh(loclist)
|
||||
function! g:SyntasticAutoloclistNotifier.refresh(loclist) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'autoloclist: refresh')
|
||||
call g:SyntasticAutoloclistNotifier.AutoToggle(a:loclist)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist)
|
||||
function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'autoloclist: toggle')
|
||||
if !a:loclist.isEmpty()
|
||||
if g:syntastic_auto_loc_list == 1
|
||||
if syntastic#util#var('auto_loc_list') == 1
|
||||
call a:loclist.show()
|
||||
endif
|
||||
else
|
||||
if g:syntastic_auto_loc_list > 0
|
||||
if syntastic#util#var('auto_loc_list') > 0
|
||||
|
||||
"TODO: this will close the loc list window if one was opened by
|
||||
"something other than syntastic
|
||||
lclose
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
if exists("g:loaded_syntastic_notifier_balloons")
|
||||
if exists("g:loaded_syntastic_notifier_balloons") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_balloons = 1
|
||||
|
||||
if !exists("g:syntastic_enable_balloons")
|
||||
let g:syntastic_enable_balloons = 1
|
||||
endif
|
||||
|
||||
if !has('balloon_eval')
|
||||
let g:syntastic_enable_balloons = 0
|
||||
endif
|
||||
|
@ -15,17 +11,17 @@ let g:SyntasticBalloonsNotifier = {}
|
|||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticBalloonsNotifier.New()
|
||||
function! g:SyntasticBalloonsNotifier.New() " {{{2
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticBalloonsNotifier.enabled()
|
||||
function! g:SyntasticBalloonsNotifier.enabled() " {{{2
|
||||
return has('balloon_eval') && syntastic#util#var('enable_balloons')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Update the error balloons
|
||||
function! g:SyntasticBalloonsNotifier.refresh(loclist)
|
||||
function! g:SyntasticBalloonsNotifier.refresh(loclist) " {{{2
|
||||
let b:syntastic_balloons = {}
|
||||
if self.enabled() && !a:loclist.isEmpty()
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: refresh')
|
||||
|
@ -42,25 +38,29 @@ function! g:SyntasticBalloonsNotifier.refresh(loclist)
|
|||
set beval bexpr=SyntasticBalloonsExprNotifier()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Reset the error balloons
|
||||
" @vimlint(EVL103, 1, a:loclist)
|
||||
function! g:SyntasticBalloonsNotifier.reset(loclist)
|
||||
function! g:SyntasticBalloonsNotifier.reset(loclist) " {{{2
|
||||
if has('balloon_eval')
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: reset')
|
||||
set nobeval
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:loclist)
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
function! SyntasticBalloonsExprNotifier()
|
||||
function! SyntasticBalloonsExprNotifier() " {{{2
|
||||
if !exists('b:syntastic_balloons')
|
||||
return ''
|
||||
endif
|
||||
return get(b:syntastic_balloons, v:beval_lnum, '')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_checker")
|
||||
if exists("g:loaded_syntastic_checker") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_checker = 1
|
||||
|
@ -7,7 +7,7 @@ let g:SyntasticChecker = {}
|
|||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticChecker.New(args)
|
||||
function! g:SyntasticChecker.New(args) " {{{2
|
||||
let newObj = copy(self)
|
||||
|
||||
let newObj._filetype = a:args['filetype']
|
||||
|
@ -34,29 +34,29 @@ function! g:SyntasticChecker.New(args)
|
|||
endif
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getFiletype()
|
||||
function! g:SyntasticChecker.getFiletype() " {{{2
|
||||
return self._filetype
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getName()
|
||||
function! g:SyntasticChecker.getName() " {{{2
|
||||
return self._name
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getExec()
|
||||
function! g:SyntasticChecker.getExec() " {{{2
|
||||
if exists('g:syntastic_' . self._filetype . '_' . self._name . '_exec')
|
||||
return expand(g:syntastic_{self._filetype}_{self._name}_exec)
|
||||
endif
|
||||
|
||||
return self._exec
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getExecEscaped()
|
||||
function! g:SyntasticChecker.getExecEscaped() " {{{2
|
||||
return syntastic#util#shescape(self.getExec())
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getLocListRaw()
|
||||
function! g:SyntasticChecker.getLocListRaw() " {{{2
|
||||
let name = self._filetype . '/' . self._name
|
||||
try
|
||||
let list = self._locListFunc()
|
||||
|
@ -69,13 +69,13 @@ function! g:SyntasticChecker.getLocListRaw()
|
|||
call syntastic#log#debug(g:SyntasticDebugLoclist, name . ' raw:', list)
|
||||
call self._quietMessages(list)
|
||||
return list
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getLocList()
|
||||
function! g:SyntasticChecker.getLocList() " {{{2
|
||||
return g:SyntasticLoclist.New(self.getLocListRaw())
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.makeprgBuild(opts)
|
||||
function! g:SyntasticChecker.makeprgBuild(opts) " {{{2
|
||||
let basename = self._filetype . '_' . self._name . '_'
|
||||
|
||||
let parts = []
|
||||
|
@ -86,23 +86,42 @@ function! g:SyntasticChecker.makeprgBuild(opts)
|
|||
call extend(parts, self._getOpt(a:opts, basename, 'tail', ''))
|
||||
|
||||
return join(parts)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.isAvailable()
|
||||
function! g:SyntasticChecker.isAvailable() " {{{2
|
||||
return self._isAvailableFunc()
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticChecker._quietMessages(errors)
|
||||
let filter = 'g:syntastic_' . self._filetype . '_' . self._name . '_quiet_messages'
|
||||
if exists(filter) && type({filter}) == type({}) && !empty({filter})
|
||||
call syntastic#util#dictFilter(a:errors, {filter})
|
||||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'filtered by ' . filter . ':', a:errors)
|
||||
function! g:SyntasticChecker._quietMessages(errors) " {{{2
|
||||
" wildcard quiet_messages
|
||||
let quiet_filters = copy(syntastic#util#var('quiet_messages', {}))
|
||||
if type(quiet_filters) != type({})
|
||||
call syntastic#log#warn('ignoring invalid syntastic_quiet_messages')
|
||||
unlet quiet_filters
|
||||
let quiet_filters = {}
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticChecker._populateHighlightRegexes(errors)
|
||||
" per checker quiet_messages
|
||||
let name = self._filetype . '_' . self._name
|
||||
try
|
||||
call extend( quiet_filters, copy(syntastic#util#var(name . '_quiet_messages', {})), 'force' )
|
||||
catch /\m^Vim\%((\a\+)\)\=:E712/
|
||||
call syntastic#log#warn('ignoring invalid syntastic_' . name . '_quiet_messages')
|
||||
endtry
|
||||
|
||||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'quiet_messages filter:', quiet_filters)
|
||||
|
||||
if !empty(quiet_filters)
|
||||
call syntastic#util#dictFilter(a:errors, quiet_filters)
|
||||
call syntastic#log#debug(g:SyntasticDebugLoclist, 'filtered by quiet_messages:', a:errors)
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker._populateHighlightRegexes(errors) " {{{2
|
||||
if has_key(self, '_highlightRegexFunc')
|
||||
for e in a:errors
|
||||
if e['valid']
|
||||
|
@ -113,9 +132,9 @@ function! g:SyntasticChecker._populateHighlightRegexes(errors)
|
|||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker._getOpt(opts, basename, name, default)
|
||||
function! g:SyntasticChecker._getOpt(opts, basename, name, default) " {{{2
|
||||
let user_val = syntastic#util#var(a:basename . a:name)
|
||||
let ret = []
|
||||
call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) )
|
||||
|
@ -123,9 +142,9 @@ function! g:SyntasticChecker._getOpt(opts, basename, name, default)
|
|||
call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) )
|
||||
|
||||
return ret
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker._shescape(opt)
|
||||
function! g:SyntasticChecker._shescape(opt) " {{{2
|
||||
if type(a:opt) == type('') && a:opt != ''
|
||||
return [a:opt]
|
||||
elseif type(a:opt) == type([])
|
||||
|
@ -133,12 +152,16 @@ function! g:SyntasticChecker._shescape(opt)
|
|||
endif
|
||||
|
||||
return []
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Non-method functions {{{1
|
||||
|
||||
function! SyntasticCheckerIsAvailableDefault() dict
|
||||
function! SyntasticCheckerIsAvailableDefault() dict " {{{2
|
||||
return executable(self.getExec())
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,26 +1,22 @@
|
|||
if exists("g:loaded_syntastic_notifier_cursor")
|
||||
if exists("g:loaded_syntastic_notifier_cursor") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_cursor = 1
|
||||
|
||||
if !exists('g:syntastic_echo_current_error')
|
||||
let g:syntastic_echo_current_error = 1
|
||||
endif
|
||||
|
||||
let g:SyntasticCursorNotifier = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticCursorNotifier.New()
|
||||
function! g:SyntasticCursorNotifier.New() " {{{2
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticCursorNotifier.enabled()
|
||||
function! g:SyntasticCursorNotifier.enabled() " {{{2
|
||||
return syntastic#util#var('echo_current_error')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticCursorNotifier.refresh(loclist)
|
||||
function! g:SyntasticCursorNotifier.refresh(loclist) " {{{2
|
||||
if self.enabled() && !a:loclist.isEmpty()
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'cursor: refresh')
|
||||
let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
|
||||
|
@ -28,21 +24,23 @@ function! g:SyntasticCursorNotifier.refresh(loclist)
|
|||
autocmd! syntastic CursorMoved
|
||||
autocmd syntastic CursorMoved * call g:SyntasticRefreshCursor()
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" @vimlint(EVL103, 1, a:loclist)
|
||||
function! g:SyntasticCursorNotifier.reset(loclist)
|
||||
function! g:SyntasticCursorNotifier.reset(loclist) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'cursor: reset')
|
||||
autocmd! syntastic CursorMoved
|
||||
unlet! b:syntastic_messages
|
||||
let b:oldLine = -1
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:loclist)
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
" The following defensive nonsense is needed because of the nature of autocmd
|
||||
function! g:SyntasticRefreshCursor()
|
||||
function! g:SyntasticRefreshCursor() " {{{2
|
||||
if !exists('b:syntastic_messages') || empty(b:syntastic_messages)
|
||||
" file not checked
|
||||
return
|
||||
|
@ -62,6 +60,8 @@ function! g:SyntasticRefreshCursor()
|
|||
else
|
||||
echo
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_notifier_highlighting")
|
||||
if exists("g:loaded_syntastic_notifier_highlighting") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_highlighting = 1
|
||||
|
@ -6,17 +6,13 @@ let g:loaded_syntastic_notifier_highlighting = 1
|
|||
" Highlighting requires getmatches introduced in 7.1.040
|
||||
let s:has_highlighting = v:version > 701 || (v:version == 701 && has('patch040'))
|
||||
|
||||
if !exists("g:syntastic_enable_highlighting")
|
||||
let g:syntastic_enable_highlighting = 1
|
||||
endif
|
||||
|
||||
let g:SyntasticHighlightingNotifier = {}
|
||||
|
||||
let s:setup_done = 0
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticHighlightingNotifier.New()
|
||||
function! g:SyntasticHighlightingNotifier.New() " {{{2
|
||||
let newObj = copy(self)
|
||||
|
||||
if !s:setup_done
|
||||
|
@ -25,14 +21,14 @@ function! g:SyntasticHighlightingNotifier.New()
|
|||
endif
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticHighlightingNotifier.enabled()
|
||||
function! g:SyntasticHighlightingNotifier.enabled() " {{{2
|
||||
return s:has_highlighting && syntastic#util#var('enable_highlighting')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Sets error highlights in the cuirrent window
|
||||
function! g:SyntasticHighlightingNotifier.refresh(loclist)
|
||||
function! g:SyntasticHighlightingNotifier.refresh(loclist) " {{{2
|
||||
if self.enabled()
|
||||
call self.reset(a:loclist)
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'highlighting: refresh')
|
||||
|
@ -59,11 +55,11 @@ function! g:SyntasticHighlightingNotifier.refresh(loclist)
|
|||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Remove all error highlights from the window
|
||||
" @vimlint(EVL103, 1, a:loclist)
|
||||
function! g:SyntasticHighlightingNotifier.reset(loclist)
|
||||
function! g:SyntasticHighlightingNotifier.reset(loclist) " {{{2
|
||||
if s:has_highlighting
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'highlighting: reset')
|
||||
for match in getmatches()
|
||||
|
@ -72,13 +68,15 @@ function! g:SyntasticHighlightingNotifier.reset(loclist)
|
|||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:loclist)
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
" One time setup: define our own highlighting
|
||||
function! g:SyntasticHighlightingNotifier._setup()
|
||||
function! g:SyntasticHighlightingNotifier._setup() " {{{2
|
||||
if s:has_highlighting
|
||||
if !hlexists('SyntasticError')
|
||||
highlight link SyntasticError SpellBad
|
||||
|
@ -88,6 +86,8 @@ function! g:SyntasticHighlightingNotifier._setup()
|
|||
highlight link SyntasticWarning SpellCap
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_loclist")
|
||||
if exists("g:loaded_syntastic_loclist") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_loclist = 1
|
||||
|
@ -7,7 +7,7 @@ let g:SyntasticLoclist = {}
|
|||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticLoclist.New(rawLoclist)
|
||||
function! g:SyntasticLoclist.New(rawLoclist) " {{{2
|
||||
let newObj = copy(self)
|
||||
|
||||
let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1')
|
||||
|
@ -22,34 +22,34 @@ function! g:SyntasticLoclist.New(rawLoclist)
|
|||
let newObj._name = ''
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.current()
|
||||
function! g:SyntasticLoclist.current() " {{{2
|
||||
if !exists("b:syntastic_loclist")
|
||||
let b:syntastic_loclist = g:SyntasticLoclist.New([])
|
||||
endif
|
||||
return b:syntastic_loclist
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.extend(other)
|
||||
function! g:SyntasticLoclist.extend(other) " {{{2
|
||||
let list = self.copyRaw()
|
||||
call extend(list, a:other.copyRaw())
|
||||
return g:SyntasticLoclist.New(list)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.isEmpty()
|
||||
function! g:SyntasticLoclist.isEmpty() " {{{2
|
||||
return empty(self._rawLoclist)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.copyRaw()
|
||||
function! g:SyntasticLoclist.copyRaw() " {{{2
|
||||
return copy(self._rawLoclist)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.getRaw()
|
||||
function! g:SyntasticLoclist.getRaw() " {{{2
|
||||
return self._rawLoclist
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.getStatuslineFlag()
|
||||
function! g:SyntasticLoclist.getStatuslineFlag() " {{{2
|
||||
if !exists("self._stl_format")
|
||||
let self._stl_format = ''
|
||||
endif
|
||||
|
@ -100,52 +100,48 @@ function! g:SyntasticLoclist.getStatuslineFlag()
|
|||
endif
|
||||
|
||||
return self._stl_flag
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.getFirstIssue()
|
||||
function! g:SyntasticLoclist.getFirstIssue() " {{{2
|
||||
return get(self._rawLoclist, 0, {})
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.getName()
|
||||
function! g:SyntasticLoclist.getName() " {{{2
|
||||
return len(self._name)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.setName(name)
|
||||
function! g:SyntasticLoclist.setName(name) " {{{2
|
||||
let self._name = a:name
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.decorate(name, filetype)
|
||||
function! g:SyntasticLoclist.decorate(filetype, name) " {{{2
|
||||
for e in self._rawLoclist
|
||||
let e['text'] .= ' [' . a:filetype . '/' . a:name . ']'
|
||||
endfor
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.quietMessages(filters)
|
||||
call syntastic#util#dictFilter(self._rawLoclist, a:filters)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.errors()
|
||||
function! g:SyntasticLoclist.errors() " {{{2
|
||||
if !exists("self._cachedErrors")
|
||||
let self._cachedErrors = self.filter({'type': "E"})
|
||||
endif
|
||||
return self._cachedErrors
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.warnings()
|
||||
function! g:SyntasticLoclist.warnings() " {{{2
|
||||
if !exists("self._cachedWarnings")
|
||||
let self._cachedWarnings = self.filter({'type': "W"})
|
||||
endif
|
||||
return self._cachedWarnings
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Legacy function. Syntastic no longer calls it, but we keep it
|
||||
" around because other plugins (f.i. powerline) depend on it.
|
||||
function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay()
|
||||
function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay() " {{{2
|
||||
return !self.isEmpty()
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" cache used by EchoCurrentError()
|
||||
function! g:SyntasticLoclist.messages(buf)
|
||||
function! g:SyntasticLoclist.messages(buf) " {{{2
|
||||
if !exists("self._cachedMessages")
|
||||
let self._cachedMessages = {}
|
||||
let errors = self.errors() + self.warnings()
|
||||
|
@ -165,7 +161,7 @@ function! g:SyntasticLoclist.messages(buf)
|
|||
endif
|
||||
|
||||
return get(self._cachedMessages, a:buf, {})
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"Filter the list and return new native loclist
|
||||
"e.g.
|
||||
|
@ -174,14 +170,14 @@ endfunction
|
|||
"would return all errors for buffer 10.
|
||||
"
|
||||
"Note that all comparisons are done with ==?
|
||||
function! g:SyntasticLoclist.filter(filters)
|
||||
function! g:SyntasticLoclist.filter(filters) " {{{2
|
||||
let conditions = values(map(copy(a:filters), 's:translate(v:key, v:val)'))
|
||||
let filter = len(conditions) == 1 ?
|
||||
\ conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
|
||||
return filter(copy(self._rawLoclist), filter)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.setloclist()
|
||||
function! g:SyntasticLoclist.setloclist() " {{{2
|
||||
if !exists('w:syntastic_loclist_set')
|
||||
let w:syntastic_loclist_set = 0
|
||||
endif
|
||||
|
@ -189,16 +185,16 @@ function! g:SyntasticLoclist.setloclist()
|
|||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: setloclist ' . (replace ? '(replace)' : '(new)'))
|
||||
call setloclist(0, self.getRaw(), replace ? 'r' : ' ')
|
||||
let w:syntastic_loclist_set = 1
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
"display the cached errors for this buf in the location list
|
||||
function! g:SyntasticLoclist.show()
|
||||
function! g:SyntasticLoclist.show() " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: show')
|
||||
call self.setloclist()
|
||||
|
||||
if !self.isEmpty()
|
||||
let num = winnr()
|
||||
execute "lopen " . g:syntastic_loc_list_height
|
||||
execute "lopen " . syntastic#util#var('loc_list_height')
|
||||
if num != winnr()
|
||||
wincmd p
|
||||
endif
|
||||
|
@ -220,19 +216,25 @@ function! g:SyntasticLoclist.show()
|
|||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Non-method functions {{{1
|
||||
|
||||
function! g:SyntasticLoclistHide()
|
||||
function! g:SyntasticLoclistHide() " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: hide')
|
||||
silent! lclose
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
function! s:translate(key, val)
|
||||
function! s:translate(key, val) " {{{2
|
||||
return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_modemap")
|
||||
if exists("g:loaded_syntastic_modemap") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_modemap = 1
|
||||
|
@ -7,16 +7,16 @@ let g:SyntasticModeMap = {}
|
|||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticModeMap.Instance()
|
||||
function! g:SyntasticModeMap.Instance() " {{{2
|
||||
if !exists('s:SyntasticModeMapInstance')
|
||||
let s:SyntasticModeMapInstance = copy(self)
|
||||
call s:SyntasticModeMapInstance.synch()
|
||||
endif
|
||||
|
||||
return s:SyntasticModeMapInstance
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticModeMap.synch()
|
||||
function! g:SyntasticModeMap.synch() " {{{2
|
||||
if exists('g:syntastic_mode_map')
|
||||
let self._mode = get(g:syntastic_mode_map, 'mode', 'active')
|
||||
let self._activeFiletypes = get(g:syntastic_mode_map, 'active_filetypes', [])
|
||||
|
@ -26,9 +26,9 @@ function! g:SyntasticModeMap.synch()
|
|||
let self._activeFiletypes = []
|
||||
let self._passiveFiletypes = []
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticModeMap.allowsAutoChecking(filetype)
|
||||
function! g:SyntasticModeMap.allowsAutoChecking(filetype) " {{{2
|
||||
let fts = split(a:filetype, '\m\.')
|
||||
|
||||
if self.isPassive()
|
||||
|
@ -36,13 +36,13 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype)
|
|||
else
|
||||
return self._noFiletypesArePassive(fts)
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticModeMap.isPassive()
|
||||
function! g:SyntasticModeMap.isPassive() " {{{2
|
||||
return self._mode ==# 'passive'
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticModeMap.toggleMode()
|
||||
function! g:SyntasticModeMap.toggleMode() " {{{2
|
||||
call self.synch()
|
||||
|
||||
if self._mode ==# 'active'
|
||||
|
@ -56,20 +56,24 @@ function! g:SyntasticModeMap.toggleMode()
|
|||
let g:syntastic_mode_map = {}
|
||||
endif
|
||||
let g:syntastic_mode_map['mode'] = self._mode
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticModeMap.echoMode()
|
||||
function! g:SyntasticModeMap.echoMode() " {{{2
|
||||
echo "Syntastic: " . self._mode . " mode enabled"
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes)
|
||||
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes) " {{{2
|
||||
return !empty(filter(copy(a:filetypes), 'index(self._activeFiletypes, v:val) != -1'))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes)
|
||||
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes) " {{{2
|
||||
return empty(filter(copy(a:filetypes), 'index(self._passiveFiletypes, v:val) != -1'))
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if exists("g:loaded_syntastic_notifiers")
|
||||
if exists("g:loaded_syntastic_notifiers") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifiers = 1
|
||||
|
@ -9,16 +9,16 @@ let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autolocl
|
|||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticNotifiers.Instance()
|
||||
function! g:SyntasticNotifiers.Instance() " {{{2
|
||||
if !exists('s:SyntasticNotifiersInstance')
|
||||
let s:SyntasticNotifiersInstance = copy(self)
|
||||
call s:SyntasticNotifiersInstance._initNotifiers()
|
||||
endif
|
||||
|
||||
return s:SyntasticNotifiersInstance
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticNotifiers.refresh(loclist)
|
||||
function! g:SyntasticNotifiers.refresh(loclist) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'notifiers: refresh')
|
||||
for type in self._enabled_types
|
||||
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
||||
|
@ -26,9 +26,9 @@ function! g:SyntasticNotifiers.refresh(loclist)
|
|||
call self._notifier[type].refresh(a:loclist)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticNotifiers.reset(loclist)
|
||||
function! g:SyntasticNotifiers.reset(loclist) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'notifiers: reset')
|
||||
for type in self._enabled_types
|
||||
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
||||
|
@ -40,11 +40,13 @@ function! g:SyntasticNotifiers.reset(loclist)
|
|||
call self._notifier[type].reset(a:loclist)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticNotifiers._initNotifiers()
|
||||
function! g:SyntasticNotifiers._initNotifiers() " {{{2
|
||||
let self._notifier = {}
|
||||
for type in s:notifier_types
|
||||
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
||||
|
@ -52,6 +54,8 @@ function! g:SyntasticNotifiers._initNotifiers()
|
|||
endfor
|
||||
|
||||
let self._enabled_types = copy(s:notifier_types)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
if exists("g:loaded_syntastic_registry")
|
||||
if exists("g:loaded_syntastic_registry") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_registry = 1
|
||||
|
||||
" Initialisation {{{1
|
||||
|
||||
let s:defaultCheckers = {
|
||||
\ 'actionscript':['mxmlc'],
|
||||
\ 'ada': ['gcc'],
|
||||
|
@ -95,188 +97,167 @@ let s:defaultFiletypeMap = {
|
|||
|
||||
let g:SyntasticRegistry = {}
|
||||
|
||||
" }}}1
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
" TODO: Handling of filetype aliases: all public methods take aliases as
|
||||
" parameters, all private methods take normalized filetypes. Public methods
|
||||
" are thus supposed to normalize filetypes before calling private methods.
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticRegistry.Instance()
|
||||
function! g:SyntasticRegistry.Instance() " {{{2
|
||||
if !exists('s:SyntasticRegistryInstance')
|
||||
let s:SyntasticRegistryInstance = copy(self)
|
||||
let s:SyntasticRegistryInstance._checkerRaw = {}
|
||||
let s:SyntasticRegistryInstance._checkerMap = {}
|
||||
let s:SyntasticRegistryInstance._cachedCheckersFor = {}
|
||||
endif
|
||||
|
||||
return s:SyntasticRegistryInstance
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.CreateAndRegisterChecker(args)
|
||||
function! g:SyntasticRegistry.CreateAndRegisterChecker(args) " {{{2
|
||||
let checker = g:SyntasticChecker.New(a:args)
|
||||
let registry = g:SyntasticRegistry.Instance()
|
||||
call registry._registerChecker(checker)
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.checkable(ftalias)
|
||||
return !empty(self.getActiveCheckers(a:ftalias))
|
||||
endfunction
|
||||
function! g:SyntasticRegistry.isCheckable(ftalias) " {{{2
|
||||
let ft = s:normaliseFiletype(a:ftalias)
|
||||
call self._loadCheckers(ft)
|
||||
return !empty(self._checkerMap[ft])
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.getActiveCheckers(ftalias)
|
||||
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
|
||||
let checkers = self.availableCheckersFor(a:ftalias)
|
||||
function! g:SyntasticRegistry.getCheckersMap(ftalias) " {{{2
|
||||
let ft = s:normaliseFiletype(a:ftalias)
|
||||
call self._loadCheckers(ft)
|
||||
return self._checkerMap[ft]
|
||||
endfunction " }}}2
|
||||
|
||||
if self._userHasFiletypeSettings(filetype)
|
||||
return self._filterCheckersByUserSettings(checkers, filetype)
|
||||
function! g:SyntasticRegistry.getCheckers(ftalias, list) " {{{2
|
||||
let checkers_map = self.getCheckersMap(a:ftalias)
|
||||
if empty(checkers_map)
|
||||
return []
|
||||
endif
|
||||
|
||||
if has_key(s:defaultCheckers, filetype)
|
||||
return self._filterCheckersByDefaultSettings(checkers, filetype)
|
||||
endif
|
||||
let ft = s:normaliseFiletype(a:ftalias)
|
||||
call self._checkDeprecation(ft)
|
||||
|
||||
return checkers[0:0]
|
||||
endfunction
|
||||
let ft_list =
|
||||
\ !empty(a:list) ? a:list :
|
||||
\ exists('b:syntastic_checkers') ? b:syntastic_checkers :
|
||||
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
|
||||
\ get(s:defaultCheckers, ft, [])
|
||||
|
||||
function! g:SyntasticRegistry.getCheckers(ftalias, list)
|
||||
return self._filterCheckersByName(self.availableCheckersFor(a:ftalias), a:list)
|
||||
endfunction
|
||||
return !empty(ft_list) ?
|
||||
\ self._filterCheckersByName(checkers_map, ft_list) : [checkers_map[keys(checkers_map)[0]]]
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.availableCheckersFor(ftalias)
|
||||
if !has_key(self._cachedCheckersFor, a:ftalias)
|
||||
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
|
||||
let checkers = self._allCheckersFor(filetype)
|
||||
let self._cachedCheckersFor[a:ftalias] = self._filterCheckersByAvailability(checkers)
|
||||
endif
|
||||
|
||||
return self._cachedCheckersFor[a:ftalias]
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.knownFiletypes()
|
||||
function! g:SyntasticRegistry.getKnownFiletypes() " {{{2
|
||||
let types = keys(s:defaultCheckers)
|
||||
|
||||
call extend(types, keys(s:defaultFiletypeMap))
|
||||
|
||||
if exists('g:syntastic_filetype_map')
|
||||
call extend(types, keys(g:syntastic_filetype_map))
|
||||
endif
|
||||
|
||||
if exists('g:syntastic_extra_filetypes') && type(g:syntastic_extra_filetypes) == type([])
|
||||
call extend(types, g:syntastic_extra_filetypes)
|
||||
endif
|
||||
return syntastic#util#unique(types)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.echoInfoFor(ftalias_list)
|
||||
return syntastic#util#unique(types)
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) " {{{2
|
||||
echomsg "Syntastic info for filetype: " . join(a:ftalias_list, '.')
|
||||
|
||||
let available = []
|
||||
let active = []
|
||||
for ftalias in a:ftalias_list
|
||||
call extend(available, self.availableCheckersFor(ftalias))
|
||||
call extend(active, self.getActiveCheckers(ftalias))
|
||||
endfor
|
||||
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:normaliseFiletype(v:val)' ))
|
||||
if len(ft_list) != 1
|
||||
let available = []
|
||||
let active = []
|
||||
|
||||
echomsg "Available checker(s): " . join(syntastic#util#unique(map(available, "v:val.getName()")))
|
||||
echomsg "Currently enabled checker(s): " . join(syntastic#util#unique(map(active, "v:val.getName()")))
|
||||
endfunction
|
||||
for ft in ft_list
|
||||
call extend(available, map( keys(self.getCheckersMap(ft)), 'ft . "/" . v:val' ))
|
||||
call extend(active, map( self.getCheckers(ft, []), 'ft . "/" . v:val.getName()' ))
|
||||
endfor
|
||||
else
|
||||
let ft = ft_list[0]
|
||||
let available = keys(self.getCheckersMap(ft))
|
||||
let active = map(self.getCheckers(ft, []), 'v:val.getName()')
|
||||
endif
|
||||
|
||||
echomsg "Available checker(s): " . join(sort(available))
|
||||
echomsg "Currently enabled checker(s): " . join(active)
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticRegistry._registerChecker(checker) abort
|
||||
function! g:SyntasticRegistry._registerChecker(checker) abort " {{{2
|
||||
let ft = a:checker.getFiletype()
|
||||
|
||||
if !has_key(self._checkerMap, ft)
|
||||
let self._checkerMap[ft] = []
|
||||
if !has_key(self._checkerRaw, ft)
|
||||
let self._checkerRaw[ft] = []
|
||||
let self._checkerMap[ft] = {}
|
||||
endif
|
||||
|
||||
call self._validateUniqueName(a:checker)
|
||||
|
||||
call add(self._checkerMap[ft], a:checker)
|
||||
endfunction
|
||||
let name = a:checker.getName()
|
||||
call add(self._checkerRaw[ft], name)
|
||||
|
||||
function! g:SyntasticRegistry._allCheckersFor(filetype)
|
||||
call self._loadCheckers(a:filetype)
|
||||
if empty(self._checkerMap[a:filetype])
|
||||
return []
|
||||
if a:checker.isAvailable()
|
||||
let self._checkerMap[ft][name] = a:checker
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
return self._checkerMap[a:filetype]
|
||||
endfunction
|
||||
function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) " {{{2
|
||||
return filter( map(copy(a:list), 'get(a:checkers_map, v:val, {})'), '!empty(v:val)' )
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
|
||||
if has_key(s:defaultCheckers, a:filetype)
|
||||
return self._filterCheckersByName(a:checkers, s:defaultCheckers[a:filetype])
|
||||
endif
|
||||
|
||||
return a:checkers
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByUserSettings(checkers, filetype)
|
||||
if exists("b:syntastic_checkers")
|
||||
let whitelist = b:syntastic_checkers
|
||||
else
|
||||
let whitelist = g:syntastic_{a:filetype}_checkers
|
||||
endif
|
||||
return self._filterCheckersByName(a:checkers, whitelist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByName(checkers, list)
|
||||
let checkers_by_name = {}
|
||||
for c in a:checkers
|
||||
let checkers_by_name[c.getName()] = c
|
||||
endfor
|
||||
|
||||
let filtered = []
|
||||
for name in a:list
|
||||
if has_key(checkers_by_name, name)
|
||||
call add(filtered, checkers_by_name[name])
|
||||
endif
|
||||
endfor
|
||||
|
||||
return filtered
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
|
||||
return filter(copy(a:checkers), "v:val.isAvailable()")
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._loadCheckers(filetype)
|
||||
if self._haveLoadedCheckers(a:filetype)
|
||||
function! g:SyntasticRegistry._loadCheckers(filetype) " {{{2
|
||||
if has_key(self._checkerRaw, a:filetype)
|
||||
return
|
||||
endif
|
||||
|
||||
execute "runtime! syntax_checkers/" . a:filetype . "/*.vim"
|
||||
|
||||
if !has_key(self._checkerMap, a:filetype)
|
||||
let self._checkerMap[a:filetype] = []
|
||||
if !has_key(self._checkerRaw, a:filetype)
|
||||
let self._checkerRaw[a:filetype] = []
|
||||
let self._checkerMap[a:filetype] = {}
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry._haveLoadedCheckers(filetype)
|
||||
return has_key(self._checkerMap, a:filetype)
|
||||
endfunction
|
||||
function! g:SyntasticRegistry._validateUniqueName(checker) abort " {{{2
|
||||
let ft = a:checker.getFiletype()
|
||||
let name = a:checker.getName()
|
||||
if index(self._checkerRaw[ft], name) > -1
|
||||
throw 'Syntastic: Duplicate syntax checker name: ' . ft . '/' . name
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry._userHasFiletypeSettings(filetype)
|
||||
if exists("g:syntastic_" . a:filetype . "_checker") && !exists("g:syntastic_" . a:filetype . "_checkers")
|
||||
" Check for obsolete variable g:syntastic_<filetype>_checker
|
||||
function! g:SyntasticRegistry._checkDeprecation(filetype) " {{{2
|
||||
if exists('g:syntastic_' . a:filetype . '_checker') && !exists('g:syntastic_' . a:filetype . '_checkers')
|
||||
let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker]
|
||||
call syntastic#log#deprecationWarn("variable g:syntastic_" . a:filetype . "_checker is deprecated")
|
||||
call syntastic#log#deprecationWarn('variable g:syntastic_' . a:filetype . '_checker is deprecated')
|
||||
endif
|
||||
return exists("b:syntastic_checkers") || exists("g:syntastic_" . a:filetype . "_checkers")
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry._validateUniqueName(checker) abort
|
||||
for checker in self._allCheckersFor(a:checker.getFiletype())
|
||||
if checker.getName() ==# a:checker.getName()
|
||||
throw "Syntastic: Duplicate syntax checker name for: " . a:checker.getName()
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
"resolve filetype aliases, and replace - with _ otherwise we cant name
|
||||
"syntax checker functions legally for filetypes like "gentoo-metadata"
|
||||
function! s:SyntasticRegistryNormaliseFiletype(ftalias)
|
||||
function! s:normaliseFiletype(ftalias) " {{{2
|
||||
let ft = get(s:defaultFiletypeMap, a:ftalias, a:ftalias)
|
||||
let ft = get(g:syntastic_filetype_map, ft, ft)
|
||||
let ft = substitute(ft, '\m-', '_', 'g')
|
||||
return ft
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -1,28 +1,9 @@
|
|||
if exists("g:loaded_syntastic_notifier_signs")
|
||||
if exists("g:loaded_syntastic_notifier_signs") || !exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_signs = 1
|
||||
|
||||
if !exists("g:syntastic_enable_signs")
|
||||
let g:syntastic_enable_signs = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_error_symbol")
|
||||
let g:syntastic_error_symbol = '>>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_warning_symbol")
|
||||
let g:syntastic_warning_symbol = '>>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_style_error_symbol")
|
||||
let g:syntastic_style_error_symbol = 'S>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_style_warning_symbol")
|
||||
let g:syntastic_style_warning_symbol = 'S>'
|
||||
endif
|
||||
|
||||
" Initialisation {{{1
|
||||
|
||||
" start counting sign ids at 5000, start here to hopefully avoid conflicting
|
||||
" with any other code that places signs (not sure if this precaution is
|
||||
|
@ -34,9 +15,11 @@ let g:SyntasticSignsNotifier = {}
|
|||
|
||||
let s:setup_done = 0
|
||||
|
||||
" }}}1
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticSignsNotifier.New()
|
||||
function! g:SyntasticSignsNotifier.New() " {{{2
|
||||
let newObj = copy(self)
|
||||
|
||||
if !s:setup_done
|
||||
|
@ -45,13 +28,13 @@ function! g:SyntasticSignsNotifier.New()
|
|||
endif
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticSignsNotifier.enabled()
|
||||
function! g:SyntasticSignsNotifier.enabled() " {{{2
|
||||
return has('signs') && syntastic#util#var('enable_signs')
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticSignsNotifier.refresh(loclist)
|
||||
function! g:SyntasticSignsNotifier.refresh(loclist) " {{{2
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'signs: refresh')
|
||||
let old_signs = copy(self._bufSignIds())
|
||||
if self.enabled()
|
||||
|
@ -59,12 +42,14 @@ function! g:SyntasticSignsNotifier.refresh(loclist)
|
|||
endif
|
||||
call self._removeSigns(old_signs)
|
||||
let s:first_sign_id = s:next_sign_id
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
" One time setup: define our own sign types and highlighting
|
||||
function! g:SyntasticSignsNotifier._setup()
|
||||
function! g:SyntasticSignsNotifier._setup() " {{{2
|
||||
if has('signs')
|
||||
if !hlexists('SyntasticErrorSign')
|
||||
highlight link SyntasticErrorSign error
|
||||
|
@ -95,10 +80,10 @@ function! g:SyntasticSignsNotifier._setup()
|
|||
exe 'sign define SyntasticStyleWarning text=' . g:syntastic_style_warning_symbol .
|
||||
\ ' texthl=SyntasticStyleWarningSign linehl=SyntasticStyleWarningLine'
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Place signs by all syntax errors in the buffer
|
||||
function! g:SyntasticSignsNotifier._signErrors(loclist)
|
||||
function! g:SyntasticSignsNotifier._signErrors(loclist) " {{{2
|
||||
let loclist = a:loclist
|
||||
if !loclist.isEmpty()
|
||||
|
||||
|
@ -123,24 +108,26 @@ function! g:SyntasticSignsNotifier._signErrors(loclist)
|
|||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Remove the signs with the given ids from this buffer
|
||||
function! g:SyntasticSignsNotifier._removeSigns(ids)
|
||||
function! g:SyntasticSignsNotifier._removeSigns(ids) " {{{2
|
||||
if has('signs')
|
||||
for i in a:ids
|
||||
execute "sign unplace " . i
|
||||
call remove(self._bufSignIds(), index(self._bufSignIds(), i))
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" Get all the ids of the SyntaxError signs in the buffer
|
||||
function! g:SyntasticSignsNotifier._bufSignIds()
|
||||
function! g:SyntasticSignsNotifier._bufSignIds() " {{{2
|
||||
if !exists("b:syntastic_sign_ids")
|
||||
let b:syntastic_sign_ids = []
|
||||
endif
|
||||
return b:syntastic_sign_ids
|
||||
endfunction
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
|
@ -28,10 +28,6 @@ endif
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_c_cppcheck_Preprocess(errors)
|
||||
return map(copy(a:errors), 'substitute(v:val, ''\v^\[[^]]+\]\zs( -\> \[[^]]+\])+\ze:'', "", "")')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_c_cppcheck_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args': syntastic#c#ReadConfig(g:syntastic_cppcheck_config_file),
|
||||
|
@ -50,7 +46,7 @@ function! SyntaxCheckers_c_cppcheck_GetLocList() dict
|
|||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'SyntaxCheckers_c_cppcheck_Preprocess',
|
||||
\ 'preprocess': 'cppcheck',
|
||||
\ 'returns': [0] })
|
||||
|
||||
for e in loclist
|
||||
|
|
|
@ -54,7 +54,7 @@ function! s:GhcModNew(exe)
|
|||
try
|
||||
let ghc_mod_version = filter(split(system(exe), '\n'), 'v:val =~# ''\m^ghc-mod version''')[0]
|
||||
let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(ghc_mod_version), [2, 1, 2])
|
||||
catch /^Vim\%((\a\+)\)\=:E684/
|
||||
catch /\m^Vim\%((\a\+)\)\=:E684/
|
||||
call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)")
|
||||
let ret = -1
|
||||
endtry
|
||||
|
|
|
@ -42,7 +42,8 @@ function! SyntaxCheckers_html_jshint_GetLocList() dict
|
|||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr('')} })
|
||||
\ 'defaults': {'bufnr': bufnr('')},
|
||||
\ 'returns': [0, 2] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
|
|
@ -48,21 +48,6 @@ endif
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_html_validator_Preprocess(errors)
|
||||
let out = []
|
||||
for e in a:errors
|
||||
let parts = matchlist(e, '\v^"([^"]+)"(.+)')
|
||||
if len(parts) >= 3
|
||||
" URL decode, except leave alone any "+"
|
||||
let parts[1] = substitute(parts[1], '\m%\(\x\x\)', '\=nr2char("0x".submatch(1))', 'g')
|
||||
let parts[1] = substitute(parts[1], '\m\\"', '"', 'g')
|
||||
let parts[1] = substitute(parts[1], '\m\\\\', '\\', 'g')
|
||||
call add(out, '"' . parts[1] . '"' . parts[2])
|
||||
endif
|
||||
endfor
|
||||
return out
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_validator_GetLocList() dict
|
||||
let fname = syntastic#util#shexpand('%')
|
||||
let makeprg = self.getExecEscaped() . ' -s --compressed -F out=gnu -F asciiquotes=yes' .
|
||||
|
@ -87,7 +72,7 @@ function! SyntaxCheckers_html_validator_GetLocList() dict
|
|||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'SyntaxCheckers_html_validator_Preprocess',
|
||||
\ 'preprocess': 'validator',
|
||||
\ 'returns': [0] })
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -27,33 +27,6 @@ endif
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_java_checkstyle_Preprocess(errors)
|
||||
let out = []
|
||||
let fname = expand('%')
|
||||
for err in a:errors
|
||||
if match(err, '\m<error\>') > -1
|
||||
let line = str2nr(matchstr(err, '\m\<line="\zs\d\+\ze"'))
|
||||
if line == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let col = str2nr(matchstr(err, '\m\<column="\zs\d\+\ze"'))
|
||||
|
||||
let type = matchstr(err, '\m\<severity="\zs.\ze')
|
||||
if type !~? '^[EW]'
|
||||
let type = 'E'
|
||||
endif
|
||||
|
||||
let message = syntastic#util#decodeXMLEntities(matchstr(err, '\m\<message="\zs[^"]\+\ze"'))
|
||||
|
||||
call add(out, join([fname, type, line, col, message], ':'))
|
||||
elseif match(err, '\m<file name="') > -1
|
||||
let fname = syntastic#util#decodeXMLEntities(matchstr(err, '\v\<file name\="\zs[^"]+\ze"'))
|
||||
endif
|
||||
endfor
|
||||
return out
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_java_checkstyle_GetLocList() dict
|
||||
|
||||
let fname = syntastic#util#shescape( expand('%:p:h') . '/' . expand('%:t') )
|
||||
|
@ -73,8 +46,8 @@ function! SyntaxCheckers_java_checkstyle_GetLocList() dict
|
|||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'preprocess': 'SyntaxCheckers_java_checkstyle_Preprocess' })
|
||||
\ 'preprocess': 'checkstyle',
|
||||
\ 'subtype': 'Style' })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
|
|
@ -17,9 +17,6 @@ let g:loaded_syntastic_javascript_jscs_checker = 1
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" we borrow SyntaxCheckers_java_checkstyle_Preprocess() from java/checkstyle
|
||||
runtime! syntax_checkers/java/*.vim
|
||||
|
||||
function! SyntaxCheckers_javascript_jscs_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({ 'args_after': '--no-colors --reporter checkstyle' })
|
||||
let errorformat = '%f:%t:%l:%c:%m'
|
||||
|
@ -27,9 +24,9 @@ function! SyntaxCheckers_javascript_jscs_GetLocList() dict
|
|||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'preprocess': 'SyntaxCheckers_java_checkstyle_Preprocess',
|
||||
\ 'preprocess': 'checkstyle',
|
||||
\ 'postprocess': ['sort'],
|
||||
\ 'returns': [0] })
|
||||
\ 'returns': [0, 2] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
|
|
@ -47,7 +47,8 @@ function! SyntaxCheckers_javascript_jshint_GetLocList() dict
|
|||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr('')} })
|
||||
\ 'defaults': {'bufnr': bufnr('')},
|
||||
\ 'returns': [0, 2] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
"============================================================================
|
||||
"File: jsxhint.vim
|
||||
"Description: Javascript syntax checker - using jsxhint
|
||||
"Maintainer: Thomas Boyt <me@thomasboyt.com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
|
||||
if exists('g:loaded_syntastic_javascript_jsxhint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_javascript_jsxhint_checker = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_javascript_jsxhint_IsAvailable() dict
|
||||
if !executable('jshint') || !syntastic#util#versionIsAtLeast(syntastic#util#getVersion('jshint --version'), [1, 1])
|
||||
return 0
|
||||
endif
|
||||
|
||||
let jsxhint_version = system(self.getExecEscaped() . ' --version')
|
||||
return
|
||||
\ v:shell_error == 0 &&
|
||||
\ jsxhint_version =~# '\m^JSXHint\>' &&
|
||||
\ syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(jsxhint_version), [0, 4, 1])
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_jsxhint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args_after': '--verbose' })
|
||||
|
||||
let errorformat = '%A%f: line %l\, col %v\, %m \(%t%*\d\)'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'javascript',
|
||||
\ 'name': 'jsxhint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -44,19 +44,6 @@ function! SyntaxCheckers_perl_perl_IsAvailable() dict
|
|||
return v:shell_error == 0
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_perl_perl_Preprocess(errors)
|
||||
let out = []
|
||||
|
||||
for e in a:errors
|
||||
let parts = matchlist(e, '\v^(.*)\sat\s(.*)\sline\s(\d+)(.*)$')
|
||||
if !empty(parts)
|
||||
call add(out, parts[2] . ':' . parts[3] . ':' . parts[1] . parts[4])
|
||||
endif
|
||||
endfor
|
||||
|
||||
return syntastic#util#unique(out)
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_perl_perl_GetLocList() dict
|
||||
let exe = expand(g:syntastic_perl_interpreter)
|
||||
if type(g:syntastic_perl_lib_path) == type('')
|
||||
|
@ -78,7 +65,7 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict
|
|||
let errors = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'SyntaxCheckers_perl_perl_Preprocess',
|
||||
\ 'preprocess': 'perl',
|
||||
\ 'defaults': {'type': 'E'} })
|
||||
if !empty(errors)
|
||||
return errors
|
||||
|
@ -91,7 +78,7 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict
|
|||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'SyntaxCheckers_perl_perl_Preprocess',
|
||||
\ 'preprocess': 'perl',
|
||||
\ 'defaults': {'type': 'W'} })
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ set cpo&vim
|
|||
|
||||
function! SyntaxCheckers_php_phpcs_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args_after': '--report=csv --tab-width=' . &tabstop })
|
||||
\ 'args': '--tab-width=' . &tabstop,
|
||||
\ 'args_after': '--report=csv' })
|
||||
|
||||
let errorformat =
|
||||
\ '%-GFile\,Line\,Column\,Type\,Message\,Source\,Severity,'.
|
||||
|
@ -37,7 +38,7 @@ endfunction
|
|||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'php',
|
||||
\ 'name': 'phpcs'})
|
||||
\ 'name': 'phpcs' })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
|
|
@ -13,11 +13,6 @@ let g:loaded_syntastic_python_pep257_checker = 1
|
|||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" sanity: kill empty lines here rather than munging errorformat
|
||||
function! SyntaxCheckers_python_pep257_Preprocess(errors)
|
||||
return filter(copy(a:errors), 'v:val != ""')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pep257_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({})
|
||||
|
||||
|
@ -30,7 +25,7 @@ function! SyntaxCheckers_python_pep257_GetLocList() dict
|
|||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'preprocess': 'SyntaxCheckers_python_pep257_Preprocess',
|
||||
\ 'preprocess': 'killEmpty',
|
||||
\ 'postprocess': ['compressWhitespace'] })
|
||||
|
||||
" pep257 outputs byte offsets rather than column numbers
|
||||
|
|
|
@ -45,6 +45,7 @@ function! SyntaxCheckers_python_pyflakes_GetLocList() dict
|
|||
let errorformat =
|
||||
\ '%E%f:%l: could not compile,'.
|
||||
\ '%-Z%p^,'.
|
||||
\ '%E%f:%l:%c: %m,'.
|
||||
\ '%E%f:%l: %m,'.
|
||||
\ '%-G%.%#'
|
||||
|
||||
|
|
|
@ -62,11 +62,13 @@ function! s:PylintNew(exe)
|
|||
let exe = syntastic#util#shescape(a:exe)
|
||||
try
|
||||
" On Windows the version is shown as "pylint-script.py 1.0.0".
|
||||
" On Gentoo Linux it's "pylint-python2.7 0.28.0". Oh, joy. :)
|
||||
let pylint_version = filter(split(system(exe . ' --version'), '\m, \=\|\n'), 'v:val =~# ''\m^pylint\>''')[0]
|
||||
" On Gentoo Linux it's "pylint-python2.7 0.28.0".
|
||||
" On NixOS, that would be ".pylint-wrapped 0.26.0", that would be.
|
||||
" Have you guys considered switching to creative writing yet? ;)
|
||||
let pylint_version = filter(split(system(exe . ' --version'), '\m, \=\|\n'), 'v:val =~# ''\m^\.\=pylint\>''')[0]
|
||||
let pylint_version = substitute(pylint_version, '\v^\S+\s+', '', '')
|
||||
let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1])
|
||||
catch /^Vim\%((\a\+)\)\=:E684/
|
||||
catch /\m^Vim\%((\a\+)\)\=:E684/
|
||||
call syntastic#log#error("checker python/pylint: can't parse version string (abnormal termination?)")
|
||||
let ret = -1
|
||||
endtry
|
||||
|
|
|
@ -41,12 +41,11 @@ endfunction
|
|||
|
||||
function! s:ForwardToZshChecker()
|
||||
let registry = g:SyntasticRegistry.Instance()
|
||||
if registry.checkable('zsh')
|
||||
if registry.isCheckable('zsh')
|
||||
return registry.getCheckers('zsh', ['zsh'])[0].getLocListRaw()
|
||||
else
|
||||
return []
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:IsShellValid()
|
||||
|
|
|
@ -40,7 +40,7 @@ function! SyntaxCheckers_vim_vimlint_IsAvailable() dict
|
|||
try
|
||||
call vimlint#vimlint(syntastic#util#DevNull(), { 'output': [], 'quiet': 1 })
|
||||
let ret = 1
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
catch /\m^Vim\%((\a\+)\)\=:E117/
|
||||
" do nothing
|
||||
endtry
|
||||
return ret
|
||||
|
|
|
@ -69,7 +69,8 @@ endfunction
|
|||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'yaml',
|
||||
\ 'name': 'yamlxs' })
|
||||
\ 'name': 'yamlxs',
|
||||
\ 'exec': 'perl' })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
|
|
@ -168,7 +168,8 @@ function! airline#extensions#load()
|
|||
endif
|
||||
|
||||
if (get(g:, 'airline#extensions#branch#enabled', 1) && get(g:, 'airline_enable_branch', 1))
|
||||
\ && (exists('*fugitive#head') || exists('*lawrencium#statusline'))
|
||||
\ && (exists('*fugitive#head') || exists('*lawrencium#statusline') ||
|
||||
\ (get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine')))
|
||||
call airline#extensions#branch#init(s:ext)
|
||||
endif
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ endfunction
|
|||
function! s:check_in_path()
|
||||
if !exists('b:airline_branch_path')
|
||||
let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', ''))
|
||||
let bufferpath = resolve(fnamemodify(expand('%'), ':p:h'))
|
||||
let bufferpath = resolve(fnamemodify(expand('%'), ':p'))
|
||||
|
||||
if !filereadable(root) "not a file
|
||||
" if .git is a directory, it's the old submodule format
|
||||
|
|
|
@ -31,6 +31,7 @@ function! airline#extensions#tabline#init(ext)
|
|||
|
||||
autocmd User AirlineToggledOn call s:toggle_on()
|
||||
autocmd User AirlineToggledOff call s:toggle_off()
|
||||
autocmd BufDelete * let s:current_bufnr = -1
|
||||
|
||||
call s:toggle_on()
|
||||
call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
|
||||
|
|
|
@ -23,9 +23,15 @@ function! airline#extensions#tagbar#inactive_apply(...)
|
|||
endif
|
||||
endfunction
|
||||
|
||||
let s:airline_tagbar_last_lookup_time = 0
|
||||
let s:airline_tagbar_last_lookup_val = ''
|
||||
function! airline#extensions#tagbar#currenttag()
|
||||
if get(w:, 'airline_active', 0)
|
||||
return tagbar#currenttag('%s', '', s:flags)
|
||||
if s:airline_tagbar_last_lookup_time != localtime()
|
||||
let s:airline_tagbar_last_lookup_val = tagbar#currenttag('%s', '', s:flags)
|
||||
let s:airline_tagbar_last_lookup_time = localtime()
|
||||
endif
|
||||
return s:airline_tagbar_last_lookup_val
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
|
|
@ -48,8 +48,10 @@ function! airline#themes#solarized#refresh()
|
|||
let s:NW = [s:base3, s:orange, '']
|
||||
if s:background == 'dark'
|
||||
let s:NM = [s:base1, s:N3[1], '']
|
||||
let s:NMi = [s:base2, s:N3[1], '']
|
||||
else
|
||||
let s:NM = [s:base01, s:N3[1], '']
|
||||
let s:NMi = [s:base02, s:N3[1], '']
|
||||
endif
|
||||
|
||||
" Insert mode
|
||||
|
@ -73,11 +75,12 @@ function! airline#themes#solarized#refresh()
|
|||
let s:RM = s:NM
|
||||
let s:RF = s:NF
|
||||
|
||||
" Inactive
|
||||
" Inactive, according to VertSplit in solarized
|
||||
" (bg dark: base00; bg light: base0)
|
||||
if s:background == 'dark'
|
||||
let s:IA = [s:base00, s:base02, '']
|
||||
let s:IA = [s:base02, s:base00, '']
|
||||
else
|
||||
let s:IA = [s:base1, s:base2, '']
|
||||
let s:IA = [s:base2, s:base0, '']
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
@ -98,7 +101,7 @@ function! airline#themes#solarized#refresh()
|
|||
\ [s:IA[0].g, s:IA[1].g, s:IA[0].t, s:IA[1].t, s:IA[2]],
|
||||
\ [s:IA[0].g, s:IA[1].g, s:IA[0].t, s:IA[1].t, s:IA[2]])
|
||||
let g:airline#themes#solarized#palette.inactive_modified = {
|
||||
\ 'airline_c': [s:NM[0].g, '', s:NM[0].t, '', s:NM[2]]}
|
||||
\ 'airline_c': [s:NMi[0].g, '', s:NMi[0].t, '', s:NMi[2]]}
|
||||
|
||||
let g:airline#themes#solarized#palette.normal = airline#themes#generate_color_map(
|
||||
\ [s:N1[0].g, s:N1[1].g, s:N1[0].t, s:N1[1].t, s:N1[2]],
|
||||
|
|
11
sources_non_forked/vim-bundle-mako/ftplugin/mako.vim
Normal file
11
sources_non_forked/vim-bundle-mako/ftplugin/mako.vim
Normal file
|
@ -0,0 +1,11 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: Mako
|
||||
" Maintainer: Randy Stauner <randy@magnificent-tears.com>
|
||||
" Last Change: 2014-02-07
|
||||
" Version: 0.1
|
||||
|
||||
if exists("b:did_ftplugin") | finish | endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal comments=:##
|
||||
setlocal commentstring=##%s
|
1
sources_non_forked/vim-commentary/.gitignore
vendored
Normal file
1
sources_non_forked/vim-commentary/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/doc/tags
|
62
sources_non_forked/vim-commentary/README.markdown
Normal file
62
sources_non_forked/vim-commentary/README.markdown
Normal file
|
@ -0,0 +1,62 @@
|
|||
commentary.vim
|
||||
==============
|
||||
|
||||
Comment stuff out. Use `gcc` to comment out a line (takes a count),
|
||||
`gc` to comment out the target of a motion (for example, `gcap` to
|
||||
comment out a paragraph), and `gc` in visual mode to comment out the
|
||||
selection. That's it.
|
||||
|
||||
I wrote this because 5 years after Vim added support for mapping an
|
||||
operator, I still couldn't find a commenting plugin that leveraged that
|
||||
feature (I overlooked
|
||||
[tcomment.vim](https://github.com/tomtom/tcomment_vim)). Striving for
|
||||
minimalism, it weighs in at under 100 lines of code.
|
||||
|
||||
Oh, and it uncomments, too. The above maps actually toggle, and `gcu`
|
||||
uncomments a set of adjacent commented lines. Install
|
||||
[repeat.vim](https://github.com/tpope/vim-repeat) to enable
|
||||
repeating `gcu` with `.` (the other maps are repeatable without it).
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
If you don't have a preferred installation method, I recommend
|
||||
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
|
||||
then simply copy and paste:
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone git://github.com/tpope/vim-commentary.git
|
||||
|
||||
Once help tags have been generated, you can view the manual with
|
||||
`:help commentary`.
|
||||
|
||||
FAQ
|
||||
---
|
||||
|
||||
> My favorite file type isn't supported!
|
||||
|
||||
Relax! You just have to adjust `'commentstring'`:
|
||||
|
||||
autocmd FileType apache set commentstring=#\ %s
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
See the contribution guidelines for
|
||||
[pathogen.vim](https://github.com/tpope/vim-pathogen#readme).
|
||||
|
||||
Self-Promotion
|
||||
--------------
|
||||
|
||||
Like commentary.vim? Follow the repository on
|
||||
[GitHub](https://github.com/tpope/vim-commentary) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=3695). And if
|
||||
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
|
||||
[Twitter](http://twitter.com/tpope) and
|
||||
[GitHub](https://github.com/tpope).
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
|
||||
See `:help license`.
|
28
sources_non_forked/vim-commentary/doc/commentary.txt
Normal file
28
sources_non_forked/vim-commentary/doc/commentary.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
*commentary.txt* Comment stuff out
|
||||
|
||||
Author: Tim Pope <http://tpo.pe/>
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
Comment stuff out. Then uncomment it later. Relies on 'commentstring' to be
|
||||
correctly set.
|
||||
|
||||
The gc mappings are preferred, while the \\ mappings are provided for
|
||||
backwards compatibility.
|
||||
|
||||
*gc* *\\*
|
||||
gc{motion} Comment or uncomment lines that {motion} moves over.
|
||||
\\{motion}
|
||||
|
||||
*gcc* *\\\*
|
||||
gcc Comment or uncomment [count] lines.
|
||||
\\\
|
||||
|
||||
*v_gc* *v_\\*
|
||||
{Visual}gc Comment or uncomment the highlighted lines.
|
||||
{Visual}\\
|
||||
|
||||
*gcu* *\\u*
|
||||
gcu Uncomment the current and adjacent commented lines.
|
||||
\\u
|
||||
|
||||
vim:tw=78:et:ft=help:norl:
|
75
sources_non_forked/vim-commentary/plugin/commentary.vim
Normal file
75
sources_non_forked/vim-commentary/plugin/commentary.vim
Normal file
|
@ -0,0 +1,75 @@
|
|||
" commentary.vim - Comment stuff out
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" Version: 1.1
|
||||
" GetLatestVimScripts: 3695 1 :AutoInstall: commentary.vim
|
||||
|
||||
if exists("g:loaded_commentary") || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_commentary = 1
|
||||
|
||||
function! s:go(type,...) abort
|
||||
if a:0
|
||||
let [lnum1, lnum2] = [a:type, a:1]
|
||||
else
|
||||
let [lnum1, lnum2] = [line("'["), line("']")]
|
||||
endif
|
||||
|
||||
let [l, r] = split(substitute(substitute(&commentstring,'\S\zs%s',' %s',''),'%s\ze\S','%s ',''),'%s',1)
|
||||
let uncomment = 2
|
||||
for lnum in range(lnum1,lnum2)
|
||||
let line = matchstr(getline(lnum),'\S.*\s\@<!')
|
||||
if line != '' && (stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
|
||||
let uncomment = 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
for lnum in range(lnum1,lnum2)
|
||||
let line = getline(lnum)
|
||||
if strlen(r) > 2 && l.r !~# '\\'
|
||||
let line = substitute(line,
|
||||
\'\M'.r[0:-2].'\zs\d\*\ze'.r[-1:-1].'\|'.l[0].'\zs\d\*\ze'.l[1:-1],
|
||||
\'\=substitute(submatch(0)+1-uncomment,"^0$\\|^-\\d*$","","")','g')
|
||||
endif
|
||||
if uncomment
|
||||
let line = substitute(line,'\S.*\s\@<!','\=submatch(0)[strlen(l):-strlen(r)-1]','')
|
||||
else
|
||||
let line = substitute(line,'^\%('.matchstr(getline(lnum1),'^\s*').'\|\s*\)\zs.*\S\@<=','\=l.submatch(0).r','')
|
||||
endif
|
||||
call setline(lnum,line)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:undo()
|
||||
let [l, r] = split(substitute(substitute(&commentstring,'\S\zs%s',' %s',''),'%s\ze\S','%s ',''),'%s',1)
|
||||
let lnums = [line('.')+1, line('.')-2]
|
||||
for [index, dir, bound, line] in [[0, -1, 1, ''], [1, 1, line('$'), '']]
|
||||
while lnums[index] != bound && line ==# '' || !(stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
|
||||
let lnums[index] += dir
|
||||
let line = matchstr(getline(lnums[index]+dir),'\S.*\s\@<!')
|
||||
endwhile
|
||||
endfor
|
||||
call s:go(lnums[0], lnums[1])
|
||||
silent! call repeat#set("\<Plug>CommentaryUndo")
|
||||
endfunction
|
||||
|
||||
xnoremap <silent> <Plug>Commentary :<C-U>call <SID>go(line("'<"),line("'>"))<CR>
|
||||
nnoremap <silent> <Plug>Commentary :<C-U>set opfunc=<SID>go<CR>g@
|
||||
nnoremap <silent> <Plug>CommentaryLine :<C-U>set opfunc=<SID>go<Bar>exe 'norm! 'v:count1.'g@_'<CR>
|
||||
nnoremap <silent> <Plug>CommentaryUndo :<C-U>call <SID>undo()<CR>
|
||||
|
||||
if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
|
||||
xmap gc <Plug>Commentary
|
||||
nmap gc <Plug>Commentary
|
||||
nmap gcc <Plug>CommentaryLine
|
||||
nmap gcu <Plug>CommentaryUndo
|
||||
endif
|
||||
|
||||
if maparg('\\','n') ==# '' && maparg('\','n') ==# ''
|
||||
xmap \\ <Plug>Commentary
|
||||
nmap \\ <Plug>Commentary
|
||||
nmap \\\ <Plug>CommentaryLine
|
||||
nmap \\u <Plug>CommentaryUndo
|
||||
endif
|
||||
|
||||
" vim:set et sw=2:
|
|
@ -85,6 +85,9 @@ syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepe
|
|||
syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```.*$" end="^\s*```\ze\s*$" keepend
|
||||
|
||||
syn match markdownFootnote "\[^[^\]]\]\s*$"
|
||||
syn match markdownFootnoteDefinition "^\[^[^\]]\]:"
|
||||
|
||||
if main_syntax ==# 'markdown'
|
||||
for s:type in g:markdown_fenced_languages
|
||||
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
|
||||
|
@ -108,6 +111,9 @@ hi def link markdownListMarker htmlTagName
|
|||
hi def link markdownBlockquote Comment
|
||||
hi def link markdownRule PreProc
|
||||
|
||||
hi def link markdownFootnote Typedef
|
||||
hi def link markdownFootnoteDefinition Typedef
|
||||
|
||||
hi def link markdownLinkText htmlLink
|
||||
hi def link markdownIdDeclaration Typedef
|
||||
hi def link markdownId Type
|
||||
|
|
53
sources_non_forked/vim-repeat/README.markdown
Normal file
53
sources_non_forked/vim-repeat/README.markdown
Normal file
|
@ -0,0 +1,53 @@
|
|||
repeat.vim
|
||||
==========
|
||||
|
||||
If you've ever tried using the `.` command after a plugin map, you were
|
||||
likely disappointed to discover it only repeated the last native command
|
||||
inside that map, rather than the map as a whole. That disappointment
|
||||
ends today. Repeat.vim remaps `.` in a way that plugins can tap into
|
||||
it.
|
||||
|
||||
The following plugins support repeat.vim:
|
||||
|
||||
* [surround.vim](https://github.com/tpope/vim-surround)
|
||||
* [speeddating.vim](https://github.com/tpope/vim-speeddating)
|
||||
* [abolish.vim](https://github.com/tpope/vim-abolish)
|
||||
* [unimpaired.vim](https://github.com/tpope/vim-unimpaired)
|
||||
* [commentary.vim](https://github.com/tpope/vim-commentary)
|
||||
|
||||
Adding support to a plugin is generally as simple as the following
|
||||
command at the end of your map functions.
|
||||
|
||||
silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
If you don't have a preferred installation method, I recommend
|
||||
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
|
||||
then simply copy and paste:
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone git://github.com/tpope/vim-repeat.git
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
See the contribution guidelines for
|
||||
[pathogen.vim](https://github.com/tpope/vim-pathogen#readme).
|
||||
|
||||
Self-Promotion
|
||||
--------------
|
||||
|
||||
Like repeat.vim? Follow the repository on
|
||||
[GitHub](https://github.com/tpope/vim-repeat) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=2136). And if
|
||||
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
|
||||
[Twitter](http://twitter.com/tpope) and
|
||||
[GitHub](https://github.com/tpope).
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
|
||||
See `:help license`.
|
119
sources_non_forked/vim-repeat/autoload/repeat.vim
Normal file
119
sources_non_forked/vim-repeat/autoload/repeat.vim
Normal file
|
@ -0,0 +1,119 @@
|
|||
" repeat.vim - Let the repeat command repeat plugin maps
|
||||
" Maintainer: Tim Pope
|
||||
" Version: 1.1
|
||||
" GetLatestVimScripts: 2136 1 :AutoInstall: repeat.vim
|
||||
|
||||
" Installation:
|
||||
" Place in either ~/.vim/plugin/repeat.vim (to load at start up) or
|
||||
" ~/.vim/autoload/repeat.vim (to load automatically as needed).
|
||||
"
|
||||
" License:
|
||||
" Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
|
||||
" See :help license
|
||||
"
|
||||
" Developers:
|
||||
" Basic usage is as follows:
|
||||
"
|
||||
" silent! call repeat#set("\<Plug>MappingToRepeatCommand",3)
|
||||
"
|
||||
" The first argument is the mapping that will be invoked when the |.| key is
|
||||
" pressed. Typically, it will be the same as the mapping the user invoked.
|
||||
" This sequence will be stuffed into the input queue literally. Thus you must
|
||||
" encode special keys by prefixing them with a backslash inside double quotes.
|
||||
"
|
||||
" The second argument is the default count. This is the number that will be
|
||||
" prefixed to the mapping if no explicit numeric argument was given. The
|
||||
" value of the v:count variable is usually correct and it will be used if the
|
||||
" second parameter is omitted. If your mapping doesn't accept a numeric
|
||||
" argument and you never want to receive one, pass a value of -1.
|
||||
"
|
||||
" Make sure to call the repeat#set function _after_ making changes to the
|
||||
" file.
|
||||
"
|
||||
" For mappings that use a register and want the same register used on
|
||||
" repetition, use:
|
||||
"
|
||||
" silent! call repeat#setreg("\<Plug>MappingToRepeatCommand", v:register)
|
||||
"
|
||||
" This function can (and probably needs to be) called before making changes to
|
||||
" the file (as those typically clear v:register). Therefore, the call sequence
|
||||
" in your mapping will look like this:
|
||||
"
|
||||
" nnoremap <silent> <Plug>MyMap
|
||||
" \ :<C-U>execute 'silent! call repeat#setreg("\<lt>Plug>MyMap", v:register)'<Bar>
|
||||
" \ call <SID>MyFunction(v:register, ...)<Bar>
|
||||
" \ silent! call repeat#set("\<lt>Plug>MyMap")<CR>
|
||||
|
||||
if exists("g:loaded_repeat") || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_repeat = 1
|
||||
|
||||
let g:repeat_tick = -1
|
||||
let g:repeat_reg = ['', '']
|
||||
|
||||
" Special function to avoid spurious repeats in a related, naturally repeating
|
||||
" mapping when your repeatable mapping doesn't increase b:changedtick.
|
||||
function! repeat#invalidate()
|
||||
let g:repeat_tick = -1
|
||||
endfunction
|
||||
|
||||
function! repeat#set(sequence,...)
|
||||
let g:repeat_sequence = a:sequence
|
||||
let g:repeat_count = a:0 ? a:1 : v:count
|
||||
let g:repeat_tick = b:changedtick
|
||||
augroup repeat_custom_motion
|
||||
autocmd!
|
||||
autocmd CursorMoved <buffer> let g:repeat_tick = b:changedtick | autocmd! repeat_custom_motion
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! repeat#setreg(sequence,register)
|
||||
let g:repeat_reg = [a:sequence, a:register]
|
||||
endfunction
|
||||
|
||||
function! repeat#run(count)
|
||||
if g:repeat_tick == b:changedtick
|
||||
let r = ''
|
||||
if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1])
|
||||
if g:repeat_reg[1] ==# '='
|
||||
" This causes a re-evaluation of the expression on repeat, which
|
||||
" is what we want.
|
||||
let r = '"=' . getreg('=', 1) . "\<CR>"
|
||||
else
|
||||
let r = '"' . g:repeat_reg[1]
|
||||
endif
|
||||
endif
|
||||
|
||||
let c = g:repeat_count
|
||||
let s = g:repeat_sequence
|
||||
let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : ''))
|
||||
call feedkeys(r . cnt, 'n')
|
||||
call feedkeys(s)
|
||||
else
|
||||
call feedkeys((a:count ? a:count : '') . '.', 'n')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! repeat#wrap(command,count)
|
||||
let preserve = (g:repeat_tick == b:changedtick)
|
||||
exe 'norm! '.(a:count ? a:count : '').a:command . (&foldopen =~# 'undo' ? 'zv' : '')
|
||||
if preserve
|
||||
let g:repeat_tick = b:changedtick
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <silent> . :<C-U>call repeat#run(v:count)<CR>
|
||||
nnoremap <silent> u :<C-U>call repeat#wrap('u',v:count)<CR>
|
||||
if maparg('U','n') ==# ''
|
||||
nnoremap <silent> U :<C-U>call repeat#wrap('U',v:count)<CR>
|
||||
endif
|
||||
nnoremap <silent> <C-R> :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
|
||||
|
||||
augroup repeatPlugin
|
||||
autocmd!
|
||||
autocmd BufLeave,BufWritePre,BufReadPre * let g:repeat_tick = (g:repeat_tick == b:changedtick || g:repeat_tick == 0) ? 0 : -1
|
||||
autocmd BufEnter,BufWritePost * if g:repeat_tick == 0|let g:repeat_tick = b:changedtick|endif
|
||||
augroup END
|
||||
|
||||
" vim:set ft=vim et sw=4 sts=4:
|
|
@ -48,8 +48,11 @@ looking at the [vim-snippets][vim-snippets] repository.
|
|||
|
||||
### Master ###
|
||||
|
||||
* Implement simple caching
|
||||
* Remove expansion guards
|
||||
* Fix bug with mirrors in the first column
|
||||
* Fix bug with tabs in indents ([#143][143])
|
||||
* Fix bug with mirrors in placeholders
|
||||
|
||||
### 0.87 - 2014-01-04 ###
|
||||
|
||||
|
|
|
@ -13,13 +13,6 @@ endtry
|
|||
" match $ which doesn't follow a \
|
||||
let s:d = '\%([\\]\@<!\$\)'
|
||||
|
||||
|
||||
" disable write cache in files
|
||||
" some people get errors about writing the cache files. Probably there is no
|
||||
" pay off having slow disks anyway. So disabling the cache by default
|
||||
let s:c.cache_parsed_snippets_on_disk = get(s:c, 'cache_parsed_snippets_on_disk', 0)
|
||||
let s:c.read_snippets_cached = get(s:c, 'read_snippets_cached', {'func' : function('snipMate#ReadSnippetsFile'), 'version': 3, 'use_file_cache': s:c.cache_parsed_snippets_on_disk})
|
||||
|
||||
" if filetype is objc, cpp, cs or cu also append snippets from scope 'c'
|
||||
" you can add multiple by separating scopes by ',', see s:AddScopeAliases
|
||||
let s:c.scope_aliases = get(s:c, 'scope_aliases', {})
|
||||
|
@ -47,6 +40,7 @@ fun! Filename(...)
|
|||
endf
|
||||
|
||||
let s:state_proto = {}
|
||||
let s:cache = {}
|
||||
|
||||
fun! s:state_proto.remove()
|
||||
unlet! b:snip_state
|
||||
|
@ -91,7 +85,7 @@ fun! snipMate#expandSnip(snip, col)
|
|||
|
||||
if b:snip_state.stop_count
|
||||
aug snipmate_changes
|
||||
au CursorMovedI,InsertEnter <buffer> call b:snip_state.update_changes()
|
||||
au CursorMoved,CursorMovedI <buffer> call b:snip_state.update_changes()
|
||||
aug END
|
||||
call b:snip_state.set_stop(0)
|
||||
|
||||
|
@ -263,7 +257,7 @@ function! s:state_proto.jump_stop(backwards)
|
|||
|
||||
if self.stop_no == self.stop_count
|
||||
call self.remove()
|
||||
return -1
|
||||
return ''
|
||||
endif
|
||||
|
||||
call self.set_stop(self.stop_no)
|
||||
|
@ -303,6 +297,10 @@ function! s:state_proto.update_stops()
|
|||
if exists('pos[3]')
|
||||
for nPos in pos[3]
|
||||
let changed = nPos[0] == curLine && nPos[1] > self.start_col
|
||||
if changed && nPos[1] < self.start_col + self.cur_stop[2]
|
||||
call remove(pos, index(pos, nPos))
|
||||
continue
|
||||
endif
|
||||
for [lnum, col] in self.old_vars
|
||||
if lnum > nPos[0] | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
|
@ -387,21 +385,11 @@ function! s:state_proto.update_vars(change)
|
|||
|
||||
" Reposition the cursor in case a var updates on the same line but before
|
||||
" the current tabstop
|
||||
if oldStartSnip != self.start_col
|
||||
if oldStartSnip != self.start_col || mode() == 'i'
|
||||
call cursor(0, col('.') + self.start_col - oldStartSnip)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" should be moved to utils or such?
|
||||
fun! snipMate#SetByPath(dict, path, value)
|
||||
let d = a:dict
|
||||
for p in a:path[:-2]
|
||||
if !has_key(d,p) | let d[p] = {} | endif
|
||||
let d = d[p]
|
||||
endfor
|
||||
let d[a:path[-1]] = a:value
|
||||
endf
|
||||
|
||||
" reads a .snippets file
|
||||
" returns list of
|
||||
" ['triggername', 'name', 'contents']
|
||||
|
@ -410,27 +398,18 @@ fun! snipMate#ReadSnippetsFile(file)
|
|||
let result = []
|
||||
let new_scopes = []
|
||||
if !filereadable(a:file) | return [result, new_scopes] | endif
|
||||
let r_guard = '^guard\s\+\zs.*'
|
||||
let inSnip = 0
|
||||
let guard = 1
|
||||
for line in readfile(a:file) + ["\n"]
|
||||
if inSnip == 2 && line =~ r_guard
|
||||
let guard = matchstr(line, r_guard)
|
||||
elseif inSnip && (line[0] == "\t" || line == '')
|
||||
if inSnip && (line[0] == "\t" || line == '')
|
||||
let content .= strpart(line, 1)."\n"
|
||||
continue
|
||||
elseif inSnip
|
||||
call add(result, [trigger, name == '' ? 'default' : name, content[:-2], guard])
|
||||
call add(result, [trigger, name == '' ? 'default' : name, content[:-2]])
|
||||
let inSnip = 0
|
||||
let guard = "1"
|
||||
endif
|
||||
|
||||
if inSnip == 2
|
||||
let inSnip = 1
|
||||
endif
|
||||
if line[:6] == 'snippet'
|
||||
" 2 signals first line
|
||||
let inSnip = 2
|
||||
let inSnip = 1
|
||||
let trigger = strpart(line, 8)
|
||||
let name = ''
|
||||
let space = stridx(trigger, ' ') + 1
|
||||
|
@ -527,43 +506,61 @@ function! snipMate#GetSnippetFiles(mustExist, scopes, trigger)
|
|||
return result
|
||||
endfunction
|
||||
|
||||
fun! snipMate#EvalGuard(guard)
|
||||
" left: everything left of expansion
|
||||
" word: the expanded word
|
||||
" are guaranteed to be in scpe
|
||||
" should be moved to utils or such?
|
||||
function! snipMate#SetByPath(dict, path, value)
|
||||
let d = a:dict
|
||||
for p in a:path[:-2]
|
||||
if !has_key(d,p) | let d[p] = {} | endif
|
||||
let d = d[p]
|
||||
endfor
|
||||
let d[a:path[-1]] = a:value
|
||||
endfunction
|
||||
|
||||
if a:guard == '1' | return 1 | endif
|
||||
let word = s:c.word
|
||||
" eval is evil, but backticks are allowed anyway.
|
||||
let left = getline('.')[:col('.')-3 - len(word)]
|
||||
exec 'return '.a:guard
|
||||
endf
|
||||
function! s:ReadFile(file)
|
||||
if a:file =~ '\.snippet$'
|
||||
return [['', '', readfile(a:file), '1']]
|
||||
else
|
||||
return snipMate#ReadSnippetsFile(a:file)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:CachedSnips(file)
|
||||
let mtime = getftime(a:file)
|
||||
if has_key(s:cache, a:file) && s:cache[a:file].mtime >= mtime
|
||||
return s:cache[a:file].contents
|
||||
endif
|
||||
let s:cache[a:file] = {}
|
||||
let s:cache[a:file].mtime = mtime
|
||||
let s:cache[a:file].contents = snipMate#ReadSnippetsFile(a:file)
|
||||
return s:cache[a:file].contents
|
||||
endfunction
|
||||
|
||||
" default triggers based on paths
|
||||
fun! snipMate#DefaultPool(scopes, trigger, result)
|
||||
let triggerR = substitute(a:trigger,'*','.*','g')
|
||||
function! snipMate#DefaultPool(scopes, trigger, result)
|
||||
let extra_scopes = []
|
||||
for [f,opts] in items(snipMate#GetSnippetFiles(1, a:scopes, a:trigger))
|
||||
let opts.name_prefix = matchstr(f, '\v[^/]+\ze/snippets') . ' ' . opts.name_prefix
|
||||
let opts.name_prefix = matchstr(f, '\v/\zs.{-}\ze/snippets') . ' ' . opts.name_prefix
|
||||
if opts.type == 'snippets'
|
||||
let [snippets, extension] = cached_file_contents#CachedFileContents(f, s:c.read_snippets_cached, 0)
|
||||
for [trigger, name, contents, guard] in snippets
|
||||
if trigger !~ escape(triggerR,'~') | continue | endif
|
||||
if snipMate#EvalGuard(guard)
|
||||
call snipMate#SetByPath(a:result, [trigger, opts.name_prefix.' '.name], contents)
|
||||
let [snippets, new_scopes] = s:CachedSnips(f)
|
||||
call extend(extra_scopes, new_scopes)
|
||||
for [trigger, name, contents] in snippets
|
||||
if trigger =~ '\V\^' . escape(a:trigger, '\')
|
||||
call snipMate#SetByPath(a:result,
|
||||
\ [trigger, opts.name_prefix . ' ' . name],
|
||||
\ contents)
|
||||
endif
|
||||
endfor
|
||||
call extend(extra_scopes, extension)
|
||||
elseif opts.type == 'snippet'
|
||||
call snipMate#SetByPath(a:result, [opts.trigger, opts.name_prefix.' '.opts.name], funcref#Function('return readfile('.string(f).')'))
|
||||
call snipMate#SetByPath(a:result, [opts.trigger, opts.name_prefix.' '.opts.name], readfile(f))
|
||||
else
|
||||
throw "unexpected"
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !empty(extra_scopes)
|
||||
call snipMate#DefaultPool(extra_scopes, a:trigger, a:result)
|
||||
endif
|
||||
endf
|
||||
endfunction
|
||||
|
||||
" return a dict of snippets found in runtimepath matching trigger
|
||||
" scopes: list of scopes. usually this is the filetype. eg ['c','cpp']
|
||||
|
@ -571,8 +568,6 @@ endf
|
|||
"
|
||||
fun! snipMate#GetSnippets(scopes, trigger)
|
||||
let result = {}
|
||||
let triggerR = escape(substitute(a:trigger,'*','.*','g'), '~') " escape '~' for use as regexp
|
||||
" let scopes = s:AddScopeAliases(a:scopes)
|
||||
|
||||
for F in values(g:snipMateSources)
|
||||
call funcref#Call(F, [a:scopes, a:trigger, result])
|
||||
|
@ -666,14 +661,12 @@ fun! snipMate#GetSnippetsForWordBelowCursor(word, suffix, break_on_first_match)
|
|||
endif
|
||||
|
||||
call filter(lookups, 'v:val != ""')
|
||||
" echo lookups
|
||||
|
||||
let matching_snippets = []
|
||||
let snippet = ''
|
||||
" prefer longest word
|
||||
for word in lookups
|
||||
let s:c.word = word
|
||||
" echomsg string(lookups).' current: '.word
|
||||
for [k,snippetD] in items(funcref#Call(s:c['get_snippets'], [snipMate#ScopesByFile(), word]))
|
||||
if a:suffix == ''
|
||||
" hack: require exact match
|
||||
|
@ -716,7 +709,7 @@ endf
|
|||
|
||||
fun! snipMate#GetSnippetsForWordBelowCursorForComplete(word)
|
||||
let snippets = map(snipMate#GetSnippetsForWordBelowCursor(a:word, '*', 0), 'v:val[0]')
|
||||
return filter(snippets, "v:val =~# '\\V\\^" . escape(a:word, '\') . "'")
|
||||
return filter(snippets, 'v:val =~# "\\V\\^' . escape(a:word, '"\') . '"')
|
||||
endf
|
||||
|
||||
fun! snipMate#CanBeTriggered()
|
||||
|
|
|
@ -194,7 +194,6 @@ Multiple snippets can be defined in *.snippets files. Each snippet definition
|
|||
looks something like: >
|
||||
|
||||
snippet trigger optional description
|
||||
guard left_from_cursor='^\s*'
|
||||
expanded text
|
||||
more expanded text
|
||||
|
||||
|
@ -203,9 +202,6 @@ The description is optional. If it is left out and a second snippet inside the
|
|||
same .snippets file uses the same trigger, the second one will overwrite the
|
||||
first. Otherwise multisnip is used.
|
||||
|
||||
The guard condition line is also optional. It can be used to make a snippet
|
||||
available only in some cases. The value should be a VimL expression.
|
||||
|
||||
Note: Hard tabs in the expansion text are required. When the snippet is
|
||||
expanded in the text and 'expandtab' is set, each tab will be replaced with
|
||||
spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise.
|
||||
|
@ -254,7 +250,7 @@ the tab stop. This text then can be copied throughout the snippet using "$#",
|
|||
given # is the same number as used before. So, to make a C for loop: >
|
||||
|
||||
snippet for
|
||||
for (${2:i}; $2 < ${1:count}; $1++) {
|
||||
for (${2:i}=0; $2 < ${1:count}; $2++) {
|
||||
${4}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ ${0}
|
|||
endsnippet
|
||||
|
||||
snippet sec "Section" b
|
||||
\section{${1:section name}}
|
||||
\section{${1:section name}}
|
||||
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
|
||||
|
||||
${0}
|
||||
|
|
|
@ -50,6 +50,9 @@ snippet case
|
|||
${0}
|
||||
end
|
||||
|
||||
snippet df
|
||||
def ${1:name}, do: ${2}
|
||||
|
||||
snippet def
|
||||
def ${1:name} do
|
||||
${0}
|
||||
|
|
|
@ -749,15 +749,15 @@ snippet summary
|
|||
snippet sup
|
||||
<sup>${0}</sup>
|
||||
snippet table
|
||||
<table border="${1:0}">
|
||||
<table>
|
||||
${0}
|
||||
</table>
|
||||
snippet table.
|
||||
<table class="${1}" border="${2:0}">
|
||||
<table class="${1}">
|
||||
${0}
|
||||
</table>
|
||||
snippet table#
|
||||
<table id="${1}" border="${2:0}">
|
||||
<table id="${1}">
|
||||
${0}
|
||||
</table>
|
||||
snippet tbody
|
||||
|
|
|
@ -620,6 +620,8 @@ snippet asrj
|
|||
assert_rjs :${1:replace}, "${0:dom id}"
|
||||
snippet ass assert_select(..)
|
||||
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
|
||||
snippet ba
|
||||
before_action :${0:method}
|
||||
snippet bf
|
||||
before_filter :${0:method}
|
||||
snippet bt
|
||||
|
|
|
@ -36,6 +36,8 @@ vim-airline https://github.com/bling/vim-airline
|
|||
goyo.vim https://github.com/junegunn/goyo.vim
|
||||
vim-zenroom2 https://github.com/amix/vim-zenroom2
|
||||
syntastic https://github.com/scrooloose/syntastic
|
||||
vim-repeat https://github.com/tpope/vim-repeat
|
||||
vim-commentary https://github.com/tpope/vim-commentary
|
||||
""".strip()
|
||||
|
||||
GITHUB_ZIP = '%s/archive/master.zip'
|
||||
|
|
Loading…
Reference in a new issue