dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.48k stars 1.43k forks source link

[Improvement Suggestion][sqlfluff] Allow other config file other than `.sqlfluff` #4554

Open keatmin opened 1 year ago

keatmin commented 1 year ago

sqlfluff looks for the list of these files here automatically and should not require a hardcoded .sqlfluff to be looked up in the linter and in the fixer. Users of other config file and in my case pyproject.toml have no choice but to migrate to .sqlfluff

I want to suggest that we remove the constraint on allowing only .sqlfluff file as config file and let sqlfluff search for it.

pbnj commented 1 year ago

Hi @keatmin - thank you for the suggestion. This seems like a good change to me, but I am not a sqlfluff user.

The sqlfluff fixer is defined here and the linter is defined here

Seems that removing these blocks is all that is needed?

Are you able to test this change locally and submit a PR if it works?

keatmin commented 1 year ago

Hey @pbnj,

More than happy to submit a PR, just wanted to create an issue first.

I removed the block and it didn't work mainly because that we had %t in this and this which caused the tool to search for the config file in the temp folder instead of the buffer.

So what I will do is I can add a new variable to allow user to list their own config file via g:ale_sql_sqlfluff_config_file instead.

pbnj commented 1 year ago

@keatmin -

Thank you for testing it and reporting back.

So what I will do is I can add a new variable to allow user to list their own config file via g:ale_sql_sqlfluff_config_file instead.

Adding a config option may be nice. You may also default it to the same list of configuration files that sqlfluff expects, because later config values may override previous config values, according to the docs you linked earlier:

For file based configuration SQLFluff will look for the following files in order. Later files will (if found) will be used to overwrite any values read from earlier files.

  • setup.cfg
  • tox.ini
  • pep8.ini
  • .sqlfluff
  • pyproject.toml