vimpostor / vim-tpipeline

Embed your vim statusline in tmux
GNU General Public License v3.0
364 stars 10 forks source link

"Can't send data to closed stream" error when exiting neovim #56

Closed defr0std closed 1 year ago

defr0std commented 1 year ago

Describe the bug

I use lualine and tpipeline. With this setup, when exiting vim, the following error is printed in the terminal:

Error detected while processing function <lambda>4[1]..tpipeline#lualine#fix_stl[9]..tpipeline#update:
line   35:
Can't send data to closed stream%

I assume this happens because there is a timer, on which the data is sent to the channel. This channel is probably closed by the time the timer callback fires.

To reproduce

Repro is with neovim.

  1. Add the following config to /tmp/config.lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  "hoob3rt/lualine.nvim",
  "vimpostor/vim-tpipeline",
})

vim.g.tpipeline_clearstl = 1

require("lualine").setup {
  options = {
    globalstatus = true,
  },
  sections = {
    lualine_x = { "filetype" },
    lualine_z = { "location" }
  },
  winbar = {
    lualine_a = {
      { "filename" }
    },
  },
}
  1. Start neovim when the config: nvim -u /tmp/config.lua

  2. Close neovim without doing anything and observe the error printed in the terminal.

Expected behavior

Nothing printed to the terminal when closing neovim.

Terminal emulator

alacritty

Debug output

{'right': ['#[fg=,bg=]#[fg=#88c0d0,bg=terminal] #[fg=#d8dee9,bg=terminal] lua #[fg=#d8dee9,bg=terminal]  5% #[fg=,bg=terminal]   2:13 '], 'native_str': '--------------------------------------------------------
----------------------------  lua   5%    2:13 ', 'version_info': '{   api_compatible = 0,   api_level = 10,   api_prerelease = false,   major = 0,   minor = 8,   patch = 3,   prerelease = false }', 'tmux': 't
mux 3.2a', 'left': ['#[fg=,bg=]#[fg=#4c566a,bg=terminal]'], 'plugin_version': '1.0', 'native_highlights': [{'group': 'lualine_c_normal', 'start': 0}, {'group': 'lualine_x_filetype_DevIconlua_command', 'start':
84}, {'group': 'lualine_x_normal', 'start': 88}, {'group': 'lualine_y_normal', 'start': 93}, {'group': 'lualine_z_command', 'start': 98}], 'os': 'MacOS', 'brand': 'neovim'}
vimpostor commented 1 year ago

Thanks for the minimal repro config, it really makes my life easier!

The problem isn't reproducible with neovim 0.9 and only happens in neovim 0.8. I have pushed a fix.

defr0std commented 1 year ago

Thank you!