How to disable ale plugin by default in Vim?
Asked Answered
C

2

11

I'm using https://github.com/w0rp/ale plugin. But it makes vim less responsive... I have a bind for ALETooggle on <leader>l.

It would be nice to have it disabled by default and enable by keyboard shortcut when wanted, I tried to put ALEDisable on my .vimrc but it gives me the error below

Error detected while processing /Users/daniel/.vimrc:
line   94:
E492: Not an editor command: ALEDisable   
Press ENTER or type command to continue

Here is a sample .vimrc that would trigger the problem

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
Plugin 'w0rp/ale'
call vundle#end()            " required
filetype plugin indent on    " required

noremap <leader>l :ALEToggle<CR>
ALEDisable
Ceraceous answered 9/1, 2019 at 21:10 Comment(3)
Have you looked at vim's native package manager (e.g. :help pack-add) and considered placing this in the opt folder? Seems like that would work well. Certainly you could create a bind to perform a :packadd alePseudohermaphroditism
I'm using Vundle for managing plugins, does the package manager changes anything about getting ALEDisable to work at .vimrc?Ceraceous
@Ceraceous ALEDisable fails because plugins are loaded after vimrc.Gilford
U
2

The most elegant solution is to use a better plugin manager like Plug or Dein. Why? Because they're well maintained and much more faster and efficient than the current plugin manager you use. And most importantly they support lazy loading of plugins with ease.

For your purpose of loading the plugin on map, you can do either of these :

Plug 'w0rp/ale', { 'on':  'ALEToggle' }  

or

call dein#add('w0rp/ale',{'on_cmd': 'ALEToggle'})  

the same lazy loading maybe possible with vundle too i guess, but believe me, it's worth using either vim-plug or dein, cause they're super fast and intuitive.

Ultun answered 10/1, 2019 at 2:3 Comment(1)
Thanks! I didn't know that vundle was slow,Ceraceous
S
19

The ALE plugin provides an option named g:ale_enabled to disable ALE by default, so this way is plugin manager agnostic.

If you set g:ale_enabled to 0 then ALE is disabled for any buffer. Also the plugin provides an option to control ALE availability based on file name. Here is an example found with :h g:ale_enabled:

" Disable linting for all minified JS files.
let g:ale_pattern_options = {'\.min.js$': {'ale_enabled': 0}}

You can enable ALE using :ALEEnable or :ALEToggle when you want to enable it.

Sullyprudhomme answered 23/1, 2019 at 2:15 Comment(2)
This is very useful. I'm using vim-plug right now and is being very pleasant since it make my vi sessions much lighter.Ceraceous
:ALEToggle (Capital T) -- unable to edit because edits must be 6+ chars :)Cleisthenes
U
2

The most elegant solution is to use a better plugin manager like Plug or Dein. Why? Because they're well maintained and much more faster and efficient than the current plugin manager you use. And most importantly they support lazy loading of plugins with ease.

For your purpose of loading the plugin on map, you can do either of these :

Plug 'w0rp/ale', { 'on':  'ALEToggle' }  

or

call dein#add('w0rp/ale',{'on_cmd': 'ALEToggle'})  

the same lazy loading maybe possible with vundle too i guess, but believe me, it's worth using either vim-plug or dein, cause they're super fast and intuitive.

Ultun answered 10/1, 2019 at 2:3 Comment(1)
Thanks! I didn't know that vundle was slow,Ceraceous

© 2022 - 2024 — McMap. All rights reserved.