willothy / flatten.nvim

Open files and command output from wezterm, kitty, and neovim terminals in your current neovim instance
https://luarocks.org/modules/willothy/flatten.nvim
MIT License
473 stars 13 forks source link

Customizable host address detection #49

Closed IndianBoy42 closed 1 year ago

IndianBoy42 commented 1 year ago

Is your feature request related to a problem? Please describe. I don't use :terminal I prefer to use kitty splits/tabs with my own plugin for sending text/running commands. I'd still like to be able to open files in the singular neovim instance. The thing is because its not actually a nested terminal I don't get the $NVIM variable in the other splits, there is a way using kitty @ ls to find all the other kitty windows and find which one has nvim running. I just need to tell flatten.nvim that

Describe the solution you'd like Add a configuration option that allows the user to pass a callback that determines the pipe address that guest nvims should use to communicate with the host. The default implementation would just return vim.env.NVIM but users could use kitty (or wezterm, or tmux or whatever else) to find and return the correct servername/pipe address

Describe alternatives you've considered The alternatives are something in the shell that sets $NVIM, this is possible but parsing json in shell scrip is annoying. Or figuring out somehow that the host nvim injects environment variables into all other windows (I don't think this is possible in an elegant way)

willothy commented 1 year ago

I use wezterm the same way, so that's a great idea.

willothy commented 1 year ago

Thinking about this now that I have some free time, and I think the best way to do this would be to allow the user to set a specific host address in the config, then creates a new server instead of using the one started by Neovim. Since the config is loaded by both host and guest, they can easily share the pipe address. What do you think about that?

IndianBoy42 commented 1 year ago

I think that's a good choice, as it's basically the most flexible base API. Users could do whatever they want to find the host address (env variable, config files in project, etc). I would probably also provide a utils.lua or just recipes in the wiki for common scenarios (like to share the neovim instance across kitty or wezterm windows)