Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detach the current TUI (nvim continues headlessly) #23093

Open
eloytoro opened this issue Apr 14, 2023 · 5 comments
Open

detach the current TUI (nvim continues headlessly) #23093

eloytoro opened this issue Apr 14, 2023 · 5 comments
Labels
enhancement feature request remote remote UI, --remote commands, p2p / peer-to-peer server tui
Milestone

Comments

@eloytoro
Copy link

Problem

When connected to a remote ui executing :q will close the remote server, I guess this makes sense in the way that the command is being run by the backend and not the UI, but it's not intuitive or desired, I wish to quit without killing the backend

Steps to reproduce

nvim --listen 127.0.0.1:8888 --headless
nvim --server 127.0.0.1:8888 --remote-ui
:q

Expected behavior

The UI should disconnect from the server but not to kill it

Neovim version (nvim -v)

0.10.x

Vim (not Nvim) behaves the same?

no

Operating system/version

macOS 13.2.1

Terminal name/version

iTerm

$TERM environment variable

xterm-256color

Installation

homebrew

@eloytoro eloytoro added the bug issues reporting wrong behavior label Apr 14, 2023
@zeertzjq
Copy link
Member

I don't think this should be changed.

@zeertzjq zeertzjq closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2023
@zeertzjq zeertzjq added closed:wontfix current behavior is by design, and change is not desired and removed bug issues reporting wrong behavior labels Apr 14, 2023
@erw7
Copy link
Contributor

erw7 commented Apr 15, 2023

I don't think this should be changed.

I don't think we should try to detach the tui with :q, but a way to detach the current tui should be implemented.

Even now, it is possible to terminate only tui by using call chanclose(id) with the channel id obtained by echo nvim_list_uis() as an argument. However, it is not easy to use because users need to remember the correspondence between tui and channel id.

To begin with, #18375 has the following disadvantages,

  • Increased memory usage
  • Startup time is increased by the amount of child processes that need to be forked
  • Lots of bugs ;-<

so it is unlikely to be beneficial to users unless it is used as follows

nohup nvim --listen /tmp/nvim.pipe --headless > /dev/null 2>&1 0< /dev/null &!
nvim --server /tmp/nvim.pipe --remote-ui

In that case, we would love to have this feature.

@erw7 erw7 added enhancement feature request and removed closed:wontfix current behavior is by design, and change is not desired labels Apr 15, 2023
@erw7 erw7 changed the title Quitting a remote-ui closes the server Implement a method to detach the current tui Apr 15, 2023
@erw7 erw7 reopened this Apr 15, 2023
@zeertzjq zeertzjq added the tui label Apr 15, 2023
@justinmk justinmk added remote remote UI, --remote commands, p2p / peer-to-peer server labels Jul 7, 2023
@justinmk justinmk changed the title Implement a method to detach the current tui detach the current TUI (nvim continues headlessly) Jul 16, 2023
@mikesmithgh
Copy link
Sponsor Contributor

I don't think this should be changed.

I don't think we should try to detach the tui with :q, but a way to detach the current tui should be implemented.

Even now, it is possible to terminate only tui by using call chanclose(id) with the channel id obtained by echo nvim_list_uis() as an argument. However, it is not easy to use because users need to remember the correspondence between tui and channel id.

To begin with, #18375 has the following disadvantages,

  • Increased memory usage
  • Startup time is increased by the amount of child processes that need to be forked
  • Lots of bugs ;-<

so it is unlikely to be beneficial to users unless it is used as follows

nohup nvim --listen /tmp/nvim.pipe --headless > /dev/null 2>&1 0< /dev/null &!
nvim --server /tmp/nvim.pipe --remote-ui

In that case, we would love to have this feature.

Thanks for the info. I came up with a function to disconnect all remote-ui sessions:

  vim.keymap.set('n', '<leader>q', function()
    for _, ui in pairs(vim.api.nvim_list_uis()) do
      if ui.chan and not ui.stdout_tty then
        vim.fn.chanclose(ui.chan)
      end
    end
  end, { noremap = true })

This is working for my use case, but I am not 100% sure that ui.stdout_tty is the correct condition to check. But, if I use your nohup commands in combination with this I can have a long living neovim session. Hopefully this helps someone 🙂

@zeertzjq zeertzjq added this to the backlog milestone Jul 28, 2023
@cosminadrianpopescu

This comment was marked as off-topic.

@justinmk
Copy link
Member

justinmk commented Oct 4, 2023

if the nvim_list_uis() returns more than one ui, how would I know which channel to close?

:help nvim_set_client_info()

@neovim neovim deleted a comment from borring Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request remote remote UI, --remote commands, p2p / peer-to-peer server tui
Projects
None yet
Development

No branches or pull requests

6 participants