muru / vim-manpager

A Vim plugin to make it easier to use as $MANPAGER
GNU General Public License v3.0
3 stars 2 forks source link

Load the plugin manually? (thoughts) #1

Open miyl opened 3 years ago

miyl commented 3 years ago

Hi!

Interesting project! I tried it out and I like it, but I realized that using vim as a manpager was rather slow compared to less, so I tried disabling all plugins + not reading my vimrc at all (especially because of the lines that depend on plugins) which helped a great deal in startup speed, and it also seems to make sense, as most of my plugins are for editing.

But of course there's one issue with that: This plugin no longer loads, and so I have to add lines to create the nmap and such. Another issue with is that there are then various ugly raw ANSI escapes around in the manpages.

So I was thinking whether anyone know if it's still possibly to manually load a plugin via commands?

Because your plugin currently isn't loading I currently have this:

# Launch vim read only, don't load config or plugins, disable (most of) the statusbar, set the filetype (no effect by itself) and an nmap to quit more easily
export MANPAGER='nvim -R -u NONE +":set laststatus=0 ft=man | nmap q :q!<CR>" -'

...and I tried to add this to it to load the plugin, but unfortunately it's not enough:

rtp^=~/.config/nvim/pack/minpac/start/vim-manpager ft=man

Sourcing the ftplugin and after files seemingly don't make a difference either, or at least it doesn't reload it and display it properly.

muru commented 3 years ago

I think there are two problems with that:

Instead of -u NONE, with Vim I'd use --clean:

MANPAGER='vim -N --clean +"set rtp^=~/.vim/plugged/vim-manpager/after,~/.vim/plugged/vim-manpager ft=man | MANPAGER" --not-a-term -'

But --clean seems to be different for Vim and NeoVim:

                                                        --clean
--clean         Similar to "-u DEFAULTS -U NONE -i NONE":
                - initializations from files and environment variables is
                  skipped
                - 'runtimepath' and 'packpath' are set to exclude home
                  directory entries (does not happen with -u DEFAULTS).
                - the defaults.vim script is loaded, which implies
                  'nocompatible': use Vim defaults
                - no gvimrc script is loaded
                - no viminfo file is read or written
                Note that a following "-u" argument overrules the effect of
                "-u DEFAULTS".
                            *--clean*
--clean     Equivalent to "-u NONE -i NONE":
        - Skips initializations from files and environment variables.
        - No 'shada' file is read or written.
        - Excludes user directories from 'runtimepath'

Using an alternate vimrc file might be the least messy option. For example, with Vim I would do something like:

export MANPAGER='vim -u ~/.vim/vimrc-man --not-a-term +MANPAGER -'
" ~/.vim/vimrc-man
set nocompatible
filetype plugin on
set rtp^=~/.vim/plugged/vim-manpager/after,~/.vim/plugged/vim-manpager

That last line is pretty much what vim-plug does, I think. But this doesn't work with NeoVim either.


With a bit of trial and error, this seems to work:

MANPAGER='nvim -u NORC +"set rtp^=~/.vim/plugged/vim-manpager,~/.vim/plugged/vim-manpager/after ft=man" +MANPAGER -'
miyl commented 3 years ago

Thanks a lot for your thoughts and solutions! Been experimenting a bit since then.

With -u somevimrc or -u NORC it still loads all plugins, not just yours. With -u NONE it loads no plugins at all and I haven't succeeded in getting it to load yours specifically.

Sourcing your files seems to work okay though:

export MANPAGER='nvim -R -u NONE +":set laststatus=0 ft=man | source ~/.config/nvim/pack/minpac/start/vim-manpager/ftplugin/man.vim | source ~/.config/nvim/pack/minpac/start/vim-manpager/after/syntax/man.vim | syntax enable" -'