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

Spoonify Spacehammer #183

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
518bcc1
Update functional library
jaidetree Oct 16, 2023
fff7288
Initial spoonify
jaidetree Oct 17, 2023
81cd4a5
Update imports
jaidetree Oct 17, 2023
fd6ee92
Make hyper binding optional if not present in config
jaidetree Dec 9, 2023
d43db39
Fix example config path
ambirdsall Dec 11, 2023
99210e6
Fix path to activate modal fn in example config
ambirdsall Dec 12, 2023
51f0ec0
Make hs.ipc.cliInstall work on M1 & co.
ambirdsall Dec 12, 2023
e8dd456
Merge pull request #2 from ambirdsall/spoonify
jaidetree Dec 12, 2023
28b37bf
Try to get tests running
Grazfather Dec 14, 2023
531d6a8
cleanup
Grazfather Dec 14, 2023
5cc9a11
cleanup more
Grazfather Dec 14, 2023
c36aa5d
cleanx
Grazfather Dec 14, 2023
374481a
more
Grazfather Dec 14, 2023
fdded94
Merge pull request #3 from Grazfather/fix_tests
jaidetree Dec 14, 2023
21ecae6
Remove -c flag from test.lua
jaidetree Dec 14, 2023
1d75ea1
Fix argument order of string.find
ambirdsall Dec 14, 2023
8417c03
Update testing docs with updated paths
jaidetree Dec 14, 2023
8d9f141
Extract file helper functions to lib directory
ambirdsall Dec 14, 2023
cb8cfa6
Move most other globals to lib/globals.fnl
ambirdsall Dec 14, 2023
7a8574e
Create init.example.fnl, extract console keybind
ambirdsall Dec 14, 2023
1ff7743
Remove obsolete comments
ambirdsall Dec 14, 2023
61f52a1
Merge pull request #4 from ambirdsall/fix-cliInstall-conditional
jaidetree Dec 14, 2023
8d2a05a
Update file helper docstrings for consistency
ambirdsall Dec 14, 2023
a7de87a
Merge pull request #5 from ambirdsall/extract-helpers-from-core-and-a…
jaidetree Dec 14, 2023
5a0a156
Support custom paths from tools like nix
jaidetree Apr 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/CODEOWNERS

This file was deleted.

2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

34 changes: 25 additions & 9 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
hs.alert.show("Spacehammer config loaded")
local Spacehammer = {
name = "Spacehammer",
version = "3.0.0",
author = "Ag Ibragimov",
license = "MIT",
homepage = "https://github.com/agzam/spacehammer"
}

-- Support upcoming 5.4 release and also use luarocks' local path
package.path = package.path .. ";" .. os.getenv("HOME") .. "/.luarocks/share/lua/5.4/?.lua;" .. os.getenv("HOME") .. "/.luarocks/share/lua/5.4/?/init.lua"
package.cpath = package.cpath .. ";" .. os.getenv("HOME") .. "/.luarocks/lib/lua/5.4/?.so"
package.path = package.path .. ";" .. os.getenv("HOME") .. "/.luarocks/share/lua/5.3/?.lua;" .. os.getenv("HOME") .. "/.luarocks/share/lua/5.3/?/init.lua"
package.cpath = package.cpath .. ";" .. os.getenv("HOME") .. "/.luarocks/lib/lua/5.3/?.so"
function Spacehammer:init()
local scriptPath = hs.spoons.scriptPath()

fennel = require("fennel")
table.insert(package.loaders or package.searchers, fennel.searcher)
package.path = package.path .. ";" .. scriptPath .. "?.lua;" .. scriptPath .. "?/init.lua;"
package.cpath = package.cpath .. ";" .. scriptPath .. "?.so;"

require "core"
fennel = require("spacehammer.vendor.fennel")
fennel.path = scriptPath .. "?.fnl;" .. scriptPath .. "?/init.fnl;" .. fennel.path
fennel['macro-path'] = scriptPath .. "?.fnl;" .. scriptPath .. "?/init-macros.fnl;" .. scriptPath .. "?/init.fnl;" .. fennel.path
print(hs.inspect(package.searchers))
table.insert(package.loaders or package.searchers, fennel.searcher)
end

