Skip to content

Commit

Permalink
Braid: Update mirror 'bundle/syntastic' to '17183c6'
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly committed Jul 11, 2011
1 parent 6f08470 commit 78c2f1d
Show file tree
Hide file tree
Showing 27 changed files with 559 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .braids
Expand Up @@ -121,7 +121,7 @@ bundle/surround:
bundle/syntastic:
branch: master
remote: braid/bundles/syntastic
revision: b8fbc338ce979aec7fbad3acb4cf02da95ec2d00
revision: 17183c6d19b7d1ced18e18187eeb2fa148f1a29e
squashed: true
type: git
url: git://github.com/scrooloose/syntastic.git
Expand Down
23 changes: 23 additions & 0 deletions bundle/syntastic/autoload/syntastic.vim
@@ -0,0 +1,23 @@

function! syntastic#ErrorBalloonExpr()
if !exists('b:syntastic_balloons') | return '' | endif
return get(b:syntastic_balloons, v:beval_lnum, '')
endfunction

function! syntastic#HighlightErrors(errors, termfunc)
call clearmatches()
for item in a:errors
if item['col']
let lastcol = col([item['lnum'], '$'])
let lcol = min([lastcol, item['col']])
call matchadd('SpellBad', '\%'.item['lnum'].'l\%'.lcol.'c')
else
let group = item['type'] == 'E' ? 'SpellBad' : 'SpellCap'
let term = a:termfunc(item)
if len(term) > 0
call matchadd(group, '\%' . item['lnum'] . 'l' . term)
endif
endif
endfor
endfunction

66 changes: 54 additions & 12 deletions bundle/syntastic/doc/syntastic.txt
Expand Up @@ -45,8 +45,12 @@ Syntastic comes in two parts: the syntax checker plugins, and the core script
(i.e. syntastic.vim). The syntax checker plugins are defined on a per-filetype
basis where each one wraps up an external syntax checking program. The core
script delegates off to these plugins and uses their output to provide the
syntastic functionality. Currently, syntax checking plugins exist for eruby,
haml, html, javascript, php, python, ruby and sass.
syntastic functionality. Currently, syntax checking plugins exist for c,
coffee, cpp, cucumber, eruby, haml, haskell, html, javascript, lua, perl, php,
python, ruby, sass, sh, tex and xhtml.

NOTE: This list is subject to change without notice. Please check the
syntax_checkers directory for a reliable list of syntax checkers.

If your language is not supported then see |syntastic-syntax-checkers| for
details on how to implement a syntax checking plugin, and be sure to send me a
Expand Down Expand Up @@ -84,13 +88,8 @@ Something like this could be more useful: >
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
<
When syntax errors are detected, the following will be displayed on your
statusline: >
[syntax:X(Y)]
<
Where X is the line number of the first error and Y is the total number of
errors. Note that "(Y)" only appears if there is more than one error.

When syntax errors are detected a flag will be shown. The content of the flag
is derived from the |syntastic_stl_format| option
------------------------------------------------------------------------------
2.2. Error signs *syntastic-error-signs*

Expand Down Expand Up @@ -129,12 +128,24 @@ errors: >
let g:syntastic_enable_signs=1
<

*'syntastic_auto_jump'*
Enable this option if you want the cursor to jump to the first detected error
when saving or opening a file: >
let g:syntastic_auto_jump=1
<

*'syntastic_auto_loc_list'*
Use this option to tell syntastic to automatically open the |location-list|
(see |syntastic-error-window|) when a buffer has errors: >
Use this option to tell syntastic to automatically open and/or close the
|location-list| (see |syntastic-error-window|).

When set to 1 the error window will be automatically opened when errors are
detected, and closed when none are detected. >
let g:syntastic_auto_loc_list=1
<
The location list is also closed again when there are no errors.
When set to 2 the error window will be automatically closed when no errors are
detected, but not opened automatically. >
let g:syntastic_auto_loc_list=2
<

*'syntastic_quiet_warnings'*

Expand All @@ -150,6 +161,37 @@ this option has the following effects:
let g:syntastic_quiet_warnings=1
<

*'syntastic_stl_format'*

Default: [Syntax: line:%F (%t)]
Use this option to control what the syntastic statusline text contains. Several
magic flags are availble to insert information:
%e - number of errors
%w - number of warnings
%t - total number of warnings and errors
%fe - line number of first error
%fw - line number of first warning
%F - line number of first warning or error

Several additional flags are available to hide text under certain conditions:
%E{...} - hide the text in the brackets unless there are errors
%W{...} - hide the text in the brackets unless there are warnings
%B{...} - hide the text in the brackets unless there are both warnings AND
errors
These flags cant be nested.

