agzam / spacehammer

Hammerspoon config inspired by Spacemacs
MIT License
569 stars 70 forks source link

Make SpaceHammer a Hammerspoon Spoon? #124

Open jaidetree opened 3 years ago

jaidetree commented 3 years ago

Currently, Spacehammer is intended to own the ~/.hammerspoon directory. This suits people who first discover Spacehammer but this setup might be alienating to existing Hammerspoon users who don't want to start over again or move their years worth of Hammerspoon config over.

It seems more than possible to put Spacehammer into a spoon. It will need to match the Spoon API so that it exports an object with a SPOON:start() function that would handle what our init.lua does now.

The problem is this would be a breaking change, so we would need to decide carefully how to best roll that out.

Off the top of my head, I am thinking it might be wise to create a separate organization like Spacehammer/spacehammer.git and the version of that repo can exist as a spoon so it doesn't break everyone's config. This version of the repo can remain unchanged, add a link and deprecation notice to the README.org, and direct issues to the new repo.

Additionally, looking at https://www.hammerspoon.org/Spoons/SpoonInstall.html, we could even have our own repository for spoons written in fennel.

The other anticipated change will likely be updating the fennel search paths to include *.spoon/init.fnl which is pretty trivial.

This is not a high priority but is a direction we can go if we're interested.

jaidetree commented 3 years ago

One question that comes to mind though:

Would doing this inhibit our ability to make a brew formula?

Should still work but the setup script would be different.

Other notes:

https://github.com/Hammerspoon/hammerspoon/blob/c31c2aeaa32dd2e3379340af14eec4a116f476d9/extensions/_coresetup/init.lua#L312-L317

Uses package.path to resolve the spoon path. My current value looks like:

/Users/j/.hammerspoon/?.lua;/Users/j/.hammerspoon/?/init.lua;/Users/j/.hammerspoon/Spoons/?.spoon/init.lua;/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua;/Applications/Hammerspoon.app/Contents/Resources/extensions/?.lua;/Applications/Hammerspoon.app/Contents/Resources/extensions/?/init.lua;/Users/j/.luarocks/share/lua/5.4/?.lua;/Users/j/.luarocks/share/lua/5.4/?/init.lua;/Users/j/.luarocks/share/lua/5.3/?.lua;/Users/j/.luarocks/share/lua/5.3/?/init.lua"

Might be able to insert something like $HOME/.spacehammer/Spoons/?.spoon/init.fnl but will need to experiment to confirm.

Grazfather commented 3 years ago

Yes, I think at the very least a v1.0 release would do the trick. Maybe we can finagle it so that even if one were to pull in the 1.0 changes as their .hammerspoon it would still work as expected. Maybe even warn them that they should install it as a spoon.

Do we want a brew formula if we want a spoon? Brew for hammerspoon makes sense, but then it's just a matter of:

hs.loadSpoon("SpoonInstall") -- Maybe they have to install this manually
spoon.SpoonInstall("spacehammer")
jaidetree commented 3 years ago

How would fennel be installed there?

I think the goal for the brew formula is to make it a 1 liner to install hammerspoon, luarocks, and fennel. In addition to supporting autoupdates