Skip to content

Commit df841a0

Browse files
committed
vim: add vue/ts <leader>l map for eslint
1 parent 89e630a commit df841a0

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function! s:RunCompiler(program) abort
2+
let old_compiler = get(b:, 'current_compiler', '')
3+
let old_makeprg = &l:makeprg
4+
let old_errorformat = &l:errorformat
5+
6+
try
7+
silent! execute 'compiler' a:program
8+
silent! execute 'make' '%'
9+
10+
" if qf list has anything in it, open it
11+
if len(getqflist()) > 0
12+
" only open if it's not already open
13+
if empty(filter(range(1, winnr('$')), 'getwinvar(v:val, "&buftype") ==# "quickfix"'))
14+
silent! execute 'botright copen'
15+
endif
16+
else
17+
silent! execute 'cclose'
18+
end
19+
20+
redraw!
21+
finally
22+
let b:current_compiler = old_compiler
23+
let &l:makeprg = old_makeprg
24+
let &l:errorformat = old_errorformat
25+
endtry
26+
endfunction
27+
28+
augroup eslint_buffers
29+
autocmd!
30+
autocmd BufRead,BufNewFile *.vue,*.ts nnoremap <buffer> <leader>l :<C-u>call <SID>RunCompiler('eslint')<CR>
31+
augroup END

0 commit comments

Comments
 (0)