Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update syntastic

  • Loading branch information...
commit 415659132b39eaf7750f5145cd8e59ca50e5544b 1 parent 5325439
Jeremy Voorhis authored January 14, 2013
7  .vim/bundle/syntastic/autoload/syntastic/c.vim
@@ -67,7 +67,12 @@ endfunction
67 67
 " get the gcc include directory argument depending on the default
68 68
 " includes and the optional user-defined 'g:syntastic_c_include_dirs'
69 69
 function! syntastic#c#GetIncludeDirs(filetype)
70  
-    let include_dirs = copy(s:default_includes)
  70
+    let include_dirs = []
  71
+
  72
+    if !exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') ||
  73
+        \ !g:syntastic_{a:filetype}_no_default_include_dirs
  74
+        let include_dirs = copy(s:default_includes)
  75
+    endif
71 76
 
72 77
     if exists('g:syntastic_'.a:filetype.'_include_dirs')
73 78
         call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
65  .vim/bundle/syntastic/autoload/syntastic/makeprg.vim
... ...
@@ -0,0 +1,65 @@
  1
+if exists("g:loaded_syntastic_makeprg_autoload")
  2
+    finish
  3
+endif
  4
+let g:loaded_syntastic_makeprg_autoload = 1
  5
+
  6
+function! syntastic#makeprg#build(opts)
  7
+    let opts = copy(a:opts)
  8
+
  9
+    if !has_key(opts, 'args')
  10
+        let opts['args'] = ''
  11
+    endif
  12
+
  13
+    if !has_key(opts, 'subchecker')
  14
+        let opts['subchecker'] = ''
  15
+    endif
  16
+
  17
+    let builder = s:MakeprgBuilder.New(opts['exe'], opts['args'], opts['subchecker'])
  18
+    return builder.makeprg()
  19
+endfunction
  20
+
  21
+let s:MakeprgBuilder = {}
  22
+
  23
+function! s:MakeprgBuilder.New(exe, args, subchecker)
  24
+    let newObj = copy(self)
  25
+    let newObj._exe = a:exe
  26
+    let newObj._args = a:args
  27
+    let newObj._subchecker = a:subchecker
  28
+    return newObj
  29
+endfunction
  30
+
  31
+function! s:MakeprgBuilder.makeprg()
  32
+    return join([self.exe(), self.args(), self.fname()])
  33
+endfunction
  34
+
  35
+function! s:MakeprgBuilder.exe()
  36
+    if self.optExists('exe')
  37
+        return {self.optName('exe')}
  38
+    endif
  39
+
  40
+    return self._exe
  41
+endfunction
  42
+
  43
+function! s:MakeprgBuilder.args()
  44
+    if exists('g:syntastic_' . &ft . '_args')
  45
+        return g:syntastic_{&ft}_args
  46
+    endif
  47
+
  48
+    return self._args
  49
+endfunction
  50
+
  51
+function! s:MakeprgBuilder.fname()
  52
+    return shellescape(expand("%"))
  53
+endfunction
  54
+
  55
+function! s:MakeprgBuilder.optExists(name)
  56
+    return exists(self.optName(a:name))
  57
+endfunction
  58
+
  59
+function! s:MakeprgBuilder.optName(name)
  60
+    let setting = "g:syntastic_" . &ft
  61
+    if !empty(self._subchecker)
  62
+        let setting .= '_' . self._subchecker
  63
+    endif
  64
+    return setting . '_' . a:name
  65
+endfunction
24  .vim/bundle/syntastic/autoload/syntastic/util.vim
@@ -13,6 +13,30 @@ function! syntastic#util#DevNull()
13 13
     return '/dev/null'
14 14
 endfunction
15 15
 
  16
+"search the first 5 lines of the file for a magic number and return a map
  17
+"containing the args and the executable
  18
+"
  19
+"e.g.
  20
+"
  21
+"#!/usr/bin/perl -f -bar
  22
+"
  23
