dense-analysis / ale

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

Implement project configuration files #832

Closed w0rp closed 7 years ago

w0rp commented 7 years ago

Some people want to configure ALE differently for different projects. Support should be added for loading a project configuration file before linting or fixing is done. It should work like so.

  1. Add an option for enabling per-project configuration files.
  2. Add an option for changing the project file configuration name.
  3. When project configuration files are enabled, and before fixing or linting is done, :source the configuration file to run whatever VimL code is contained within.

A variable might need to be set for the configuration file like g:ale_active_buffer for determining which buffer is being checked or fixed, as the current buffer (bufnr('')) might be a different buffer from the buffer being checked or fixed.

avimmer commented 7 years ago

Should it? As long as the plugin can react to change of global variables while being active the local vimrc plugin solves the problem (at least on per vim instance basis).

w0rp commented 7 years ago

Yeah, that'll do the job. I won't implement this then. If anyone else asks how to handle this, I'll put it in the FAQ.

offero commented 5 years ago

I just came here looking for the same way to have ale use eslint for 1 project and healthier for another.

w0rp commented 5 years ago

You can use one of many Vim plugins that implement project configuration files and buffer-specific options in ALE. (Those that begin with b:). You can also try using g:ale_pattern_options to set options based on regular expression matches for paths.

Flimm commented 4 months ago

Neovim has a way to run local .nvim.lua, .nvimrc or .exrc files in the current directory, if the file is in the trust list. See :help 'exrc'. Vim also has the exrc option, but it doesn't seem to have a way to mark files as trusted, so Vim's implementation is considered dangerous and insecure, as mentioned in Vim's :help 'exrc'.

Here's an example for Neovim, to disable ALE's automated fixing in a certain project. Create a file named .nvim.lua in your current directory, with this line:

vim.g.ale_fix_on_save = 0

When you run Neovim in this directory for the first time, you will be asked whether you want to mark .nvim.lua in this directory as trusted or not. If you trust it, the hash of the file is saved. If the file changes contents, you will be asked again if you trust it or not.