首页 > 解决方案 > 如何在 Vim 中默认禁用 ale 插件?

问题描述

我正在使用https://github.com/w0rp/ale插件。但这会使 vim 的响应速度降低...我有一个绑定ALETooggleon <leader>l

最好默认禁用它并在需要时通过键盘快捷键启用它,我试图戴上ALEDisable我的.vimrc但它给了我下面的错误

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

.vimrc这是一个会触发问题的示例

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

标签: vimvim-plugin

解决方案


ALE 插件提供了一个名为g:ale_enabled默认禁用 ALE 的选项,因此这种方式与插件管理器无关。

如果您设置g:ale_enabled为,0则 ALE 对任何缓冲区都禁用。该插件还提供了一个基于文件名控制 ALE 可用性的选项。这是一个示例:h g:ale_enabled

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

:ALEEnable您可以使用或:ALEToggle在您想要启用 ALE时启用它。


推荐阅读