hammerspoon updates

This commit is contained in:
Noah Masur 2021-08-30 15:36:04 -06:00
parent ba75ec2366
commit 43cbd18caf
5 changed files with 64 additions and 2 deletions

View File

@ -2,6 +2,7 @@
function fish_user_key_bindings
bind -M insert \co 'edit'
bind -M insert \ca 'cd; and edit; cd -'
bind -M insert \ce 'recent'
bind -M insert \cg 'commandline-git-commits'
bind -M insert \cf 'fcd'

View File

@ -39,15 +39,20 @@ function obj:init()
-- Control was not down but is now
if not self.lastModifiers['ctrl'] then
-- Only prepare to send escape if no other modifier keys are in use
self.lastModifiers = newModifiers
if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then
self.sendEscape = true
self.movements = 0
end
-- Control was down and is up, hasn't been blocked by another key, and
-- isn't above the movement threshold
elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 20) then
elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 30) then
self.lastModifiers = newModifiers
-- Allow for shift-escape
if newModifiers['shift'] then
hs.eventtap.keyStroke({'shift'}, 'escape', 0)
@ -56,8 +61,12 @@ function obj:init()
end
self.sendEscape = false
self.movements = 0
self.numberOfCharacters = 0
-- Control was down and is up, but isn't ready to send escape
else
self.lastModifiers = newModifiers
end
end
)

View File

@ -0,0 +1,50 @@
--- === Launcher ===
local obj={}
obj.__index = obj
-- Metadata
obj.name = 'Launcher'
obj.version = '0.1'
obj.license = 'MIT - https://opensource.org/licenses/MIT'
function obj:init()
-- Begin launcher mode
self.launcher = hs.hotkey.modal.new('ctrl', 'space')
-- Behaviors on enter
function self.launcher:entered()
-- hs.alert'Entered mode'
end
-- Behaviors on exit
function self.launcher:exited()
-- hs.alert'Exited mode'
end
-- Use escape to exit launcher mode
self.launcher:bind('', 'escape', function() self.launcher:exit() end)
-- Launcher shortcuts
self.launcher:bind('', 'space', function() hs.hints.windowHints(); self.launcher:exit() end)
self.launcher:bind('', 'return', function() self:switch('Alacritty.app') end)
self.launcher:bind('', 'D', function() self:switch('Discord.app') end)
self.launcher:bind('', 'E', function() self:switch('Microsoft Outlook.app') end)
self.launcher:bind('', 'F', function() self:switch('Firefox.app') end)
self.launcher:bind('', 'G', function() self:switch('Mimestream.app') end)
self.launcher:bind('', 'M', function() self:switch('Messages.app') end)
self.launcher:bind('', 'O', function() self:switch('Obsidian.app') end)
self.launcher:bind('', 'P', function() self:switch('System Preferences.app') end)
self.launcher:bind('', 'R', function() hs.reload() end)
self.launcher:bind('', 'S', function() self:switch('Slack.app') end)
self.launcher:bind('', 'Z', function() self:switch('zoom.us.app') end)
end
function obj:switch(app)
hs.application.launchOrFocus(app)
self.launcher:exit()
end
return obj

View File

@ -1 +1,2 @@
hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon
hs.loadSpoon('Launcher'):init()

View File

@ -227,6 +227,7 @@ vim.api.nvim_exec([[
au BufRead,BufNewFile *.toml.*link setfiletype toml
au BufRead,BufNewFile *.muttrc setfiletype muttrc
au BufRead,BufNewFile .env* set ft=text | set syntax=sh
au BufRead,BufNewFile *.hcl set ft=terraform
]], false)
-- LaTeX options