+"returns
  24
+"
  25
+"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
  26
+function! syntastic#util#ParseShebang()
  27
+    for lnum in range(1,5)
  28
+        let line = getline(lnum)
  29
+
  30
+        if line =~ '^#!'
  31
+            let exe = matchstr(line, '^#!\s*\zs[^ \t]*')
  32
+            let args = split(matchstr(line, '^#!\s*[^ \t]*\zs.*'))
  33
+            return {'exe': exe, 'args': args}
  34
+        endif
  35
+    endfor
  36
+
  37
+    return {'exe': '', 'args': []}
  38
+endfunction
  39
+
16 40
 let &cpo = s:save_cpo
17 41
 unlet s:save_cpo
18 42
 " vim: set et sts=4 sw=4:
4  .vim/bundle/syntastic/syntax_checkers/c.vim
@@ -14,8 +14,8 @@ if !exists('g:syntastic_c_checker')
14 14
     let g:syntastic_c_checker = "gcc"
15 15
 endif
16 16
 
17  
-if g:syntastic_c_checker == "gcc"
18  
-    if executable("gcc")
  17
+if g:syntastic_c_checker == "gcc" || g:syntastic_c_checker == "clang"
  18
+    if executable(g:syntastic_c_checker)
19 19
         runtime! syntax_checkers/c/gcc.vim
20 20
     endif
21 21
 elseif g:syntastic_c_checker == "checkpatch"
12  .vim/bundle/syntastic/syntax_checkers/c/gcc.vim
@@ -19,6 +19,11 @@
19 19
 "
20 20
 "   let g:syntastic_c_no_include_search = 1
21 21
 "
  22
+" To disable the include of the default include dirs (such as /usr/include)
  23
+" add this line to your .vimrc:
  24
+"
  25
+"   let g:syntastic_c_no_default_include_dirs = 1
  26
+"
22 27
 " To enable header files being re-checked on every file write add the
23 28
 " following line to your .vimrc. Otherwise the header files are checked only
24 29
 " one time on initially loading the file.
@@ -68,7 +73,7 @@ if exists('loaded_gcc_syntax_checker')
68 73
 endif
69 74
 let loaded_gcc_syntax_checker = 1
70 75
 
71  
-if !executable('gcc')
  76
+if !executable(g:syntastic_c_checker)
72 77
     finish
73 78
 endif
74 79
 
@@ -84,7 +89,7 @@ if !exists('g:syntastic_c_config_file')
84 89
 endif
85 90
 
86 91
 function! SyntaxCheckers_c_GetLocList()
87  
-    let makeprg = 'gcc -fsyntax-only '
  92
+    let makeprg = g:syntastic_c_checker . ' -x c -fsyntax-only '
88 93
     let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
89 94
                \ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
90 95
                \ 'each function it appears%.%#,%-GIn file included%.%#,'.
@@ -105,7 +110,8 @@ function! SyntaxCheckers_c_GetLocList()
105 110
     " determine whether to parse header files as well
106 111
     if expand('%') =~? '.h$'
107 112
         if exists('g:syntastic_c_check_header')
108  
-            let makeprg = 'gcc -c '.shellescape(expand('%')) .
  113
+            let makeprg = g:syntastic_c_checker
  114
+                        \ ' -c ' . shellescape(expand('%')) .
109 115
                         \ ' ' . g:syntastic_c_compiler_options .
110 116
                         \ ' ' . syntastic#c#GetNullDevice() .
111 117
                         \ ' ' . syntastic#c#GetIncludeDirs('c')
4  .vim/bundle/syntastic/syntax_checkers/coffee.vim
@@ -21,7 +21,9 @@ endif
21 21
 
22 22
 
23 23
 function! SyntaxCheckers_coffee_GetLocList()
24  
-    let makeprg = 'coffee -c -l -o /tmp '.shellescape(expand('%'))
  24
+    let makeprg = syntastic#makeprg#build({
  25
+                \ 'exe': 'coffee',
  26
+                \ 'args': '-c -l -o /tmp' })
25 27
     let errorformat =  'Syntax%trror: In %f\, %m on line %l,%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%.%#'
26 28
 
27 29
     let coffee_results = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
7  .vim/bundle/syntastic/syntax_checkers/cpp.vim
@@ -19,6 +19,11 @@
19 19
 "
20 20
 "   let g:syntastic_cpp_no_include_search = 1
21 21
 "
  22
+" To disable the include of the default include dirs (such as /usr/include)
  23
+" add this line to your .vimrc:
  24
+"
  25
+"   let g:syntastic_cpp_no_default_include_dirs = 1
  26
+"
22 27
 " In order to add some custom include directories that should be added to the
23 28
 " gcc command line you can add those to the global variable
24 29
 " g:syntastic_cpp_include_dirs. This list can be used like this:
@@ -87,7 +92,7 @@ if !exists('g:syntastic_cpp_config_file')
87 92
 endif
88 93
 
89 94
 function! SyntaxCheckers_cpp_GetLocList()
90  
-    let makeprg = g:syntastic_cpp_compiler . ' -fsyntax-only ' .
  95
+    let makeprg = g:syntastic_cpp_compiler . ' -x c++ -fsyntax-only ' .
91 96
                 \ g:syntastic_cpp_compiler_options
92 97
     let errorformat =  '%-G%f:%s:,%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: '.
93 98
                 \ '%m,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %tarning: %m,'.
14  .vim/bundle/syntastic/syntax_checkers/dart.vim
... ...
@@ -0,0 +1,14 @@
  1
+"============================================================================
  2
+"File:        dart.vim
  3
+"Description: Figures out which dart syntax checker (if any) to load
  4
+"             from the dart directory.
  5
+"Maintainer:  Maksim Ryzhikov <rv.maksim at gmail dot com>
  6
+"License:     This program is free software. It comes without any warranty,
  7
+"             to the extent permitted by applicable law. You can redistribute
  8
+"             it and/or modify it under the terms of the Do What The Fuck You
  9
+"             Want To Public License, Version 2, as published by Sam Hocevar.
  10
+"             See http://sam.zoy.org/wtfpl/COPYING for more details.
  11
+"
  12
+"============================================================================
  13
+
  14
+call SyntasticLoadChecker('dart')
21  .vim/bundle/syntastic/syntax_checkers/dart/dart_analyzer.vim
... ...
@@ -0,0 +1,21 @@
  1
+"============================================================================
  2
+"File:        dart_analyzer.vim
  3
+"Description: Dart syntax checker - using dart_analyzer
  4
+"Maintainer:  Maksim Ryzhikov <rv.maksim at gmail dot com>
  5
+"License:     This program is free software. It comes without any warranty,
  6
+"             to the extent permitted by applicable law. You can redistribute
  7
+"             it and/or modify it under the terms of the Do What The Fuck You
  8
+"             Want To Public License, Version 2, as published by Sam Hocevar.
  9
+"             See http://sam.zoy.org/wtfpl/COPYING for more details.
  10
+"============================================================================
  11
+if !exists("g:syntastic_dart_analyzer_conf")
  12
+    let g:syntastic_dart_analyzer_conf = ''
  13
+endif
  14
+
  15
+function! SyntaxCheckers_dart_GetLocList()
  16
+    let args = !empty(g:syntastic_dart_analyzer_conf) ? ' ' . g:syntastic_dart_analyzer_conf : ''
  17
+    let makeprg = 'dart_analyzer ' . shellescape(expand("%")) . args
  18
+
  19
+    let errorformat = '%Efile:%f:%l:%c: %m'
  20
+    return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
  21
+endfunction
13  .vim/bundle/syntastic/syntax_checkers/efm_perl.pl
@@ -68,6 +68,7 @@
68 68
 use warnings;
69 69
 use strict;
