11

I have been following the following two tutorials to try and set up eslint and Neomake:

So I have the following minimal 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

The problem is when I save Neomake hangs with the following message:

Neomake: Starting: eslint -f compact /home/otis/Developer/test/index.js

If i run that command manually outside of nvim like so:

eslint -f compact /home/otis/Developer/test/index.js

I receive the following output:

/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

Which is good it means eslint is working but I am getting nothing back from Neomake.

If I run :lopen the window pops up and then instantly closes like below:

Window open then close

My vim/nvim knowledge is somewhat basic so please be explicit in responses.

  • try to change your autocmd! BufWritePost,BufEnter * Neomake to augroup neomake/ au!/ autocmd BufWritePost * Neomake/ augroup END BufEnter don't have many sense – Yonsy Solis Sep 5 '16 at 1:18
  • Actually this might be the reason for empty Quick fix window. On your screen cast when you run :lopen Neomake runs for that buffer due to autocmd for BufEnter. @Yonsy snippet is good, but should be additionally limited to JavaScript files only: augroup neomake/ au!/ autocmd BufWritePost *.js Neomake/ augroup END – grodzik Dec 22 '16 at 18:12
0

This doesn't exactly answer your question, but I found that neomake works better with eslint_d. It has the nice side effect that it should do the linting faster too.

You first have to install eslint_d globally (but it still seems to pick up any local .eslintrc file):

npm install -g eslint_d

Then add the following configuration for neomake to your init.vim / .vimrc:

let g:neomake_javascript_enabled_makers = ['eslint_d']

For me that was all I required, after restarting neovim and opening a javascript file running :Neomake gave me eslint warnings.

0

Some [lightly edited] info from the comments:

Actually this might be the reason for empty Quickfix window. On your screen cast when you run :lopen, Neomake runs for that buffer due to the autocmd for BufEnter. It should be additionally limited to JavaScript files only:

augroup neomake
  au!
  autocmd BufWritePost *.js Neomake
augroup END

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.