lucc / nvimpager

Use nvim as a pager to view manpages, diffs, etc with nvim's syntax highlighting
Other
372 stars 20 forks source link

Don't load pack at startup fix #40 #41

Closed JingMatrix closed 3 years ago

JingMatrix commented 3 years ago

For nvim 0.4.4, rtp is set by file /usr/share/nvim/runtime/plugin/matchit.vim, which will add nvim default rtp as it use packadd,

" Nvim: load the matchit plugin by default.
if stridx(&packpath, $VIMRUNTIME) >= 0
  packadd matchit
endif

To disable this feature, we should set packpath to empty. This workaround won't affect nvimpager's default rtp value.

lucc commented 3 years ago

Is your problem specifically the matchit plugin or other plugins in the user specific folders of packpath? I would like to avoid removing all folders from packpath because we don't know what other users might expect.

So maybe we can think about the question what a sensible setting for pp is. The docs say the default is the same as for rtp so I tried to code a solution in the fix/40 branch. Can you try that and tell my what you think?

Also if we do not use the fix/40 branch but this PR I would ask you to change it a little and move the setting to the lua function stage1 because I try to keep the bash code as minimal as possible and do everything in lua.

JingMatrix commented 3 years ago

You fix works, thanks for your help.

I don't lua well so I cannot be very helpful. For now, it works as expected.

lucc commented 3 years ago

@JingMatrix Can you show me the values of pp and rtp before and after 4b180e6 so that I can better understand where the difference is in your setup?

lucc commented 3 years ago

And maybe I should improve the docs on this. Was the README or the man page any help when you encountered this or how could the text there be improved?

JingMatrix commented 3 years ago

The problem is not your code. I think it could be the behaviour of nvim changed for 0.4.4.

After your commit, rtp and pp have values you claimed in your project.

Before your commit, since nvim choose to load matchit plugin by default ( I didn't change any config about it), which called packadd command. This behaviour is out of exception of your original code, and it happens if pp is the default one, see the code at the first comment. packadd definitely modifies the value of rtp, which adds default value of rtp, i.e., value of pp to what you expected.

Hence, the solution should be changing pp value in your plugin, and your commit did it well.

I hope this comment helps you understand my explanation of why your plugin failed yesterday.

ps: when I used your code yesterday, I was zero-config, just downloaded and installed it.

lucc commented 3 years ago

Thanks @JingMatrix I understand the background a little better now.