70 70
 use Getopt::Std;
  71
+use File::Temp qw( tempfile );
71 72
 
72 73
 use vars qw/$opt_I $opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars'
73 74
 
@@ -91,13 +92,23 @@
91 92
 (my $file = shift) or &usage; # display usage if no filename is supplied
92 93
 my $args = (@ARGV ? ' ' . join ' ', @ARGV : '');
93 94
 
94  
-my $libs = join ' ', map {"-I$_"} split ',', $opt_I;
  95
+if ($file eq '-') { # make STDIN seek-able, so it can be read twice
  96
+    my $fh = tempfile();
  97
+    print {$fh} <STDIN>;
  98
+    open \*STDIN, '<&', $fh or die "open: $!";
  99
+    seek \*STDIN, 0, 0 or die "seek: $!";
  100
+}
  101
+
  102
+my $libs = join ' ', map {"-I$_"} split ',', $opt_I || '';
95 103
 my @error_lines = `perl $libs @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-Mwarnings ']} "$file$args" 2>&1`;
96 104
 
97 105
 my @lines = map { "E:$_" } @error_lines;
98 106
 
99 107
 my @warn_lines;
100 108
 if(defined($opt_w)) {
  109
+    if ($file eq '-') {
  110
+        seek \*STDIN, 0, 0 or die "seek: $!";
  111
+    }
101 112
     @warn_lines = `perl $libs @{[defined $opt_c ? '-c ' : '' ]} -Mwarnings "$file$args" 2>&1`;
102 113
 }
103 114
 
3  .vim/bundle/syntastic/syntax_checkers/html/tidy.vim
@@ -34,7 +34,8 @@ let s:ignore_html_errors = [
34 34
                 \ "<meta> proprietary attribute \"charset\"",
35 35
                 \ "<meta> lacks \"content\" attribute",
36 36
                 \ "inserting \"type\" attribute",
37  
-                \ "proprietary attribute \"data-"
  37
+                \ "proprietary attribute \"data-",
  38
+                \ "<input> attribute \"type\" has invalid value \"search\""
38 39
                 \]
39 40
 
40 41
 function! s:ValidateError(text)
79  .vim/bundle/syntastic/syntax_checkers/java/javac.vim
@@ -28,10 +28,26 @@ if !exists("g:syntastic_java_javac_delete_output")
28 28
     let g:syntastic_java_javac_delete_output = 1
29 29
 endif
30 30
 
  31
+if !exists("g:syntastic_java_javac_temp_dir")
  32
+    if has('win32') || has('win64')
  33
+        let g:syntastic_java_javac_temp_dir = $TEMP."\\vim-syntastic-javac"
  34
+    else
  35
+        let g:syntastic_java_javac_temp_dir = '/tmp/vim-syntastic-javac'
  36
+    endif
  37
+endif
  38
+
31 39
 if !exists("g:syntastic_java_javac_autoload_maven_classpath")
32 40
     let g:syntastic_java_javac_autoload_maven_classpath = 1
33 41
 endif
34 42
 
  43
+if !exists('g:syntastic_java_javac_config_file_enabled')
  44
+    let g:syntastic_java_javac_config_file_enabled = 0
  45
+endif
  46
+
  47
+if !exists('g:syntastic_java_javac_config_file')
  48
+    let g:syntastic_java_javac_config_file = '.syntastic_javac_config'
  49
+endif
  50
+
35 51
 " Internal variables, do not ovveride those
36 52
 if !exists("g:syntastic_java_javac_maven_pom_cwd")
37 53
     let g:syntastic_java_javac_maven_pom_cwd = ''
@@ -45,20 +61,55 @@ if !exists("g:syntastic_java_javac_maven_pom_classpath")
45 61
     let g:syntastic_java_javac_maven_pom_classpath = ''
46 62
 endif
47 63
 
  64
+" recursively remove directory and all it's sub-directories
  65
+function! s:RemoveDir(dir)
  66
