Permalink
Browse files

Braid: Update mirror 'bundle/syntastic' to 'e961f17'

  • Loading branch information...
baphled committed Apr 1, 2012
1 parent 269a1ba commit 96636a5821397cfbacc56ed5c550880089454954
View
@@ -107,7 +107,7 @@ bundle/surround:
bundle/syntastic:
branch: master
remote: master/braid/bundles/syntastic
- revision: b4a7d4729447f1c912eca390f3e4c9d9d98e62ef
+ revision: e961f17c7c19c9888e16f714b37085e0cb833111
squashed: true
type: git
url: git://github.com/scrooloose/syntastic.git
@@ -55,7 +55,7 @@ Installation
cd ~/.vim/bundle
git clone https://github.com/scrooloose/syntastic.git
-Then reload vim, run `:helptags`, and check out `:help syntastic.txt`.
+Then reload vim, run `:Helptags`, and check out `:help syntastic.txt`.
Google group
@@ -64,6 +64,16 @@ Google group
To get information or make suggestions check out the [google group](https://groups.google.com/group/vim-syntastic).
+FAQ
+---
+
+__Q. I installed syntastic but it isn't reporting any errors ...__
+
+A. The most likely reason is that the syntax checker that it requires isn't installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executable is required, just look in `syntax_checkers/<filetype>.vim`.
+
+Another reason it could fail is that the error output for the syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then create an issue - or better yet, create a pull request.
+
+
Changelog
---------
2.3.0 (16-feb-2012)
@@ -38,6 +38,69 @@ function! s:Init()
call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
endfunction
+" default include directories
+let s:default_includes = [ '.', '..', 'include', 'includes',
+ \ '../include', '../includes' ]
+
+" uniquify the input list
+function! s:Unique(list)
+ let l = []
+ for elem in a:list
+ if index(l, elem) == -1
+ let l = add(l, elem)
+ endif
+ endfor
+ return l
+endfunction
+
+" get the gcc include directory argument depending on the default
+" includes and the optional user-defined 'g:syntastic_c_include_dirs'
+function! syntastic#c#GetIncludeDirs(filetype)
+ let include_dirs = copy(s:default_includes)
+
+ if exists('g:syntastic_'.a:filetype.'_include_dirs')
+ call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
+ endif
+
+ return join(map(s:Unique(include_dirs), '"-I" . v:val'), ' ')
+endfunction
+
+" 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)
+ " search in the current file's directory upwards
+ let config = findfile(a:file, '.;')
+ if config == '' || !filereadable(config) | return '' | endif
+
+ " convert filename into absolute path
+ let filepath = substitute(fnamemodify(config, ':p:h'), '\', '/', 'g')
+
+ " try to read config file
+ try
+ let lines = map(readfile(config),
+ \ 'substitute(v:val, ''\'', ''/'', ''g'')')
+ catch /E484/
+ return ''
+ endtry
+
+ let parameters = []
+ for line in lines
+ let matches = matchlist(line, '^\s*-I\s*\(\S\+\)')
+ if matches != [] && matches[1] != ''
+ " this one looks like an absolute path
+ if match(matches[1], '^\%(/\|\a:\)') != -1
+ call add(parameters, '-I' . matches[1])
+ else
+ call add(parameters, '-I' . filepath . '/' . matches[1])
+ endif
+ else
+ call add(parameters, line)
+ endif
+ endfor
+
+ return join(parameters, ' ')
+endfunction
+
" search the first 100 lines for include statements that are
" given in the handlers dictionary
function! syntastic#c#SearchHeaders()
@@ -127,6 +127,10 @@ function! s:UpdateErrors(auto_invoked)
call s:RefreshSigns()
endif
+ if g:syntastic_enable_highlighting
+ call s:HightlightErrors()
+ endif
+
if g:syntastic_auto_jump && s:BufHasErrorsOrWarningsToDisplay()
silent! ll
endif
@@ -350,6 +354,43 @@ function! s:ShowLocList()
endif
endfunction
+"highlight the current errors using matchadd()
+"
+"The function `Syntastic_{&ft}_GetHighlightRegex` is used to get the regex to
+"highlight errors that do not have a 'col' key (and hence cant be done
+"automatically). This function must take one arg (an error item) and return a
+"regex to match that item in the buffer.
+"
+"If the 'force_highlight_callback' key is set for an error item, then invoke
+"the callback even if it can be highlighted automatically.
+function! s:HightlightErrors()
+ call s:ClearErrorHighlights()
+
+ let fts = substitute(&ft, '-', '_', 'g')
+ for ft in split(fts, '\.')
+
+ for item in s:LocList()
+
+ let force_callback = has_key(item, 'force_highlight_callback') && item['force_highlight_callback']
+
+ let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
+ if get( item, 'col' ) && !force_callback
+ let lastcol = col([item['lnum'], '$'])
+ let lcol = min([lastcol, item['col']])
+ call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c')
+ else
+
+ if exists("*SyntaxCheckers_". ft ."_GetHighlightRegex")
+ let term = SyntaxCheckers_{ft}_GetHighlightRegex(item)
+ if len(term) > 0
+ call matchadd(group, '\%' . item['lnum'] . 'l' . term)
+ endif
+ endif
+ endif
+ endfor
+ endfor
+endfunction
+
"remove all error highlights from the window
function! s:ClearErrorHighlights()
for match in getmatches()
@@ -425,8 +466,8 @@ endfunction
"load the chosen checker for the current filetype - useful for filetypes like
"javascript that have more than one syntax checker
-function! s:LoadChecker(checker)
- exec "runtime syntax_checkers/" . &ft . "/" . a:checker . ".vim"
+function! s:LoadChecker(checker, ft)
+ exec "runtime syntax_checkers/" . a:ft . "/" . a:checker . ".vim"
endfunction
"return a string representing the state of buffer according to
@@ -541,37 +582,6 @@ function! SyntasticErrorBalloonExpr()
return get(b:syntastic_balloons, v:beval_lnum, '')
endfunction
-"highlight the list of errors (a:errors) using matchadd()
-"
-"a:termfunc is provided to highlight errors that do not have a 'col' key (and
-"hence cant be done automatically). This function must take one arg (an error
-"item) and return a regex to match that item in the buffer.
-"
-"an optional boolean third argument can be provided to force a:termfunc to be
-"used regardless of whether a 'col' key is present for the error
-function! SyntasticHighlightErrors(errors, termfunc, ...)
- if !g:syntastic_enable_highlighting
- return
- endif
-
- call s:ClearErrorHighlights()
-
- let force_callback = a:0 && a:1
- for item in a:errors
- let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
- if item['col'] && !force_callback
- let lastcol = col([item['lnum'], '$'])
- let lcol = min([lastcol, item['col']])
- call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c')
- else
- let term = a:termfunc(item)
- if len(term) > 0
- call matchadd(group, '\%' . item['lnum'] . 'l' . term)
- endif
- endif
- endfor
-endfunction
-
"take a list of errors and add default values to them from a:options
function! SyntasticAddToErrors(errors, options)
for i in range(0, len(a:errors)-1)
@@ -592,22 +602,24 @@ endfunction
"well as the names of the actual syntax checker executables. The checkers
"should be listed in order of default preference.
"
-"if a option called 'g:syntastic_[filetype]_checker' exists then attempt to
+"a:ft should be the filetype for the checkers being loaded
+"
+"if a option called 'g:syntastic_{a:ft}_checker' exists then attempt to
"load the checker that it points to
-function! SyntasticLoadChecker(checkers)
- let opt_name = "g:syntastic_" . &ft . "_checker"
+function! SyntasticLoadChecker(checkers, ft)
+ let opt_name = "g:syntastic_" . a:ft . "_checker"
if exists(opt_name)
let opt_val = {opt_name}
if index(a:checkers, opt_val) != -1 && executable(opt_val)
- call s:LoadChecker(opt_val)
+ call s:LoadChecker(opt_val, a:ft)
else
echoerr &ft . " syntax not supported or not installed."
endif
else
for checker in a:checkers
if executable(checker)
- return s:LoadChecker(checker)
+ return s:LoadChecker(checker, a:ft)
endif
endfor
endif
@@ -46,6 +46,13 @@
"
" let g:syntastic_c_compiler_options = ' -ansi'
"
+" Additionally the setting 'g:syntastic_c_config_file' allows you to define a
+" file that contains additional compiler arguments like include directories or
+" CFLAGS. The file is expected to contain one option per line. If none is
+" given the filename defaults to '.syntastic_c_config':
+"
+" let g:syntastic_c_config_file = '.config'
+"
" Using the global variable 'g:syntastic_c_remove_include_errors' you can
" specify whether errors of files included via the g:syntastic_c_include_dirs'
" setting are removed from the result set:
@@ -64,56 +71,37 @@ endif
let s:save_cpo = &cpo
set cpo&vim
-" default include directories
-let s:default_includes = [ '.', '..', 'include', 'includes',
- \ '../include', '../includes' ]
-
-" uniquify the input list
-function! s:Unique(list)
- let l = []
- for elem in a:list
- if index(l, elem) == -1
- let l = add(l, elem)
- endif
- endfor
- return l
-endfunction
-
-" get the gcc include directory argument depending on the default
-" includes and the optional user-defined 'g:syntastic_c_include_dirs'
-function! s:GetIncludeDirs()
- let include_dirs = s:default_includes
-
- if exists('g:syntastic_c_include_dirs')
- call extend(include_dirs, g:syntastic_c_include_dirs)
- endif
+if !exists('g:syntastic_c_compiler_options')
+ let g:syntastic_c_compiler_options = '-std=gnu99'
+endif
- return join(map(s:Unique(include_dirs), '"-I" . v:val'), ' ')
-endfunction
+if !exists('g:syntastic_c_config_file')
+ let g:syntastic_c_config_file = '.syntastic_c_config'
+endif
function! SyntaxCheckers_c_GetLocList()
- let makeprg = 'gcc -fsyntax-only -std=gnu99 '.shellescape(expand('%')).
- \ ' '.s:GetIncludeDirs()
+ let makeprg = 'gcc -fsyntax-only '
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
\ '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'
+ " add optional user-defined compiler options
+ let makeprg .= g:syntastic_c_compiler_options
+
+ let makeprg .= ' '.shellescape(expand('%')).
+ \ ' '.syntastic#c#GetIncludeDirs('c')
+
" determine whether to parse header files as well
if expand('%') =~? '.h$'
if exists('g:syntastic_c_check_header')
let makeprg = 'gcc -c '.shellescape(expand('%')).
- \ ' '.s:GetIncludeDirs()
+ \ ' '.syntastic#c#GetIncludeDirs('c')
else
return []
endif
endif
- " add optional user-defined compiler options
- if exists('g:syntastic_c_compiler_options')
- let makeprg .= g:syntastic_c_compiler_options
- endif
-
" check if the user manually set some cflags
if !exists('b:syntastic_c_cflags')
" check whether to search for include files at all
@@ -136,6 +124,9 @@ function! SyntaxCheckers_c_GetLocList()
let makeprg .= b:syntastic_c_cflags
endif
+ " add optional config file parameters
+ let makeprg .= syntastic#c#ReadConfig(g:syntastic_c_config_file)
+
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg,
\ 'errorformat': errorformat })
Oops, something went wrong.

0 comments on commit 96636a5

Please sign in to comment.