-
Notifications
You must be signed in to change notification settings - Fork 463
/
jslint.vim
26 lines (23 loc) · 991 Bytes
/
jslint.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
"" jslint.vim
"" jslint plugin for vim
""
"" 1. Save this file and "jslint.mjs" to directory "~/.vim/"
"" 2. Add vim-command ":source ~/.vim/jslint.vim" to file "~/.vimrc"
"" 3. Vim can now jslint files (via nodejs):
"" - with vim-command ":SaveAndJslint"
"" - with vim-key-combo "<Ctrl-S> <Ctrl-J>"
"" this function will save current file and jslint it (via nodejs)
function! SaveAndJslint(bang)
"" save file
if a:bang == "!" | write! | else | write | endif
"" jslint file (via nodejs)
let &l:errorformat = "%f:%n:%l:%c:%m"
let &l:makeprg = "node \"" . $HOME . "/.vim/jslint.mjs\" --mode-vim-plugin"
\ . " \"" . fnamemodify(bufname("%"), ":p") . "\""
silent make! | cwindow | redraw!
endfunction
"" create vim-command ":SaveAndJslint"
command! -nargs=* -bang SaveAndJslint call SaveAndJslint("<bang>")
"" map vim-key-combo "<ctrl-s> <ctrl-j>" to ":SaveAndJslint"
inoremap <c-s><c-j> <esc> :SaveAndJslint <cr>
nnoremap <c-s><c-j> :SaveAndJslint <cr>