Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the plugin manually? (thoughts) #1

Open
miyl opened this issue Mar 14, 2021 · 2 comments
Open

Load the plugin manually? (thoughts) #1

miyl opened this issue Mar 14, 2021 · 2 comments

Comments

@miyl
Copy link

miyl commented Mar 14, 2021

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
Copy link
Owner

muru commented Mar 15, 2021

I think there are two problems with that:

  • IIRC + commands are run after all initialization is done and the file is completely read. So the autocmd that handles the formatting (which runs on StdinReadPost) won't be triggered - it's set after that event fires.
  • -u NONE means that Vim isn't going to read anything in rtp (and I'd guess the same applies to NeoVim too), so the plugin files aren't loaded at all.

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
Copy link
Author

miyl commented Mar 21, 2021

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" -'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants