diff --git a/lua/alpha/themes/theta.lua b/lua/alpha/themes/theta.lua index 78b643a..d8b463e 100644 --- a/lua/alpha/themes/theta.lua +++ b/lua/alpha/themes/theta.lua @@ -18,6 +18,29 @@ local file_icons = { provider = "mini", } +-- Function to open the relevant config file +-- Takes into accoutn vim or lua setup +local function open_config_local() + local config_path = vim.fn.stdpath("config") + vim.api.nvim_set_current_dir(config_path) + + -- Select init.* file base on setup + local init_lua = config_path .. "/init.lua" + local init_vim = config_path .. "/init.vim" + + if vim.fn.filereadable(init_lua) == 1 then + vim.cmd("edit " .. init_lua) + elseif vim.fn.filereadable(init_vim) == 1 then + vim.cmd("edit " .. init_vim) + else + print("No init.* file found in " .. config_path) + print("Fallback to config path") + vim.cmd("cd " .. config_path) + end +end +-- Makes function globally available to be used in cmd-button +_G.open_config = open_config_local + local function icon(fn) if file_icons.provider ~= "devicons" and file_icons.provider ~= "mini" then vim.notify("Alpha: Invalid file icons provider: " .. file_icons.provider .. ", disable file icons", vim.log.levels.WARN) @@ -174,7 +197,7 @@ local buttons = { dashboard.button("e", " New file", "ene"), dashboard.button("SPC f f", "󰈞 Find file"), dashboard.button("SPC f g", "󰊄 Live grep"), - dashboard.button("c", " Configuration", "cd stdpath('config')"), + dashboard.button("c", " Configuration", "lua open_config()"), dashboard.button("u", " Update plugins", "Lazy sync"), dashboard.button("q", "󰅚 Quit", "qa"), },