+    if isdirectory(a:dir)
  67
+        for f in split(globpath(a:dir,'*'),"\n")
  68
+            call s:RemoveDir(f)
  69
+        endfor
  70
+        silent! call system('rmdir '.a:dir) 
  71
+    else
  72
+        silent! call delete(a:dir)
  73
+    endif
  74
+endfunction
  75
+
48 76
 function! s:AddToClasspath(classpath,path)
49 77
     if a:path == ''
50 78
         return a:classpath
51 79
     endif
52 80
     if a:classpath != '' && a:path != ''
53  
-        return a:classpath . ":" . a:path
  81
+        if has('win32') || has('win64')
  82
+            return a:classpath . ";" . a:path
  83
+        else
  84
+            return a:classpath . ":" . a:path
  85
+        endif
54 86
     else
55 87
         return a:path
56 88
     endif
57 89
 endfunction
58 90
 
  91
+function! s:LoadClasspathFromConfigFile()
  92
+    if filereadable(g:syntastic_java_javac_config_file)
  93
+        let path = ''
  94
+        let lines = readfile(g:syntastic_java_javac_config_file)
  95
+        for l in lines
  96
+            if l != ''
  97
+                let path .= l."\n" 
  98
+            endif
  99
+        endfor
  100
+        return path
  101
+    else
  102
+        return ''
  103
+    endif
  104
+endfunction
  105
+
59 106
 function! s:SaveClasspath()
60 107
     let path = ''
61 108
     let lines = getline(1,line('$'))
  109
+    " save classpath to config file
  110
+    if g:syntastic_java_javac_config_file_enabled
  111
+        call writefile(lines,g:syntastic_java_javac_config_file)
  112
+    endif
62 113
     for l in lines
63 114
         if l != ''
64 115
             let path .= l."\n" 
@@ -112,10 +163,18 @@ function! SyntaxCheckers_java_GetLocList()
112 163
     let javac_opts = g:syntastic_java_javac_options 
113 164
 
114 165
     if g:syntastic_java_javac_delete_output
115  
-        let output_dir = '/tmp/vim-syntastic'
  166
+        let output_dir = g:syntastic_java_javac_temp_dir 
116 167
         let javac_opts .= ' -d ' .output_dir
117 168
     endif
118 169
 
  170
+    " load classpath from config file
  171
+    if g:syntastic_java_javac_config_file_enabled
  172
+        let loaded_classpath = s:LoadClasspathFromConfigFile()
  173
+        if loaded_classpath != ''
  174
+            let g:syntastic_java_javac_classpath = loaded_classpath
  175
+        endif
  176
+    endif
  177
+
119 178
     let javac_classpath = ''
120 179
 
121 180
     " add classpathes to javac_classpath
@@ -138,22 +197,30 @@ function! SyntaxCheckers_java_GetLocList()
138 197
     endif
139 198
 
140 199
     if javac_classpath != ''
141  
-        let javac_opts .= ' -cp ' . javac_classpath
  200
+        let javac_opts .= ' -cp ' . fnameescape(javac_classpath)
  201
+    endif
  202
+
  203
+
  204
+    " path seperator
  205
+    if has('win32') || has('win64')
  206
+        let sep = "\\" 
  207
+    else
  208
+        let sep = '/'
142 209
     endif
143 210
 
144 211
     let makeprg = g:syntastic_java_javac_executable . ' '. javac_opts . ' '
145  
-               \. expand ( '%:p:h' ) . '/' . expand ( '%:t' )
  212
+               \. fnameescape(expand ( '%:p:h' ) . sep . expand ( '%:t' ))
146 213
                \. ' 2>&1 '
147 214
 
148 215
     " unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types
149 216
     let errorformat = '%E%f:%l:\ error:\ %m,%W%f:%l:\ warning:\ %m,%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#'
150 217
 
151 218
     if g:syntastic_java_javac_delete_output