function Spacehammer:start()
print(hs.inspect(package.searchers))
require('spacehammer.core')
hs.alert.show("Spacehammer config loaded")
end

return Spacehammer
18 changes: 0 additions & 18 deletions lib/testing/test.lua

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion apps.fnl → spacehammer/apps.fnl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(local {: global-filter} (require :lib.utils))
(local {: global-filter} (require :spacehammer.lib.utils))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; App switcher
Expand Down
2 changes: 1 addition & 1 deletion chrome.fnl → spacehammer/chrome.fnl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(require-macros :lib.macros)
(require-macros :spacehammer.lib.macros)

;; setting conflicting Cmd+L (jump to address bar) keybinding to Cmd+Shift+L
(fn open-location
Expand Down
14 changes: 7 additions & 7 deletions config.example.fnl → spacehammer/config.example.fnl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(require-macros :lib.macros)
(require-macros :lib.advice.macros)
(local windows (require :windows))
(local emacs (require :emacs))
(local slack (require :slack))
(local vim (require :vim))
(require-macros :spacehammer.lib.macros)
(require-macros :spacehammer.lib.advice.macros)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these used at all? They'd have to be used through the fully name, and anyway we should use import-macros.

(local windows (require :spacehammer.windows))
(local emacs (require :spacehammer.emacs))
(local slack (require :spacehammer.slack))
(local vim (require :spacehammer.vim))

(local {:concat concat
:logf logf} (require :lib.functional))
:logf logf} (require :spacehammer.lib.functional))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; WARNING
Expand Down
27 changes: 14 additions & 13 deletions core.fnl → spacehammer/core.fnl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
(hs.ipc.cliInstall) ; ensure CLI installed

(local fennel (require :fennel))
(require :lib.globals)
(local fennel (require :spacehammer.vendor.fennel))
(require :spacehammer.lib.globals)
(local {:contains? contains?
:for-each for-each
:map map
:merge merge
:reduce reduce
:split split
:some some} (require :lib.functional))
(local atom (require :lib.atom))
(require-macros :lib.macros)
(require-macros :lib.advice.macros)
:some some} (require :spacehammer.lib.functional))
(local atom (require :spacehammer.lib.atom))
(require-macros :spacehammer.lib.macros)
(require-macros :spacehammer.lib.advice.macros)

;; Add compatability with spoons as the spoon global may not exist at
;; this point until a spoon is loaded. It will exist if a spoon is
Expand Down Expand Up @@ -155,6 +155,7 @@ Returns nil. This function causes side-effects.
Returns nil
"
(when (some source-updated? files)
(hs.alert "Spacehammer reloaded")
(hs.console.clearConsole)
(hs.reload)))

Expand Down Expand Up @@ -213,13 +214,13 @@ Returns nil. This function causes side-effects.
(local config (require :config))

;; Initialize our modules that depend on config
(local modules [:lib.hyper
:vim
:windows
:apps
:lib.bind
:lib.modal
:lib.apps])
(local modules [:spacehammer.lib.hyper
:spacehammer.vim
:spacehammer.windows
:spacehammer.apps
:spacehammer.lib.bind
:spacehammer.lib.modal
:spacehammer.lib.apps])

