nvimdev / dashboard-nvim

vim dashboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Piped standard output to neovim shows the dashboard instead of the buffer with stdout content

zaerald opened this issue · comments

Describe the bug
Whenever stdout is piped to neovim, it shows the dashboard instead of the buffer that contains the piped stdout.

This was not an issue in 63df284.

To Reproduce
Steps to reproduce the behavior:

  1. Run echo "hello" | nvim
  2. It shows the dashboard instead of the piped stdout

Expected behavior
The piped stdout should be written to the buffer.

Screenshots

Before (63df284):

dashboard-before

After (39f308a):

dashbaord-after

As a workaround until this is fixed, if you use Telescope, do <leader><leader> and then open the Untitled buffer :)

a little bit annoying: temporary reverted to c71cab740e2a

I had the same issue, I worked around it by doing this

-- Create a group and autocommand to prevent dashboard from starting when stdin is passed
vim.api.nvim_create_augroup("dashboard_stdin", { clear = true })
vim.api.nvim_create_autocmd({ "StdinReadPre" }, {
  group = "dashboard_stdin",
  callback = function()
    vim.g.loaded_dashboard = 1
  end,
})

might be someone knows a better way?

@infinite-ops Your idea is great. However, this makes Dashboard function not being loaded, as the code will return here:

if vim.g.loaded_dashboard then
return
end

So we couldn't open Dashboard anytime after we opened a file from stdin.

I have made a commit inspired from #443 (comment) in my fork: mangkoran@74c80ec

wezterm-gui_LTcGnjUAdW

The only caveat is that we need to not lazy-load the plugin (e.g. if you use LazyVim)

return {
  {
    "nvimdev/dashboard-nvim",
    url = "https://github.com/mangkoran/dashboard-nvim",
    lazy = false,
    priority = 1000,
  },
}

Please give it a try!

Thanks! Tried your feature and it doesn't work with my config as below, but if I change to as you say lazy = false then it does indeed work. Plus Dashboard works too when its the stdin content and then you call it, I hadnt noticed it didnt work as I dont use that feature!

  {
    "nvimdev/dashboard-nvim",
      event = "VimEnter",
      config = function()
      require "plugins._dashboard"
    end,
    dependencies = { { "nvim-tree/nvim-web-devicons" } },
  },

nice one @mangkoran !

Thanks! Tried your feature and it doesn't work with my config as below, but if I change to as you say lazy = false then it does indeed work.

Yeah this is due to StdinReadPre event is triggered before VimEnter. So if dashboard-nvim is lazy-loaded on VimEnter event as LazyVim current config, the StdinReadPre autocmd will never called.

ahh. Thanks for the explanation :)