.hammerspoon/init.lua

Mon, 07 Mar 2022 22:57:44 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 07 Mar 2022 22:57:44 -0600
changeset 984
9c7c452cc87f
parent 908
fa7c0607c00e
child 987
556f618e117a
permissions
-rw-r--r--

Remove vim-lsp workaround

493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 hs.window.animationDuration = 0
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
3 -- aliases and partial bindings to make life easier
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 local bindKey = hs.hotkey.bind
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 local cmd = hs.fnutils.partial(bindKey, {"cmd"})
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 local cmdShift = hs.fnutils.partial(bindKey, {"cmd", "shift"})
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
7 local cmdCtrl = hs.fnutils.partial(bindKey, {"cmd", "ctrl"})
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
9 function focusedWindow()
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
10 return hs.window.focusedWindow() or hs.window.desktop()
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
11 end
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
12
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
13 function focusTo(direction)
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
14 local fn = hs.getObjectMetatable('hs.window')['focusWindow' .. direction]
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
15 return function ()
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
16 fn(focusedWindow(), nil, nil, true)
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
17 end
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
18 end
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19
908
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
20 function findOrLaunch(a)
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
21 return hs.application.find(a) or hs.application.open(a, 3)
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
22 end
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
23
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
24 -- and the key bindings
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
25 cmdShift('r', hs.reload)
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
26
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
27 cmd('k', focusTo('North'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
28 cmd('up', focusTo('North'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
30 cmd('j', focusTo('South'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
31 cmd('down', focusTo('South'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
33 cmd('h', focusTo('West'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
34 cmd('left', focusTo('West'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
36 cmd('l', focusTo('East'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
37 cmd('right', focusTo('East'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
39 cmdShift('up', function () focusedWindow():maximize() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
40
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
41 cmdShift('down', function () focusedWindow():minimize() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
42
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
43 cmdShift('left', function () focusedWindow():moveToUnit(hs.layout.left50) end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
44 cmdShift('right', function () focusedWindow():moveToUnit(hs.layout.right50) end)
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
45
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
46 cmdCtrl('left', function () focusedWindow():moveOneScreenWest() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
47 cmdCtrl('right', function () focusedWindow():moveOneScreenEast() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
48
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
49 cmd('return', function ()
908
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
50 local a = findOrLaunch('iTerm')
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
51 a:selectMenuItem({"Shell", "New Window"})
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
52 a:activate()
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
53 end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
54
734
294238afafac Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents: 733
diff changeset
55 cmdShift('return', function ()
294238afafac Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents: 733
diff changeset
56 os.execute(os.getenv('SHELL')..' -l -i -c "exec mvim"')
294238afafac Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents: 733
diff changeset
57 end)
644
42383cfcb729 add cmd-shift-return for quick mvim windows
Meredith Howard <mhoward@roomag.org>
parents: 620
diff changeset
58
908
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
59 cmdCtrl('return', function ()
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
60 local a = findOrLaunch('MacVim')
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
61 a:selectMenuItem({"File", "New Window"})
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
62 a:activate()
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
63 end)

mercurial