Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an interface to get current_state #171

Open
guoang opened this issue Jan 30, 2023 · 5 comments
Open

Provide an interface to get current_state #171

guoang opened this issue Jan 30, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@guoang
Copy link

guoang commented Jan 30, 2023

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
@goolord
Copy link
Owner

goolord commented Jan 30, 2023

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

@guoang
Copy link
Author

guoang commented Jan 30, 2023

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

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.

@goolord
Copy link
Owner

goolord commented Feb 7, 2023

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.

@goolord
Copy link
Owner

goolord commented Feb 7, 2023

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 goolord added the enhancement New feature or request label Feb 14, 2023
@avegancafe
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants