-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjsl.vim
70 lines (64 loc) · 2.5 KB
/
jsl.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
" Vim compiler file
" Compiler: JavaScript Lint (http://www.javascriptlint.com)
" Maintainer: Ingo Karkat <ingo@karkat.de>
"
" DEPENDENCIES:
" - jsl (http://www.javascriptlint.com).
"
" CONFIGURATION:
" The optional jsl configuration must either reside in this script's directory
" as 'jsl.conf', or its filespec can be specified in g:jsl_config.
"
" USAGE:
" :make [{jsl-args}]
"
" Copyright: (C) 2009 by Ingo Karkat
" The VIM LICENSE applies to this script; see ':help copyright'.
"
" REVISION DATE REMARKS
" 1.00.003 11-May-2009 Tested on Linux; published version.
" 002 21-Mar-2009 Doing jsl config file detection and filtering of
" empty error output lines inside the script;
" removed wrapper script. This compiler plugin now
" also works on Unix.
" 001 20-Mar-2009 file creation
if exists('current_compiler')
finish
endif
let current_compiler = 'jsl'
if exists(':CompilerSet') != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
let s:scriptDir = expand('<sfile>:p:h')
function! s:JslConfig()
let l:configFilespec = ''
if exists('g:jsl_config')
let l:configFilespec = g:jsl_config
else
let l:pathSeparator = (exists('+shellslash') && ! &shellslash ? '\' : '/')
let l:configFilespec = s:scriptDir . l:pathSeparator . 'jsl.conf'
endif
return (! empty(l:configFilespec) && filereadable(l:configFilespec) ? ' -conf "' . l:configFilespec . '"' : '')
endfunction
execute 'CompilerSet makeprg=jsl\ -nologo\ -nofilelisting\ -nosummary' . escape(s:JslConfig(), ' "\') . '\ $*\ -process\ $*\ \"%\"'
unlet s:scriptDir
" sample output:
"C:\TEMP\jsl\jsl-test.js(9): warning: test for equality (==) mistyped as assignment (=)?
" if (x = y) {
".............^
"
"C:\TEMP\jsl\jsl-test.js(21): lint warning: missing break statement
" case 1: z = --x;
"....^
"
"C:\TEMP\jsl\jsl-test.js(20): lint warning: undeclared identifier: z
"C:\TEMP\jsl\jsl-test.js(21): lint warning: undeclared identifier: z
" Errorformat: Cp. |errorformat-javac|
" JavaScript Lint emits an empty line after each "pointer line". If we filter
" this away by having the multiline pattern end with "%-Z" (i.e. match an empty
" line), the error column somehow is counted as a non-virtual column, which is
" wrong. So we let the pattern end with the "pointer line", and filter away the
" empty line in a separate "%-G" pattern.
"CompilerSet errorformat=%A%f(%l):\ %m,%-Z,%-C%p^,%-C%.%#
CompilerSet errorformat=%A%f(%l):\ %m,%-Z%p^,%-C%.%#,%-G
" vim: set sts=4 sw=4 noexpandtab ff=unix fdm=syntax :