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

enable vim mode? #49

Closed
butterywombat opened this issue Apr 12, 2020 · 10 comments
Closed

enable vim mode? #49

butterywombat opened this issue Apr 12, 2020 · 10 comments

Comments

@butterywombat
Copy link

butterywombat commented Apr 12, 2020

how does this work?
I've tried
{:vim {:enabled true}}
(vim.enable)
in config.fnl.
Thanks!

@jaidetree
Copy link
Collaborator

This feature is in a more experimental state and will likely need some discussion and follow-up work to get it where it needs to be.

Currently, you should only need {:vim {:enabled true}} in your ~/.spacehammer/config.fnl to enable vim mode.

It should render a mode box on the bottom right corner of the screen. Now in say, a browser-based text box like the reply form, you can operate in normal/insert modes as indicated by the status box.

For now, we mostly focused on moving by words, beginning of the line, end of the line, moving up with k, down with j, left with h, and right with l. This is where more feedback can really help us so we know how much to implement.

Could you please provide some feedback on #50 so I know what to prioritize and how we can make this feature more helpful to you?

I've attached a screenshot to see the mode indicator.

Screen Shot 2020-04-12 at 1 50 55 PM

@butterywombat
Copy link
Author

hmm I've been unable to see that mode box rendered in any browser.
i'm on latest everything I think - OSX 10.15.4, 9c99680 spacehammer, 0.9.78 hammerspoon

@butterywombat
Copy link
Author

butterywombat commented Apr 20, 2020

