From aaeb19136e3b80875f6e86887271b431c7f0d72e Mon Sep 17 00:00:00 2001 From: Marc Schinschel Date: Sun, 4 Jan 2026 15:34:52 +0100 Subject: [PATCH] Fix: Adding new function _open_config_local_ which searches for the current neovim config directory returned from stdpath('config') and opens the active init.lua or init.vim file. Fallback to just the config directory in case on init.lua or init.vim file is available. --- lua/alpha/themes/theta.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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"), },