jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.06k stars 69 forks source link

support for man pages #195

Open DerekNonGeneric opened 1 year ago

DerekNonGeneric commented 1 year ago

It does not seem like there is currently support for man pages. For example, running man npm should pull up the man page for the npm command and all the other globally-installed npm packages that include man pages. It currently works for the node command, but not npm. I think that should be the responsibility of this script, but I might be wrong.

If this is something that should be set by the user in a config.fish file or Dockerfile, let me know, and we can close this. I just think it would be convenient for this script to handle that. You can check out this config.fish I wrote a really long time ago that accounted for this (used this before using nvm at all).

See: https://docs.npmjs.com/cli/v8/configuring-npm/folders#man-pages

jorgebucaran commented 1 year ago

You are right, man npm pulls up the man page for the system node, not the version managed by nvm.

Edit: Typo

DerekNonGeneric commented 1 year ago

You are right, man nom pulls up the man page for the system node, not the version managed by nvm.

You probably mean man npm, but yeah, so confirmed bug i guess -- i would like it fixed too :)

DerekNonGeneric commented 1 year ago

whereis-note

The following may be helpful in the meantime, but will let you know about any progress (can make a PR too).

jorgebucaran commented 1 year ago

I might have a potential fix for this, but I'm currently stuck because of an issue with Fish that breaks man for other commands after updating $MANPATH.

Here's the code to support man npm:

contains -- $nvm_data/$ver/lib/node_modules/npm/man $MANPATH ||
    set --global --prepend MANPATH $nvm_data/$ver/lib/node_modules/npm/man

And to remove it:

set --local man_index (contains --index -- $nvm_data/$ver/lib/node_modules/npm/man $MANPATH) &&
    set --erase MANPATH[$man_index]

Related: https://github.com/fish-shell/fish-shell/issues/2090.

faho commented 1 year ago

In short: Have a look at https://github.com/fish-shell/fish-shell/blob/a9708367db7bd15f28802c12ac947c2e354a98ea/share/functions/man.fish#L11-L29.

breaks man for other commands after updating $MANPATH

The usual case is that $MANPATH is unset, in which case man will use the system's default.

Once you set it, only that will be used.

How you get it to use your directory in addition to the system path unfortunately depends on your man implementation (man is extremely unstandardized - there are a ton of implementations, and they work differently).

Common ideas are:

This is down to man, not fish.