the 'toggle console' also doesn't seem to work for me- trying ctrl/cmd + ` (trying to look to it to implement a 'toggle app' :)-
specifically trying to get this to work/would be nice as a generic fn (though I'm not familiar with lua or lisp). lmk if I should open another ticket

hs.hotkey.bind({}, "F15", function()
  local app = hs.application.get("kitty")

  if app then
      if not app:mainWindow() then
          app:selectMenuItem({"kitty", "New OS window"})
      elseif app:isFrontmost() then
          app:hide()
      else
          app:activate()
      end
  else
      hs.application.launchOrFocus("kitty")
      app = hs.application.get("kitty")
  end

  app:mainWindow():moveToUnit'[100,50,0,0]'
  app:mainWindow().setShadows(false)
end)

@jaidetree
Copy link
Collaborator

@dxuehu Can you please create a separate issue for toggling the console?

The VIM mode status should be displayed on the bottom right corner of your main screen. Can you open the Hammerspoon console, reload the config, and paste any output as well as your ~/.spacehammer/config.fnl?

It sounds like the app is not loading properly.

@butterywombat
Copy link
Author

butterywombat commented Apr 20, 2020

2020-04-19 18:39:26: -- Lazy extension loading enabled
2020-04-19 18:39:26: -- Loading ~/.hammerspoon/init.lua
2020-04-19 18:39:26: -- Loading extension: alert
2020-04-19 18:39:26: -- Loading extension: ipc
2020-04-19 18:39:26: -- Loading extension: fnutils
2020-04-19 18:39:26: -- Loading extension: logger
2020-04-19 18:39:26: -- Loading extension: hints
2020-04-19 18:39:26: -- Loading extension: uielement
2020-04-19 18:39:26: -- Loading extension: window
2020-04-19 18:39:26: -- Loading extension: pathwatcher
2020-04-19 18:39:26: -- Loading extension: hotkey
2020-04-19 18:39:26: 18:39:26     hotkey: Enabled hotkey ⌘⌃`
2020-04-19 18:39:26: -- Loading extension: drawing
2020-04-19 18:39:26: -- Loading extension: console
2020-04-19 18:39:26:              hotkey: Enabled hotkey F18
2020-04-19 18:39:26: -- Loading extension: screen
2020-04-19 18:39:26: -- Loading extension: grid
2020-04-19 18:39:26:              hotkey: Enabled hotkey ⌘K
2020-04-19 18:39:26:              hotkey: Enabled hotkey ⌥SPACE
2020-04-19 18:39:26:              hotkey: Enabled hotkey ⌥N
2020-04-19 18:39:26:              hotkey: Enabled hotkey ⌥P
2020-04-19 18:39:26:              hotkey: Disabled previous hotkey ⌘⌃`
2020-04-19 18:39:26:              hotkey: Enabled hotkey ⌘⌃`
2020-04-19 18:39:26: -- Loading extension: application
2020-04-19 18:39:26: -- Loading extension: base64
2020-04-19 18:39:26: -- Done.
2020-04-19 18:39:30: -- Some applications have alternate names which can also be checked if you enable Spotlight support with `hs.application.enableSpotlightForNameSearches(true)`.
2020-04-19 18:39:52: 18:39:52   apps.fnl:     app is now: Google Chrome
2020-04-19 18:41:00: 18:41:00     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:41:00:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:41:00:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:41:00:            apps.fnl:     app is now: nil
2020-04-19 18:41:33: 18:41:33                 app is now: Google Chrome
2020-04-19 18:41:41: 18:41:41     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:41:41:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:41:41:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:41:41:            apps.fnl:     app is now: nil
2020-04-19 18:41:43: 18:41:43                 app is now: Google Chrome
2020-04-19 18:42:12: 18:42:12     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:42:12:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:42:12:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:42:12:            apps.fnl:     app is now: nil
2020-04-19 18:42:12:                          app is now: Google Chrome
2020-04-19 18:42:13: 18:42:13     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:42:13:            apps.fnl:     app is now: nil
2020-04-19 18:42:13:                          app is now: Google Chrome
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:42:13:            apps.fnl:     app is now: nil
2020-04-19 18:42:13:                          app is now: Google Chrome
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:42:13:            apps.fnl:     app is now: nil
2020-04-19 18:42:13:                          app is now: Google Chrome
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:42:13:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:42:13:            apps.fnl:     app is now: nil
2020-04-19 18:42:13:                          app is now: Google Chrome
2020-04-19 18:47:10: 18:47:10     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:47:10:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:47:10:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:47:10:            apps.fnl:     app is now: nil
2020-04-19 18:47:23: 18:47:23                 app is now: Google Chrome
2020-04-19 18:47:27: 18:47:27     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:47:27:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:47:27:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:47:27:            apps.fnl:     app is now: nil
2020-04-19 18:47:29: 18:47:29                 app is now: Google Chrome
2020-04-19 18:47:35: 18:47:35     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:47:35:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:47:35:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:47:35:            apps.fnl:     app is now: nil
2020-04-19 18:47:37: 18:47:37                 app is now: Google Chrome
2020-04-19 18:47:41: 18:47:41     hotkey: Deleted hotkey ⌘⇧L
2020-04-19 18:47:41:              hotkey: Deleted hotkey ⌥K
2020-04-19 18:47:41:              hotkey: Deleted hotkey ⌥J
2020-04-19 18:47:41:            apps.fnl:     app is now: Hammerspoon
2020-04-19 18:47:56: -- Lazy extension loading enabled
2020-04-19 18:47:56: -- Loading ~/.hammerspoon/init.lua
2020-04-19 18:47:56: -- Loading extension: alert
2020-04-19 18:47:56: -- Loading extension: ipc
2020-04-19 18:47:56: -- Loading extension: fnutils
2020-04-19 18:47:56: -- Loading extension: logger
2020-04-19 18:47:56: -- Loading extension: hints
2020-04-19 18:47:56: -- Loading extension: uielement
2020-04-19 18:47:56: -- Loading extension: window
2020-04-19 18:47:56: -- Loading extension: pathwatcher
2020-04-19 18:47:56: -- Loading extension: hotkey
2020-04-19 18:47:56: 18:47:56     hotkey: Enabled hotkey ⌘⌃`
2020-04-19 18:47:56: -- Loading extension: drawing
2020-04-19 18:47:56: -- Loading extension: console
2020-04-19 18:47:56:              hotkey: Enabled hotkey F18
2020-04-19 18:47:56: -- Loading extension: screen
2020-04-19 18:47:56: -- Loading extension: grid
2020-04-19 18:47:56:              hotkey: Enabled hotkey ⌘K
2020-04-19 18:47:56:              hotkey: Enabled hotkey ⌥SPACE
2020-04-19 18:47:56:              hotkey: Enabled hotkey ⌥N
2020-04-19 18:47:56:              hotkey: Enabled hotkey ⌥P
2020-04-19 18:47:56:              hotkey: Disabled previous hotkey ⌘⌃`
2020-04-19 18:47:56:              hotkey: Enabled hotkey ⌘⌃`
2020-04-19 18:47:56: -- Loading extension: application
2020-04-19 18:47:56: -- Loading extension: base64
2020-04-19 18:47:56:            apps.fnl:     app is now: Hammerspoon
2020-04-19 18:47:56: -- Done.

https://github.com/dxuehu/dotfileserino/blob/master/spacehammer/config.fnl

@jaidetree
Copy link
Collaborator

https://github.com/dxuehu/dotfileserino/blob/master/spacehammer/config.fnl#L508

This may be something to improve with documentation but that config object at the bottom of the file is what is exported and read as "config".

The issue with https://github.com/dxuehu/dotfileserino/blob/master/spacehammer/config.fnl#L80 is that it's not exported and is just being evaluated then immediately garbage-collected.

Instead please update the config definition at https://github.com/dxuehu/dotfileserino/blob/master/spacehammer/config.fnl#L497-L502:

(local config
       {:title "Main Menu"
        :items menu-items
        :keys common-keys
        :apps apps
        :hyper {:key :F18}})

To:

(local config
       {:title "Main Menu"
        :items menu-items
        :keys common-keys
        :apps apps
        :vim {:enabled true}
        :hyper {:key :F18}})

That should enable vim mode and display the mode indicator.

@butterywombat
Copy link
Author

oh doh, makes sense. thank you!

@lilruffian
Copy link

How might I toggle vim on and off from the menu?

@jaidetree
Copy link
Collaborator

@brandonxoliver Try the following:

Ensure vim mode is enabled, keep this towards the bottom of your config.fnl:

(local config
       {
       ;; ...
        :vim {:enabled true}})

Create a vim-items collection of menu items:

(local vim-items
       [return
        {:key :e
         :title "Enable vim mode"
         :action "vim:enable"}
        {:key :d
         :title "Disable vim mode"
         :action "vim:disable"}])

Update the main menu items to create a vim submenu:

(local menu-items
       [ ;; ...
        ;; ...
        {:key :v
         :title "Vim"
         :items vim-items}])

Save your config.fnl and you should see a vim group in the main menu.

@lilruffian
Copy link

Awesome thanks!

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

No branches or pull requests

3 participants