Skip to content

Support Neovim's UI2#259

Open
rgertenbach wants to merge 1 commit into
google:masterfrom
rgertenbach:ui2
Open

Support Neovim's UI2#259
rgertenbach wants to merge 1 commit into
google:masterfrom
rgertenbach:ui2

Conversation

@rgertenbach

Copy link
Copy Markdown

Neovim's UI2 does not prepend a newline to commands' output. This causes the assertion to fail.

This commit adds a check whether we are running nvim and if yes, whether we have configures UI2 and returns the entire output in that situation.

return l:output
else
" Neovim's UI2 handles captured output differently.
if has('nvim') && luaeval('pcall(require, "vim._core.ui2") and (require("vim._core.ui2").cfg ~= nil) and true or false')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty fragile as a check.

But isn't this just a (compatibility) bug in Neovim that should be fixed in ui2?

While the existing behavior of redir (adding an initial newline to the output) is strange, it seems like Neovim currently does implement the same behavior as Vim, and ui2 should presumably do the same?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick reply!

UI2 allows you to enter and navigate command output as a buffer; the change in behavior is probably because of that.
I kept getting errors from the assertion below, because UI2 seems to prune these on purpose (neovim/neovim#37697)

It's hardly ideal as a check but there isn't really any other way to check that UI2 is enabled right now AFAICT.

Happy to let it sit for now revisit this once UI2 is rolled out as a production feature. If the behavior is backwards compatible again I can drop the PR, otherwise there is hopefully a more robust way to check which behavior to expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants