nvimdev / dashboard-nvim

vim dashboard
MIT License
2.39k stars 192 forks source link

feat: add items to center on condition #488

Open cdmill opened 1 month ago

cdmill commented 1 month ago

Here is a simple addition to the doom theme that allows items in the center to be conditionally shown. My main use case for this is for sessions and git. For example,

center = {
  -- items removed
  { 
    action = "Neogit", 
    desc = " git",
    icon = " ", 
    key = "G", 
    cond = require("cmill.core.util").is_git_repo() -- only show if cwd is git repo
  }, { 
    action = "SessionManager load_current_dir_session", 
    desc = " restore session", 
    icon = " ", 
    key = "s", 
    cond = require("session_manager").current_dir_session_exists()  -- only show if session for cwd exists
  },
  -- items removed
}