I currently have some files that i don't want to lint within a project due to how massive they are. Is it possible to have linting disabled for filepaths that match a regex?
There isn't a feature for that currently. For most tools, I recommend configuring whatever configuration files to exclude certain files if possible. Not many tools support that kind of behaviour.
I wonder if perhaps a feature should be added for excluding files above a set file size from being checked, maybe files with lines that are so long.
A filename regex option might make sense. You could include matches like '.*\.min\.js' and so on.
Unfortunately the tool doesn't support that behaviour in my example.
The filename regex solution is ideal. I used to rely on that behaviour in syntastic before switching over to ale, for example, in my ~/.vimrc:
let g:syntastic_ignore_files = ['.*\.json', '.*some/folder/.*\.js']
If someone else wants to implement this, go for it. I recommend doing it in the function which queues a lint cycle. If no one else implements this, I will implement it eventually.
You can achieve this with a simple autocommand:
autocmd BufEnter *.min.js ALEDisable
But that isn't ideal since:
BufLeave autocommand.I think buffer-local variables could be a better solution.
I'll implement an ignore list like above, _eventually_, if nobody else creates a pull request for it first.
I have now accomplished this through slightly different means, which will solve this problem, and some configuration issues. You can now use let b:ale_enabled = 0 to disable ALE for a particular buffer. This will be respected by the cursor echoing function and the function for running linters. For configuring files based on patterns, I have created g:ale_pattern_options, for automatically setting buffer variables based on filename patterns. See :help g:ale_pattern_options
These options should make it possible to not only disable ALE for particular files, but also to set different linter options for different files, etc.
@mark-westerhof You should now be able to disable linting for files like so.
let g:ale_pattern_options = {
\ '.*\.json$': {'ale_enabled': 0},
\ '.*some/folder/.*\.js$': {'ale_enabled': 0},
\}
Works great. Thanks alot!
@w0rp I really appreciate the presence of this feature. I often have many buffers open in a vim but one of them is a poorly written javascript file that i have to maintain without having prioritized the refactoring that it sorely needs. The 410 warnings and 75 errors cause ALE & Vim to slow to a crawl...
Once I set b:ale_enabled=0, ALE immediately stops updating signs, but the presence of the signs themselves still slow Vim down, not to mention that this is still also an assault upon the senses. I have to run sign unplace * and save the file to bring the signify and other signs back.
I'm just after having a single button i can press to toggle the activity of ALE and to clear signs if it's getting switched off.
What make that wonderfully simple would be if I can run sign unplace ALE* but this does not work!
Edit: I've also noticed an additional issue which is that once ALE's been disabled, the line column background highlight indicators are staying put. That's actually a bigger problem than having to flush all signs to clear them out. I don't know how to clear these out.
For the time being, I really have to manually specify for this file to disable ALE from the get-go.
If you set ale_enabled to 0 with g:ale_pattern_options, linting will be disabled before any linting is done.
See :help ALEDisable for disabling ALE and removing all of the errors and everything else.
If someone wants to take the time to do it, they could write different commands which enable, disable, or toggle ALE just for one specific buffer.
@w0rp Yes! So I think we may have some components we can use to fix things. e.g. let b:ale_enabled=0 followed by ALEDisable and ALEEnable
I'm now tracking that enhancement here: #817.
Thanks for this. Ale was automatically folding my folds within my vimrc file, when editing, until I added let b:ale_enabled = 0.
Most helpful comment
@mark-westerhof You should now be able to disable linting for files like so.