Example: >
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
<
If this format is used and the current buffer has 5 errors and 1 warning
starting on lines 20 and 10 respectively then this would appear on the
statusline: >
[Err: 20 #5, Warn: 10 #1]
<
If the buffer had 2 warnings, starting on line 5 then this would appear: >
[Warn: 5 #2]
<

*'syntastic_disabled_filetypes'*
Use this option to disable syntax checking on selected filetypes by default.
Should be set to a list of filetypes, e.g. >
Expand Down
95 changes: 73 additions & 22 deletions bundle/syntastic/plugin/syntastic.vim
Expand Up @@ -23,10 +23,18 @@ if !exists("g:syntastic_enable_signs") || !has('signs')
let g:syntastic_enable_signs = 0
endif

if !exists("g:syntastic_enable_balloons") || !has('balloon_eval')
let g:syntastic_enable_balloons = 0
endif

if !exists("g:syntastic_auto_loc_list")
let g:syntastic_auto_loc_list = 0
endif

if !exists("g:syntastic_auto_jump")
let syntastic_auto_jump=0
endif

if !exists("g:syntastic_quiet_warnings")
let g:syntastic_quiet_warnings = 0
endif
Expand All @@ -35,19 +43,40 @@ if !exists("g:syntastic_disabled_filetypes")
let g:syntastic_disabled_filetypes = []
endif

"load all the syntax checkers
runtime! syntax_checkers/*.vim
if !exists("g:syntastic_stl_format")
let g:syntastic_stl_format = '[Syntax: line:%F (%t)]'
endif

"refresh and redraw all the error info for this buf when saving or reading
autocmd bufreadpost,bufwritepost * call s:UpdateErrors()
function! s:UpdateErrors()
if &buftype == 'quickfix'
return
endif
call s:CacheErrors()

if g:syntastic_enable_balloons && has('balloon_eval')
let b:syntastic_balloons = {}
for i in b:syntastic_loclist
let b:syntastic_balloons[i['lnum']] = i['text']
endfor
set beval bexpr=syntastic#ErrorBalloonExpr()
endif

if g:syntastic_enable_signs
call s:RefreshSigns()
endif

if g:syntastic_auto_loc_list
if s:BufHasErrorsOrWarningsToDisplay()
call setloclist(0, b:syntastic_loclist)
if g:syntastic_auto_jump
silent!ll
endif
elseif g:syntastic_auto_loc_list == 2
lclose
endif

if g:syntastic_auto_loc_list == 1
if s:BufHasErrorsOrWarningsToDisplay()
call s:ShowLocList()
else
Expand Down Expand Up @@ -92,7 +121,15 @@ function! s:ErrorsForType(type)
if !exists("b:syntastic_loclist")
return []
endif
return filter(copy(b:syntastic_loclist), 'v:val["type"] ==# "' . a:type . '"')
return filter(copy(b:syntastic_loclist), 'v:val["type"] ==? "' . a:type . '"')
endfunction

function s:Errors()
return extend(s:ErrorsForType("E"), s:ErrorsForType(''))
endfunction

function s:Warnings()
return s:ErrorsForType("W")
endfunction

if g:syntastic_enable_signs
Expand Down Expand Up @@ -154,7 +191,6 @@ endfunction
"display the cached errors for this buf in the location list
function! s:ShowLocList()
if exists("b:syntastic_loclist")
call setloclist(0, b:syntastic_loclist)
let num = winnr()
lopen
if num != winnr()
Expand All @@ -165,33 +201,41 @@ endfunction

command Errors call s:ShowLocList()

"return [syntax:X(Y)] if syntax errors are detected in the buffer, where X is the
"line number of the first error and Y is the number of errors detected. (Y) is
"only displayed if > 1 errors are detected
"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()
if s:BufHasErrorsOrWarningsToDisplay()
let errors = s:Errors()
let warnings = s:Warnings()

let first_err_line = b:syntastic_loclist[0]['lnum']
if g:syntastic_quiet_warnings
let first_err_line = s:ErrorsForType('E')[0]['lnum']
endif
let output = g:syntastic_stl_format

let err_count = len(b:syntastic_loclist)
if g:syntastic_quiet_warnings
let err_count = len(s:ErrorsForType('E'))
endif
"hide stuff wrapped in %E(...) unless there are errors
let output = substitute(output, '\C%E{\([^}]*\)}', len(errors) ? '\1' : '' , 'g')

let toReturn = '[syntax:' . first_err_line
"hide stuff wrapped in %W(...) unless there are warnings
let output = substitute(output, '\C%W{\([^}]*\)}', len(warnings) ? '\1' : '' , 'g')

if err_count > 1
let toReturn .= '(' . err_count . ')'
endif
"hide stuff wrapped in %B(...) unless there are both errors and warnings
let output = substitute(output, '\C%B{\([^}]*\)}', (len(warnings) && len(errors)) ? '\1' : '' , 'g')

"sub in the total errors/warnings/both
let output = substitute(output, '\C%w', len(warnings), 'g')
let output = substitute(output, '\C%e', len(errors), 'g')
let output = substitute(output, '\C%t', len(b:syntastic_loclist), 'g')

"first error/warning line num
let output = substitute(output, '\C%F', b:syntastic_loclist[0]['lnum'], 'g')

let toReturn .= ']'
"first error line num
let output = substitute(output, '\C%fe', len(errors) ? errors[0]['lnum'] : '', 'g')

return toReturn
"first warning line num
let output = substitute(output, '\C%fw', len(warnings) ? warnings[0]['lnum'] : '', 'g')

return output
else
return ''
endif
Expand All @@ -211,12 +255,14 @@ function! SyntasticMake(options)
let old_loclist = getloclist(0)
let old_makeprg = &makeprg
let old_shellpipe = &shellpipe
let old_shell = &shell
let old_errorformat = &errorformat

if !s:running_windows
"this is a hack to stop the screen needing to be ':redraw'n when
"when :lmake is run. Otherwise the screen flickers annoyingly
let &shellpipe='&>'
let &shell = '/bin/bash'
endif

if has_key(a:options, 'makeprg')
Expand All @@ -234,11 +280,16 @@ function! SyntasticMake(options)
let &makeprg = old_makeprg
let &errorformat = old_errorformat
let &shellpipe=old_shellpipe
let &shell=old_shell

return errors
endfunction

function! s:Checkable(ft)
if !exists("g:loaded_" . a:ft . "_syntax_checker")
exec "runtime syntax_checkers/" . a:ft . ".vim"
endif

return exists("*SyntaxCheckers_". a:ft ."_GetLocList") &&
\ index(g:syntastic_disabled_filetypes, a:ft) == -1
endfunction
Expand Down
13 changes: 9 additions & 4 deletions bundle/syntastic/syntax_checkers/c.vim
Expand Up @@ -52,8 +52,10 @@ function! s:Init()
let s:handlers = []
let s:cflags = {}

call s:RegHandler('\%(gtk\|glib\)', 's:CheckPKG',
call s:RegHandler('gtk', 's:CheckPKG',
\ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
call s:RegHandler('glib', 's:CheckPKG',
\ ['glib', 'glib-2.0', 'glib'])
call s:RegHandler('glade', 's:CheckPKG',
\ ['glade', 'libglade-2.0', 'libglade'])
call s:RegHandler('libsoup', 's:CheckPKG',
Expand Down Expand Up @@ -82,8 +84,9 @@ endfunction
function! SyntaxCheckers_c_GetLocList()
let makeprg = 'gcc -fsyntax-only '.shellescape(expand('%')).' -I. -I..'
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
\ 'each function it appears%.%#,%f:%l: %trror: %m,%f:%l: %m'
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
\ '%-G %#from %f:%l\,,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %m'

if expand('%') =~? '.h$'
if exists('g:syntastic_c_check_header')
Expand Down Expand Up @@ -174,7 +177,9 @@ function! s:CheckPKG(name, ...)
if !has_key(s:cflags, a:name)
for i in range(a:0)
let l:cflags = system('pkg-config --cflags '.a:000[i])
if v:shell_error == 0
" since we cannot necessarily trust the pkg-config exit code
" we have to check for an error output as well
if v:shell_error == 0 && l:cflags !~? 'not found'
let l:cflags = ' '.substitute(l:cflags, "\n", '', '')
let s:cflags[a:name] = l:cflags
return l:cflags
Expand Down
4 changes: 2 additions & 2 deletions bundle/syntastic/syntax_checkers/coffee.vim
Expand Up @@ -14,13 +14,13 @@ if exists("loaded_coffee_syntax_checker")
endif
let loaded_coffee_syntax_checker = 1

"bail if the user doesnt have ruby installed
"bail if the user doesnt have coffee installed
if !executable("coffee")
finish
endif

function! SyntaxCheckers_coffee_GetLocList()
let makeprg = 'coffee -c -l -o /dev/null %'
let makeprg = 'coffee -c -l -o /tmp %'
let errorformat = '%EError: In %f\, Parse error on line %l: %m,%EError: In %f\, %m on line %l,%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G'

return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
Expand Down
34 changes: 34 additions & 0 deletions bundle/syntastic/syntax_checkers/css.vim
@@ -0,0 +1,34 @@
"============================================================================
"File: css.vim
"Description: Syntax checking plugin for syntastic.vim using `csslint` CLI tool (http://csslint.net).
"Maintainer: Ory Band <oryband at gmail dot 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("loaded_css_syntax_checker")
finish
endif
let loaded_css_syntax_checker = 1

" Bail if the user doesn't have `csslint` installed.
if !executable("csslint")
finish
endif

function! SyntaxCheckers_css_GetLocList()
let makeprg = 'csslint '.shellescape(expand('%'))

" Print CSS Lint's 'Welcome' and error/warning messages. Ignores the code line.
let errorformat = '%+Gcsslint:\ There%.%#,%A%f:,%C%n:\ %t%\\w%\\+\ at\ line\ %l\,\ col\ %c,%Z%m\ at\ line%.%#,%A%>%f:,%C%n:\ %t%\\w%\\+\ at\ line\ %l\,\ col\ %c,%Z%m,%-G%.%#'

let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })

for i in loclist
let i['bufnr'] = bufnr("")
endfor

return loclist
endfunction

0 comments on commit 78c2f1d

Please sign in to comment.