Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable ale plugin by default in Vim?

Tags:

vim

vim-plugin

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
like image 818
geckos Avatar asked Jan 09 '19 21:01

geckos


People also ask

How do you stop ale?

A: The best way I know of to stop an ale fermentation is to crash cool the beer; that is, chill it to 32 °F (0 °C) as quickly as possible. This method will stop most ale yeast in their tracks, and it usually works on lager yeast too, if you do it quickly enough.

What is ale vim?

ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim 0.2. 0+ and Vim 8 while you edit your text files. ALE makes use of NeoVim and Vim 8 job control functions and timers to run linters on the contents of text buffers and return errors as text is changed in Vim.


2 Answers

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.

like image 131
Tacahiroy Avatar answered Sep 21 '22 06:09

Tacahiroy


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.

like image 42
Yedhin Avatar answered Sep 20 '22 06:09

Yedhin