sql-lint
sql-lint copied to clipboard
[Question] How to use with Vim/Ale?
Hi,
I found some instructions for using Vim/Ale here: https://github.com/joereynolds/sql-lint/issues/30
But, :ALELint isn't returning anything when I open up a faulty SQL file...
I have installed and configured it in my vimrc like this:
Plug 'dense-analysis/ale', { 'for': ['sql'] }
Plug 'joereynolds/sql-lint.', {'do': 'npm install'}
...
let g:ale_linters = { 'sql': ['sql-lint'] }
I can't really seem to figure out where the executable sql-lint is supposed to be living? I looked in ~/.vim/plugged/sql-lint/node_modules/.bin/ but I don't see it there, or in /usr/local/bin...
Hey @jakebrinkmann,
You shouldn't need to install my package in your vimrc. Ale has support for it built-in. As long as sql-lint is available globally (/usr/local/bin should definitely work) then it should be picked up by Ale.
You don't need these lines:
Plug 'joereynolds/sql-lint.', {'do': 'npm install'}
and
let g:ale_linters = { 'sql': ['sql-lint'] }
I'd also remove the for from Ale's installation requirement too as I imagine you want ale to lint more than just sql? In which case it would look like:
Plug 'dense-analysis/ale'
Lastly, I use Neovim, it's untested on vim but there should be no reason why it does not work there too.
Once you've fixed the above, can you confirm:
-
What does
which sql-lintreturn? -
Open up an SQL file and put this in and wait a few seconds* for the errors to appear. Does anything happen?
DELETE FROM person;
- Do you have a config file for
sql-lint? It's not mandatory but if you do, can you copy and paste it here (redacting the DB details of course)
You shouldn't need to install my package in your vimrc. [....] As long as sql-lint is available globally
I think it would be better if I can install this with Plug. I don't have another use case for sql-lint besides inside vim, so I would rather not install it globally.
Hmmm okay, I get your point, I'll add it as an issue. I might need to create a separate plugin from this main repository :+1: