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

enhancement: Take over all stdout's of neovim by default? #5

Closed
glyh opened this issue Aug 6, 2021 · 12 comments
Closed

enhancement: Take over all stdout's of neovim by default? #5

glyh opened this issue Aug 6, 2021 · 12 comments
Labels
blocked Upstream change is required
Projects

Comments

@glyh
Copy link

glyh commented Aug 6, 2021

I really like this plugin, and I don't like vim's default outputline(i.e. at the bottom).
So is there a way that we can take over all stdouts?

@rcarriga
Copy link
Owner

rcarriga commented Aug 6, 2021

Glad you're enjoying the plugin! I don't think this would be possible right now as that'd require overriding the echo/echom commands (possibly others) which AFAIK is not possible right now as they are implemented in C. You could ask on the NeoVim repo if it would be possible but I'd imagine there would be a tonne of complexity behind a change like that.

@teto
Copy link

teto commented Aug 6, 2021

:messages is really bad, there has been some attempts neovim/neovim#6374 to improve it bot nothing concrete yet. vim.notify is a way to bypass that but eventually we'll improve :messages. For now it's not possible to do what you ask.

@zeertzjq
Copy link

zeertzjq commented Nov 23, 2021

Possible solutions in Nvim: neovim/neovim#16396, neovim/neovim#16480.

@glyh
Copy link
Author

glyh commented Aug 31, 2022

neovim/neovim#16396 is merged, we may consider add some options for it later.

@rcarriga
Copy link
Owner

rcarriga commented Sep 6, 2022

I don't think it can be used just yet, it seems the dependency on ext_cmdline causes some issues. I'm testing with

vim.ui_attach(
  vim.api.nvim_create_namespace("redirect messages"),
  { ext_messages = true },
  function(event, ...)
    if event == "msg_show" then
      local level = vim.log.levels.INFO
      local kind, content = ...
      if string.find(kind, "err") then
        level = vim.log.levels.ERROR
      end
      vim.notify(content, level, { title = "Message" })
    end
  end
)

@folke
Copy link
Contributor

folke commented Sep 30, 2022

I just silently (for now) released a new plugin that does this and a lot more. See https://github.com/folke/noice.nvim

Feel free to test it out and give some feedback :)

@folke
Copy link
Contributor

folke commented Sep 30, 2022

@rcarriga during blocking events, we sometimes need to render the messages without any delays.

When that's the case, I use a separate notify instance with stages=static, but that is not enough to make it work in realtime.

I'm currently patching NoifyService.push in https://github.com/folke/noice.nvim/blob/79f1ac9c524d14d5497065533ac9faa6ab38fe6e/lua/noice/hacks.lua#L144

  • make animator process anything in the queue on NotifyService.push
  • re-render the buffer -> this seems to be needed as well. Not 100% sure why. Possibly, because there's no visible buffer right before queing it in the animator?

Would be good to have this fixed within Notify itself, but I'm not sure what you think a proper fix would be?

@rcarriga
Copy link
Owner

Looks very cool, I'll have a go over the weekend!

Sorry if it's obvious but why do messages need to be rendered immediately during blocking events?

@folke
Copy link
Contributor

folke commented Sep 30, 2022

for example when rendering the cmdline. But also in situations where a plugin echos a message and then waits for input. Or uses confirm, inputlist, ... Or when you open a file that is already opened in another instance of Neovim. Custom operator pending modes.

In all those cases, we need to render what's still in the Noice message queue and do redraw if the state after processing the messages was updated.

Lots of cases basically :)

@folke
Copy link
Contributor

folke commented Sep 30, 2022

To clarify, just do something like:

vim.notify("Enter a character?")
vim.fn.getchar()

You won't see the message till after you entered a key. In this case, you want the initial message to be displayed instantly and prior to the blocking input.

Noice takes care of these kinds of situations automatically.

rcarriga added a commit that referenced this issue Oct 1, 2022
@rcarriga
Copy link
Owner

rcarriga commented Oct 1, 2022

Ah thanks for explaining that makes complete sense! I think your solution is pretty much the right way to do it, I've added a forced render on creation and also the redraw.

Also cool to see the instances being used 😁

@rcarriga
Copy link
Owner

Closing this as there is too much complexity involved for this plugin and noice.nvim handles it well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Upstream change is required
Projects
No open projects
Development

No branches or pull requests

5 participants