lucc / nvimpager

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

Is it possible to use pure lua to refactor this project? #94

Open Freed-Wu opened 5 months ago

Freed-Wu commented 5 months ago

neovim have a lua interpreter. If this project can use it to reduce dependency of bash, it will be better?

nvimpager:

#!/usr/bin/env -S nvim -u NONE -l
-- ...
lucc commented 5 months ago

It is possible to do that but you have to reimplement the command line parsing and some other details that bash offers.

In my opinion that is more work than it is worth. I assume that most systems already have bash installed for some other reason (so I do not consider it a "big" dependency; on my NixOS system for example the full dependency tree of bash is 34MB and the full dependency tree of neovim is 91MB and also includes bash)

Is there any problem with bash as a dependency?

Freed-Wu commented 5 months ago

Not all OSs preinstalled bash. Some BSDs installed other shells like ksh as their shell, Some OSs like win even don't have bash. However, in any situation, neovim's lua is accessible.

reimplement the command line parsing

It shouldn't be very complex, just parse vim.v.argv is OK.

some other details that bash offers

Do you mean [ -t tty ]?

lucc commented 5 months ago

I meant redirection and environment exports which are more involved with vim functions than with bash. test -t might be doable in nvim with has('ttyin') and has('ttyout').

If some system does not preinstall bash that is not a problem in my opinion. I suspect most systems do not preinstall neovim either. If a system does not provide bash then you have a point: currently nvimpager is not usable on that system.

Although you Windows is not a priority for me and you can certainly install bash on windows here are some other things that you have to check if and how they can be achieved in lua or on windows:

I am not motivated to port the bash script to lua but you can try.