152  
-        call system('mkdir -p ' . output_dir)
  219
+        silent! call mkdir(output_dir,'p')
153 220
     endif
154 221
     let r = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
155 222
     if g:syntastic_java_javac_delete_output
156  
-        call system('rm -rf ' . output_dir)
  223
+        call s:RemoveDir(output_dir)
157 224
     endif
158 225
     return r
159 226
 
11  .vim/bundle/syntastic/syntax_checkers/perl.vim
@@ -40,7 +40,18 @@ function! SyntaxCheckers_perl_GetLocList()
40 40
     else
41 41
         let makeprg = g:syntastic_perl_efm_program . ' ' . shellescape(expand('%'))
42 42
     endif
  43
+    let makeprg .= s:ExtraMakeprgArgs()
  44
+
43 45
     let errorformat =  '%t:%f:%l:%m'
44 46
 
45 47
     return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
46 48
 endfunction
  49
+
  50
+function! s:ExtraMakeprgArgs()
  51
+    let shebang = syntastic#util#ParseShebang()
  52
+    if index(shebang['args'], '-T') != -1
  53
+        return ' -Tc'
  54
+    endif
  55
+
  56
+    return ''
  57
+endfunction
2  .vim/bundle/syntastic/syntax_checkers/puppet.vim
@@ -57,7 +57,7 @@ function! s:getPuppetLintErrors()
57 57
         let g:syntastic_puppet_lint_arguments = ''
58 58
     endif
59 59
 
60  
-    let makeprg = 'puppet-lint --log-format "\%{KIND} [\%{check}] \%{message} at \%{fullpath}:\%{linenumber}" '.g:syntastic_puppet_lint_arguments.shellescape(expand('%'))
  60
+    let makeprg = 'puppet-lint --log-format "\%{KIND} [\%{check}] \%{message} at \%{fullpath}:\%{linenumber}" '.g:syntastic_puppet_lint_arguments.' '.shellescape(expand('%'))
61 61
     let errorformat = '%t%*[a-zA-Z] %m at %f:%l'
62 62
     return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' })
63 63
 endfunction
5  .vim/bundle/syntastic/syntax_checkers/python/flake8.vim
@@ -22,7 +22,10 @@ function! SyntaxCheckers_python_GetHighlightRegex(i)
22 22
 endfunction
23 23
 
24 24
 function! SyntaxCheckers_python_GetLocList()
25  
-    let makeprg = 'flake8 '.g:syntastic_python_checker_args.' '.shellescape(expand('%'))
  25
+    let makeprg = syntastic#makeprg#build({
  26
+                \ 'exe': 'flake8',
  27
+                \ 'args': g:syntastic_python_checker_args,
  28
+                \ 'subchecker': 'flake8' })
26 29
     let errorformat = '%E%f:%l: could not compile,%-Z%p^,%E%f:%l:%c: %m,%W%f:%l: %m,%-G%.%#'
27 30
     return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
28 31
 endfunction
4  .vim/bundle/syntastic/syntax_checkers/scala.vim
@@ -11,7 +11,7 @@
11 11
 "============================================================================
12 12
 
13 13
 "bail if the user doesnt have the scala binary installed
14  
-if !executable("scala")
  14
+if !executable("scalac")
15 15
     finish
16 16
 endif
17 17
 
@@ -20,7 +20,7 @@ if !exists("g:syntastic_scala_options")
20 20
 endif
21 21
 
22 22
 function! SyntaxCheckers_scala_GetLocList()
23  
-    let makeprg = 'scala '. g:syntastic_scala_options .' '.  shellescape(expand('%')) . ' /dev/null'
  23
+    let makeprg = 'scalac -Ystop-after:parser '. g:syntastic_scala_options .' '.  shellescape(expand('%'))
24 24
 
25 25
     let errorformat = '%f\:%l: %trror: %m'
26 26
 

0 notes on commit 4156591

Please sign in to comment.
Something went wrong with that request. Please try again.