summaryrefslogtreecommitdiff
path: root/ar/.config/LazyVim/lua/plugins/dashboard-nvim.lua
blob: 8a1ffd6b78f20cb2d6ad850dded4fd2fd3a73c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local Util = require("lazyvim.util")
return {
  "nvimdev/dashboard-nvim",
  opts = function(_, opts)
    local logo = [[
    ┌──────────────────────────────────────────────────────┐    
    │                                                      │    
    │  ███╗   ██╗███████╗ ██████╗ ██╗   ██╗██╗███╗   ███╗  │    
    │  ████╗  ██║██╔════╝██╔═══██╗██║   ██║██║████╗ ████║  │    
    │  ██╔██╗ ██║█████╗  ██║   ██║██║   ██║██║██╔████╔██║  │    
    │  ██║╚██╗██║██╔══╝  ██║   ██║╚██╗ ██╔╝██║██║╚██╔╝██║  │    
    │  ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║  │    
    │  ╚═╝  ╚═══╝╚══════╝ ╚═════╝   ╚═══╝  ╚═╝╚═╝     ╚═╝  │    
    └──────────────────────────────────────────────────────┘    
    ]]

    logo = string.rep("\n", 5) .. logo .. "\n"

    local opts = {
      theme = "doom",
      hide = {
        -- this is taken care of by lualine
        -- enabling this messes up the actual laststatus setting after loading a file
        statusline = false,
      },

      config = {
        header = vim.split(logo, "\n"),
        -- stylua: ignore
        center = {
          { action = "ene | startinsert",                                        desc = " New file",        icon = " ", key = "n" },
          { action = "Telescope oldfiles",                                       desc = " Recent files",    icon = " ", key = "r" },
          { action = "Telescope projects",                                       desc = " Projects",        icon = " ", key = "p" },
          { action = Util.telescope("files"),                                    desc = " Find file",       icon = " ", key = "f" },
          { action = "Telescope live_grep",                                      desc = " Find word",       icon = " ", key = "g" },
          { action = [[lua require("lazyvim.util").telescope.config_files()()]], desc = " Config",          icon = " ", key = "c" },
          { action = 'lua require("persistence").load()',                        desc = " Restore Session", icon = " ", key = "s" },
          { action = "LazyExtras",                                               desc = " Lazy Extras",     icon = " ", key = "e" },
          { action = "Lazy",                                                     desc = " Lazy",            icon = "󰒲 ", key = "l" },
          { action = "Mason",                                                    desc = " Mason",           icon = "◍ ", key = "m" },
          { action = "qa",                                                       desc = " Quit",            icon = " ", key = "q" },
        },
        footer = function()
          local stats = require("lazy").stats()
          local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
          return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" }
        end,
      },
    }

    for _, button in ipairs(opts.config.center) do
      button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
      button.key_format = "  %s"
    end

    -- close Lazy and re-open when the dashboard is ready
    if vim.o.filetype == "lazy" then
      vim.cmd.close()
      vim.api.nvim_create_autocmd("User", {
        pattern = "DashboardLoaded",
        callback = function()
          require("lazy").show()
        end,
      })
    end
    return opts
  end,
}