nvimdev / dashboard-nvim

vim dashboard
MIT License
2.3k stars 187 forks source link

ftplugin not always working #361

Open franroa opened 1 year ago

franroa commented 1 year ago

Describe the bug When I run a function on starting the dashboard, it sometimes works, but sometimes seems that nothing happened

To Reproduce create a small function which draws something in the (local) winbar

Expected behavior The winbar shows always what is written in the function

In the file, I just execute a function which adds content to the winbar: require("functions.winbar").Redraw()

glepnir commented 1 year ago

dashboard hide winbar is true will hide winbar

franroa commented 1 year ago

It is not working consistently. This is my code:

vim.api.nvim_create_autocmd({ "BufEnter" }, {
  pattern = { "" },
  callback = function()
    if vim.bo.filetype == "" or vim.bo.filetype == "dashboard" then
      require("functions.winbar").Redraw()
    end
  end
})

return {
  {
    "glepnir/dashboard-nvim",
    event = "VimEnter",
    config = function()
      require("dashboard").setup({
        hide = {
          statusline = false,
          winbar = false,
        },
        -- config
        config = {
          packages = { enable = false }, -- show how many plugins neovim loaded
          project = { enable = false },
          mru = { enable = false },
          center = {
            {},
          },
          header = header,
          footer = function()
            local stats = require("lazy").stats()
            local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
            return { "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" }
          end,
          shortcut = {
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Find Files",
              group = "Label",
              action = "Telescope find_files",
              key = "f",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "New File",
              group = "Label",
              action = [[ene | startinser]],
              key = "n",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Recent Files",
              group = "Label",
              action = "Telescope oldfiles",
              key = "r",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Find text",
              group = "Label",
              action = "Telescope live_grep",
              key = "g",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Config",
              group = "Label",
              action = ":e $MYVIMRC ",
              key = "c",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Restore Session",
              group = "Label",
              action = [[lua require("persistence").load()]],
              key = "s",
            },
            {
              icon = "󰒲 ",
              icon_hl = "@variable",
              desc = "Config",
              group = "Label",
              action = [[Lazy]],
              key = "l",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Quit",
              group = "Label",
              action = [[qa]],
              key = "q",
            },
            {
              icon = " ",
              icon_hl = "@variable",
              desc = "Projects",
              group = "Label",
              action = "Telescope projects",
              key = "p",
            },
            {
              desc = " Apps",
              group = "DiagnosticHint",
              action = "Telescope app",
              key = "a",
            },
            {
              desc = " dotfiles",
              group = "Number",
              action = "Telescope dotfiles",
              key = "d",
            },
          },
        },
      })
    end,
    dependencies = { { "nvim-tree/nvim-web-devicons" } },
  },
}
glepnir commented 1 year ago

okay . I am writing a new version dashboard. let's see what happen in new version later