3

I use both Ale and VIM pager plugins. But for obvious reasons I want to disable some Vim features and plugins in the "less" mode.

But if I put as recommended this piece of code in my .vimrc it still starts Ale:

if exists('g:vimpager.enabled')
   set nospell
   let g:ale_enabled = 0
endif

And if I start vimpager with vimpager some_file.py it will still show Ale error and warning messages

5
  • It works for me, your snippet disable ALE correctly. Does the set nospell part works? Maybe it is not executed in the right order in your config. To make sure, it should be placed in a file in the .vim/after/ directory, e.g. inside .vim/after/plugin/vimpager.vim or also maybe in .vimpagerrc.
    – perelo
    Commented Jul 23, 2019 at 11:07
  • @perelo no, set nospell doesn't work either. I added it here as an additional check if it is called. Commented Jul 23, 2019 at 11:11
  • I believe this happens to early. When your vimrc file is loaded, your plugins are not loaded so g:vimpager.enabled isn't set yet. You can try wrapping this into a VimEnter autocommand, but you most likely need an explicit command to disable Ale, since it will be already loaded at this time. Commented Jul 23, 2019 at 14:11
  • 1
    Have you tried using let g:ale_enabled = 0 in ~/.vimpagerrc or ~/.vim/vimpagerrc instead?
    – filbranden
    Commented Jul 23, 2019 at 14:40
  • @filbranden If I put it in ~/.vimpagerrc it will not load the rest of the options that are set in ~/.vimrc. These are mutually exclusive for vimpager it seems. Commented Jul 26, 2019 at 4:58

2 Answers 2

0

To quote the docs:

To disable loading plugins, put "set noloadplugins" into a vimpagerrc file.

Vimpagerrc can be ~/.vimpagerrc or (recommended for version control) ~/.vim/vimpagerrc or in the file named by the value of the environment variable VIMPAGER_RC

You could also try putting

let g:ale_enabled = 0

in the vimpagerrc as filbranden suggests.

2
  • I don't want to disable all plugins - some of them are quite useful. Just limit some particular ones. Commented Jul 23, 2019 at 13:44
  • If I put it in ~/.vimpagerrc it will not load the rest of the options that are set in ~/.vimrc. These are mutually exclusive for vimpager it seems. Commented Jul 24, 2019 at 9:54
0

The answer was in the vimpager initialization. Before it was stated that initialization of the plugin should be done by adding these lines in the .vimrc:

let g:vimpager = {}
let g:less = {}
let g:vimpager.passthrough = 0

But and the check for the g:vimpager.enabled occured later in the VIMRC file. Obviously the value of g:vimpager was reset by this point, rendering the check useless. So the right way would be to write :

if !exists('g:vimpager')
    let g:vimpager = {}
endif
if !exists('g:less')
    let g:less = {}
endif
let g:vimpager.passthrough = 0
...
if !exists('g:vimpager.enabled')
    Plug 'dense-analysis/ale'
endif

Note the disabling the inclusion of the Ale plugin completely - it speeds up the loading considerably, compared to just setting let g:ale_enabled = 0. The documentation for vimpager plugin was fixed in e887ecc commit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.