Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

FR: Using tmux as an alternative to nvim-terminal #1

Open
marcelarie opened this issue Aug 3, 2023 · 6 comments
Open

FR: Using tmux as an alternative to nvim-terminal #1

marcelarie opened this issue Aug 3, 2023 · 6 comments

Comments

@marcelarie
Copy link

Right now I don't have the time to check how this could be implemented, but it would be nice that the plugin detects if nvim is running in a tmux session and uses a tmux window command to open the glow previewer.

Or maybe a simpler version would be a config parameter that when activated uses tmux instead of nvim-terminal.

What do you think?

@mrjones2014
Copy link
Owner

Sounds like a cool feature, but I have a lot of cleanup to do before it will be feasible. I just pulled this out of my dotfiles and the code is a bit of a mess at the moment.

@mrjones2014
Copy link
Owner

Renamed the plugin in case you get confused 😉

@mrjones2014
Copy link
Owner

The plugin should be in a decent place to support alternative preview/rendering mechanisms now if you'd like to try to make a PR.

@marcelarie
Copy link
Author

I will try to do something then, thanks!

@mrjones2014
Copy link
Owner

A little context I've been thinking about that might help you.

The way that the plugin works currently with the buffer preview window in nvim is via a { 'TextChanged', 'TextChangedI' } autocmd, where the autocmd callback:

  • Grabs all lines from the source buffer
  • Starts the CLI job with the cli_args config option
  • Sends the lines from step 1 to STDIN of the CLI job
  • Updates the preview buffer lines with the STDOUT of the CLI job
  • Sets the preview buffer filetype to terminal so that the nvim-terminal.lua plugin can render the ASCII color/style escape codes

I'm not sure what the approach would be for using tmux for the preview window. One option would be to give the CLI the filepath instead of the lines via STDIN, but then you won't get live-updating unless you kill and restart the CLI process in the tmux pane each time. This is the part that's tough to solve -- the live updating part -- in a tmux preview window.

Does tmux have a way to just render arbitrary text in a pane? If that is somehow possible, we could use the existing rendering mechanism and just give tmux the STDOUT lines to render.

I haven't used tmux in a while personally (I use Wezterm's mux now) but I'm happy to help out where I can.

@marcelarie
Copy link
Author

Thanks! Lets see when I find some time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants