alpha-nvim
alpha-nvim copied to clipboard
Provide an interface to get current_state
I'm trying to write my own theme and need this interface.
diff --git a/lua/alpha.lua b/lua/alpha.lua
index 9fa8e70..69e7205 100644
--- a/lua/alpha.lua
+++ b/lua/alpha.lua
@@ -671,6 +671,10 @@ function alpha.setup(config)
})
end
+function alpha.get_state()
+ return current_state
+end
+
alpha.layout_element = layout_element
alpha.keymaps_element = keymaps_element
i believe lua tables are passed by reference so alpha.current_state = current_state would suffice, can i ask what you're trying to do? just out of curiosity
i believe lua tables are passed by reference so
alpha.current_state = current_statewould suffice, can i ask what you're trying to do? just out of curiosity
This looks good to me too. What I need is to access current_state in my vim config, I currently can't do that since current_state is a local variable.
the reason i'm asking what specifically you're trying to do is because you can already access the state by extending the layout_element and keymaps_element tables which is a bit more principled. if you're not actually defining a new element type then i'm curious y you need the state.
also the api just changed a little to accommodate multiple concurrent alpha configs
https://github.com/goolord/alpha-nvim/blob/main/lua/alpha.lua#L17-L18
but this could still be done
@goolord for context I'm looking into this too, the reason I want the state available would be because when I open a new session I want to be able to say "If and only if alpha is not already open, open alpha", since the start command also closes alpha and is more of a toggle. Alternatively, making start idempotent would also work