Closed eugene-babichenko closed 1 year ago
Ok lets try to get clear what you want here but first some assumptions that I have coded into nvimpager:
I will try to summarise your idea to make sure I get it right (please correct me):
So what is the thing you want to have in technical terms. I want to write down kind of an algorithm or the requirements of sort. Please correct me if I am mislead:
:echo l:data
because that would echo in the command line of the parent process, so I assume it has to retrieve the data and echo
(not :echo
!) it itself.If my above assumptions are correct there would be two steps that would be neccessary:
io.write
in lua)man man
inside a terminal in nvim when export PAGER=nvimpager
is set)did you try to use your default nvim config for nvimpager? That should select your colorscheme etc
It is quite heavy. For example, it automatically starts a language server if available for the current file format.
or is it important to you to not start extra processes for fzf highlighting?
Not really. The idea is to just reuse what is already running given that the config is quite heavy and not everybody want to maintain two separate configurations.
I have never worked with the neovim socket interface but I assume here that the nvim-cat process can not tell the parent nvim process to :echo l:data because that would echo in the command line of the parent process, so I assume it has to retrieve the data and echo (not :echo!) it itself.
Yes, this is the exact problem. We would need a function to return a string/byte array.
eg. running
man man
inside a terminal in nvim whenexport PAGER=nvimpager
is set
I only care about the cat
mode actually.
I think I will follow your advice and start with making nvimpager
being usable as a Vim plugin with a function that outputs the highlighted code. When this is done, the RPC program is trivial.
did you try to use your default nvim config for nvimpager? That should select your colorscheme etc
It is quite heavy. For example, it automatically starts a language server if available for the current file format.
or is it important to you to not start extra processes for fzf highlighting?
Not really. The idea is to just reuse what is already running given that the config is quite heavy and not everybody want to maintain two separate configurations.
Alternative solution for your special use case: You could modularize your init.vim file and put the stuff for colors in a file that you can :source
from the default nvim and the nvimpager init files.
Yes, this is the exact problem. We would need a function to return a string/byte array.
If you want to try that have a look at the highlight
function in nvimpager.lua. The outer for loop builds the outline
variable. Maybe it is easy to refactor the code into a highlight_line
function that returns the outline. This could then be reused be the current (maybe renamed to highlight_write
) function and your new highlight_return
function.
eg. running
man man
inside a terminal in nvim whenexport PAGER=nvimpager
is setI only care about the
cat
mode actually.
What I meant here is that if we change the default behaviour of nvimpager we have to think a little deeper then "I care about this" because I do not want nnvimpager to be a program that acumulates random features. It is foremost a pager.
I just had a look at the docs and it seems that you can use a new nvim instance as a n rpc client to send commands to the nvim process behind $NVIM_LISTEN_ADDRESS. Check the help for sockconnect() and rpcrequest().
I will close this because I do not consider it important enough to track it. If somebody is interested in implementing it they can start a new discussion about some more concrete aspect.
The application of this would be to make syntax highlighting in https://github.com/junegunn/fzf.vim preview window look exactly the same (or, at least, as close as possible) as in
nvim
.By default
nvim
exposes an RPC socket which is available to subprocesses via$NVIM_LISTEN_ADDRESS
. This API could be used for running Lua scripts as well, sonvimpager
would require very little modification for that.What would be a good approach to implement that? This would be hard to do in
bash
because of RPC message format. There are client libraries for multiple languages, but the Lua library is not well documented, so I am leaning towards Python.