rkitover / vimpager

Use Vim as PAGER
http://www.vim.org/scripts/script.php?script_id=1723
Other
769 stars 72 forks source link

[Question] How to disable particular plugins in the PAGER mode #245

Closed XVilka closed 4 years ago

XVilka commented 4 years ago

I use both Ale and VIM pager plugins. 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. Some people suggest to use separate file for pager ~/.vimpagerrc, but I don't want to copy part of ~/.vimrc in it for obvious de-syncronisation issues. So I want to share the same configuration for both modes, just disable some plugins - in this case it is Ale.

Asked also on StackExchange but haven't got any useful answer https://vi.stackexchange.com/questions/20708/how-to-disable-ale-if-pager-mode-is-enabled

Even if I put Plug declaration under this condition, it will still load the Ale in the pager mode:

if !exists('g:vimpager.enabled')
    Plug 'dense-analysis/ale'
endif

See also https://github.com/dense-analysis/ale/issues/2714

rkitover commented 4 years ago

I tried this it works for me:

call plug#begin()

if !exists('g:vimpager.enabled')
        Plug 'dense-analysis/ale'
endif

call plug#end()

Can you put your whole .vimrc in a gist please?

XVilka commented 4 years ago

@rkitover here you go: https://gist.github.com/XVilka/995951e3f2ee6e991b900675d9d59696

rkitover commented 4 years ago

I figured out the problem, my documentation is wrong and I will fix it shortly.

Where you have the line:

let g:vimpager = {}

change it to:

if !exists('g:vimpager')
    let g:vimpager = {}
endif

Then when loading the ale plugin, use the above code:

if !exists('g:vimpager.enabled')
    Plug 'dense-analysis/ale'
endif