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

refactor: merge VimMode into the api abstraction #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions core/edit/run_commands.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from talon import Context, Module, actions, app, settings, ui

from ..rpc.api import VimAPI
from ..rpc.modes import VimMode

mod = Module()


# Actions to run commands in specific modes
# TODO: move the v = VimMode() + switch of mode to mode.py and just call them here
@mod.action_class
class Actions:
def vim_run_insert(cmd: str):
Expand Down
6 changes: 3 additions & 3 deletions core/modes/detect_modes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from talon import Module

from ..rpc.modes import VimMode
from ..rpc.api import VimAPI

mod = Module()

Expand All @@ -10,10 +10,10 @@
class Actions:
def vim_is_terminal():
"""check if currently in terminal mode"""
v = VimMode()
v = VimAPI()
return v.is_terminal_mode()

def vim_is_visual():
"""check if currently in visual mode"""
v = VimMode()
v = VimAPI()
return v.is_visual_mode()
30 changes: 15 additions & 15 deletions core/modes/switch_modes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from talon import Module

from ..rpc.modes import VimMode
from ..rpc.api import VimAPI

mod = Module()

Expand All @@ -11,82 +11,82 @@
class Actions:
def vim_set_normal(auto: bool = True):
"""set normal mode"""
v = VimMode()
v = VimAPI()
v.set_normal_mode(auto=auto)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably causing a merge conflict as we removed auto=auto iirc

return v

def vim_set_normal_exterm():
"""set normal mode, escaping from the terminal mode"""
v = VimMode()
v = VimAPI()
v.set_normal_mode_exterm()
return v

def vim_set_normal_np(auto: bool = True):
"""set normal mode and don't preserve the previous mode"""
v = VimMode()
v = VimAPI()
v.set_normal_mode_np(auto=auto)
return v

def vim_set_visual():
"""set visual mode"""
v = VimMode()
v = VimAPI()
v.set_visual_mode()

def vim_set_visual_line():
"""set visual line mode"""
v = VimMode()
v = VimAPI()
v.set_visual_line_mode()
return v

def vim_set_visual_block():
"""set visual block mode"""
v = VimMode()
v = VimAPI()
v.set_visual_block_mode()

def vim_set_insert():
"""set insert mode"""
v = VimMode()
v = VimAPI()
v.set_insert_mode()
return v

def vim_set_terminal():
"""set terminal mode"""
v = VimMode()
v = VimAPI()
v.set_terminal_mode()
return v

def vim_set_command():
"""set command line mode"""
v = VimMode()
v = VimAPI()
v.set_command_mode()
return v

def vim_set_command_exterm():
"""set command line mode, escaping from the terminal mode"""
v = VimMode()
v = VimAPI()
v.set_command_mode_exterm()
return v

def vim_set_replace():
"""set replace mode"""
v = VimMode()
v = VimAPI()
v.set_replace_mode()
return v

def vim_set_visual_replace():
"""set visual replace mode"""
v = VimMode()
v = VimAPI()
v.set_visual_replace_mode()
return v

def vim_set_any_motion_mode():
"""set any motion mode"""
v = VimMode()
v = VimAPI()
v.set_any_motion_mode()
return v

def vim_set_any_motion_mode_exterm():
"""set any motion mode, escaping from the terminal mode"""
v = VimMode()
v = VimAPI()
v.set_any_motion_mode_exterm()
return v
Loading