lucc / nvimpager

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

Support communication with parent nvim if run in :terminal #73

Open lucc opened 1 year ago

lucc commented 1 year ago

It should be possible to communicate with a parent nvim instance via the $NVIM socket if nvimpager is run in a :terminal.

Something like

[[ -S $NVIM ]] && [[ -r $NVIM ]] && [[ -w $NVIM ]]
nvim --clean --headless -u NONE \
  --cmd 'let id=sockconnect("pipe", $NVIM, {"rpc":1})' \
  --cmd 'echo rpcrequest(id, "nvim_command", "echo 1")' \
  --cmd 'qa!'

can be used to send requests to the parent nvim.

Now the nvimpager code needs to be modularised in such a way that the functionality can be loaded into a running nvim without disturbing the editor. This probably means refactor cat mode and ansi-esc mode work like any normal plugin. The old AnsiEsc plugin from Dr Chip and :TOHtml can serve as examples here.