(defadvice get-config-impl
[]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion grammarly.fnl → spacehammer/grammarly.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

(fn back-to-emacs
[]
(let [windows (require :windows)
(let [windows (require :spacehammer.windows)
run-str (.. "/usr/local/bin/emacsclient"
" -e "
"'(with-current-buffer (window-buffer (selected-window)) "
Expand Down
6 changes: 3 additions & 3 deletions lib/advice/init.fnl → spacehammer/lib/advice/init.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Advising API to register functions
"

(require-macros :lib.macros)
(local fennel (require :fennel))
(require-macros :spacehammer.lib.macros)
(local fennel (require :spacehammer.vendor.fennel))
(local {: contains?
: compose
: filter
Expand All @@ -14,7 +14,7 @@ Advising API to register functions
: reduce
: seq
: slice
: split} (require :lib.functional))
: split} (require :spacehammer.lib.functional))

(var advice {})
(var advisable [])
Expand Down
6 changes: 3 additions & 3 deletions lib/advice/macros.fnl → spacehammer/lib/advice/macros.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Macros to create advisable functions or register advice for advisable functions
(assert body1 "advisable function expected body")
(let [fn-name-str (tostring fn-name)]
`(local ,fn-name
(let [adv# (require :lib.advice)]
(let [adv# (require :spacehammer.lib.advice)]
(adv#.make-advisable ,fn-name-str (fn ,args ,docstr ,body1 ,...))))))

(fn afn
Expand All @@ -37,7 +37,7 @@ Macros to create advisable functions or register advice for advisable functions
"
(assert body1 "advisable function expected body")
(let [fn-name-str (tostring fn-name)]
`(let [adv# (require :lib.advice)]
`(let [adv# (require :spacehammer.lib.advice)]
(adv#.make-advisable ,fn-name-str (fn ,args ,body1 ,...)))))


Expand All @@ -58,7 +58,7 @@ Macros to create advisable functions or register advice for advisable functions
(assert (= (type docstr) :string) "A docstr is required for defining advice")
(assert body1 "advisable function expected body")
`(local ,fn-name
(let [adv# (require :lib.advice)
(let [adv# (require :spacehammer.lib.advice)
target-fn# (fn ,fn-name ,args ,docstr ,body1 ,...)
advice-fn# (setmetatable
{}
Expand Down
10 changes: 5 additions & 5 deletions lib/apps.fnl → spacehammer/lib/apps.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ for, versus switching between apps, versus exiting apps, versus activating apps.

This module works mechanically similar to lib/modal.fnl.
"
(local atom (require :lib.atom))
(local statemachine (require :lib.statemachine))
(local atom (require :spacehammer.lib.atom))
(local statemachine (require :spacehammer.lib.statemachine))
(local os (require :os))
(local {: call-when
: find
: merge
: noop
: tap}
(require :lib.functional))
(require :spacehammer.lib.functional))
(local {:action->fn action->fn
:bind-keys bind-keys}
(require :lib.bind))
(local lifecycle (require :lib.lifecycle))
(require :spacehammer.lib.bind))
(local lifecycle (require :spacehammer.lib.lifecycle))


(local log (hs.logger.new "apps.fnl" "debug"))
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/bind.fnl → spacehammer/lib/bind.fnl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(local hyper (require :lib.hyper))
(local hyper (require :spacehammer.lib.hyper))
(local {: contains?
: map
: split}
(require :lib.functional))
(require :spacehammer.lib.functional))

(local log (hs.logger.new "bind.fnl" "debug"))

Expand Down
1 change: 1 addition & 0 deletions lib/functional.fnl → spacehammer/lib/functional.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
(set ct (+ ct 1))))
ct)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Reduce Primitives
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
4 changes: 2 additions & 2 deletions lib/globals.fnl → spacehammer/lib/globals.fnl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(local fennel (require :fennel))
(local {: map} (require :lib.functional))
(local fennel (require :spacehammer.vendor.fennel))
(local {: map} (require :spacehammer.lib.functional))

(global pprint
(fn pprint
Expand Down
4 changes: 2 additions & 2 deletions lib/hyper.fnl → spacehammer/lib/hyper.fnl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(require-macros :lib.macros)
(local {: find} (require :lib.functional))
(require-macros :spacehammer.lib.macros)
(local {: find} (require :spacehammer.lib.functional))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
2 changes: 1 addition & 1 deletion lib/lifecycle.fnl → spacehammer/lib/lifecycle.fnl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(local {: do-action} (require :lib.bind))
(local {: do-action} (require :spacehammer.lib.bind))
(local log (hs.logger.new "lifecycle.fnl" "debug"))


Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions lib/modal.fnl → spacehammer/lib/modal.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ states defined in the table.
Allows us to create the machinery for displaying, entering, exiting, and
switching menus in one place which is then powered by config.fnl.
"
(local atom (require :lib.atom))
(local statemachine (require :lib.statemachine))
(local apps (require :lib.apps))
(local atom (require :spacehammer.lib.atom))
(local statemachine (require :spacehammer.lib.statemachine))
(local apps (require :spacehammer.lib.apps))
(local {: butlast
: call-when
: concat
Expand All @@ -23,13 +23,13 @@ switching menus in one place which is then powered by config.fnl.
: join
: map
: merge}
(require :lib.functional))
(require :spacehammer.lib.functional))
(local {:align-columns align-columns}
(require :lib.text))
(require :spacehammer.lib.text))
(local {:action->fn action->fn
:bind-keys bind-keys}
(require :lib.bind))
(local lifecycle (require :lib.lifecycle))
(require :spacehammer.lib.bind))
(local lifecycle (require :spacehammer.lib.lifecycle))

(local log (hs.logger.new "modal.fnl" "debug"))
(var fsm nil)
Expand Down Expand Up @@ -273,8 +273,8 @@ switching menus in one place which is then powered by config.fnl.
(hs.alert.closeAll 0)
(unbind-keys)
(call-when stop-timeout)
(lifecycle.exit-menu state.context.menu)
)))
(lifecycle.exit-menu state.context.menu))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Menus, & Config Navigation
Expand Down Expand Up @@ -364,7 +364,7 @@ switching menus in one place which is then powered by config.fnl.
Returns new updated modal state if we are leaving the current app.
"
(let [{:config config
:menu prev-menu} state.context]
:menu prev-menu} state.context]
(if (= prev-menu.key config.key)
nil
(->menu state))))
Expand Down
6 changes: 3 additions & 3 deletions lib/statemachine.fnl → spacehammer/lib/statemachine.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ the next transition.
"


