sql-lint icon indicating copy to clipboard operation
sql-lint copied to clipboard

[Question] How to use with Vim/Ale?

Open jakebrinkmann opened this issue 5 years ago • 3 comments

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...

jakebrinkmann avatar Oct 29 '20 17:10 jakebrinkmann

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:

  1. What does which sql-lint return?

  2. 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;
  1. 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)

joereynolds avatar Oct 30 '20 08:10 joereynolds

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.

jakebrinkmann avatar Nov 09 '20 19:11 jakebrinkmann

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:

joereynolds avatar Nov 09 '20 19:11 joereynolds