我一直在遵循以下两个教程来尝试设置eslint
和Neomake
:
所以我有以下最低限度 init.vim
call plug#begin('~/.vim/plugged')
Plug 'neomake/neomake'
call plug#end()
autocmd! BufWritePost,BufEnter * Neomake
let g:neomake_verbose=3
let g:neomake_open_list = 2
let g:neomake_javascript_enabled_makers = ['eslint']
" neomake
nmap <Leader><Space>o :lopen<CR> " open location window
nmap <Leader><Space>c :lclose<CR> " close location window
nmap <Leader><Space>, :ll<CR> " go to current error/warning
nmap <Leader><Space>n :lnext<CR> " next error/warning
nmap <Leader><Space>p :lprev<CR> " previous error/warning
问题是当我保存Neomake
时出现以下消息:
Neomake: Starting: eslint -f compact /home/otis/Developer/test/index.js
如果我nvim
像这样手动运行该命令:
eslint -f compact /home/otis/Developer/test/index.js
我收到以下输出:
/home/otis/Developer/test/index.js: line 1, col 1, Error - Unexpected var, use let or const instead. (no-var)
/home/otis/Developer/test/index.js: line 1, col 5, Error - 'a' is defined but never used. (no-unused-vars)
/home/otis/Developer/test/index.js: line 1, col 9, Error - Strings must use singlequote. (quotes)
3 problems
好的意味着eslint
工作正常,但我什么都没收Neomake
。
如果我运行:lopen
,则会弹出窗口,然后立即关闭,如下所示:
我的vim
/ nvim
知识有些基础,因此请在回答中明确说明。
实际上,这可能是“快速修复”窗口为空的原因。在屏幕上,当您运行
—
grodzik 2016年
:lopen
Neocast 时,由于BufEnter的autocmd,该缓冲区将运行该缓冲区。@Yonsy代码段很好,但应仅限于JavaScript文件:augroup neomake/ au!/ autocmd BufWritePost *.js Neomake/ augroup END
autocmd! BufWritePost,BufEnter * Neomake
,以augroup neomake/ au!/ autocmd BufWritePost * Neomake/ augroup END
BufEnter没有太多的意义