(require-macros :lib.macros)
(local atom (require :lib.atom))
(require-macros :spacehammer.lib.macros)
(local atom (require :spacehammer.lib.atom))
(local {: butlast
: call-when
: concat
: conj
: last
: merge
: slice} (require :lib.functional))
: slice} (require :spacehammer.lib.functional))


(fn update-state
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(local fennel (require :fennel))
(require :lib.globals)
(local fennel (require :spacehammer.vendor.fennel))
(require :spacehammer.lib.globals)
(local {: map
: slice
: pprint} (require :lib.functional))
: pprint} (require :spacehammer.lib.functional))

(local homedir (os.getenv "HOME"))
(local customdir (.. homedir "/.spacehammer"))
Expand Down Expand Up @@ -35,8 +35,8 @@
(each [i test-file (ipairs test-files)]
(let [test-file-path (hs.fs.pathToAbsolute (.. dir "/" test-file))]
(print "Running tests for" test-file-path)
(fennel.dofile test-file-path))
))
(fennel.dofile test-file-path))))



(collect-tests)
Expand Down
15 changes: 15 additions & 0 deletions spacehammer/lib/testing/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--test.lua
-- A script to run fennel files as tests passed in as cli args


fennel = require("spacehammer.vendor.fennel")

-- Support docstrings

local searcher = fennel.makeSearcher({
useMetadata = true,
})

local testRunner = require "lib.testing.test-runner"

testRunner["load-tests"](_cli.args)
2 changes: 1 addition & 1 deletion lib/text.fnl → spacehammer/lib/text.fnl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(local {: map
: reduce} (require :lib.functional))
: reduce} (require :spacehammer.lib.functional))

"
These functions will align items in a modal menu based on columns.
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions repl.fnl → spacehammer/repl.fnl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(local coroutine (require :coroutine))
(local fennel (require :fennel))
(local jeejah (require :jeejah))
(local {:merge merge} (require :lib.functional))
(local fennel (require :spacehammer.vendor.fennel))
(local jeejah (require :spacehammer.vendor.jeejah))
(local {:merge merge} (require :spacehammer.lib.functional))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; nREPL support
Expand Down
File renamed without changes.
Loading