Skip to content

Commit 14b14ed

Browse files
committed
fix: rework code to be usable with community
1 parent 5a7e245 commit 14b14ed

File tree

6 files changed

+143
-22
lines changed

6 files changed

+143
-22
lines changed

Diff for: core/neovim.talon

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ app: neovim
33
# TODO: move these outside of this file, as we don't want to enable it
44
# when in command mode for instance
55
# neovim has native support for finding text, etc.
6-
tag(): user.find
7-
tag(): user.zoom
6+
tag(): user.find_and_replace

Diff for: core/split/split.talon

-7
This file was deleted.

Diff for: core/split/split.py renamed to core/splits/splits.py

+95-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
and not tag: user.vim_mode_command
99
"""
1010

11-
ctx.tags = ["user.split"]
11+
ctx.tags = ["user.splits"]
1212

1313

1414
# https://dev.to/mr_destructive/vim-window-splits-p3p
1515
@ctx.action_class("user")
1616
class UserActions:
1717
# ----- split creation -----
18+
19+
# ----- split arrangement ----
1820
def split_move_up():
1921
pass
2022

@@ -52,11 +54,17 @@ def split_focus_last():
5254
actions.key("ctrl-w")
5355
actions.key("W")
5456

55-
def split_focus(number: int):
57+
def split_focus_number(index: int):
5658
actions.user.vim_set_normal_exterm()
57-
actions.insert(f"{number}")
59+
actions.insert(f"{index}")
5860
actions.key("ctrl-w ctrl-w")
5961

62+
# FIXME: This name is subject to change pending https://github.com/talonhub/community/pull/1446 decisions
63+
def split_focus_most_recent():
64+
actions.user.vim_set_normal_exterm()
65+
actions.key("ctrl-w")
66+
actions.key("p")
67+
6068
# ----- Split resize -----
6169
def split_shrink_width():
6270
actions.user.vim_set_normal_exterm()
@@ -88,18 +96,22 @@ def split_expand_height():
8896

8997
# ----- Split layout -----
9098
def split_layout_toggle():
91-
pass
99+
actions.user.vim_set_normal_exterm()
100+
actions.key("ctrl-w")
101+
actions.key("r")
92102

93-
def split_layout_join_two_groups():
94-
pass
103+
def split_clear():
104+
actions.user.vim_set_normal_exterm()
105+
actions.key("ctrl-w")
106+
actions.key("q")
95107

96-
def split_layout_clear():
108+
def split_clear_all():
97109
actions.user.vim_set_normal_exterm()
98110
actions.key("ctrl-w")
99111
actions.key("o")
100112

101113
# Requirement: https://github.com/dhruvasagar/vim-zoom
102-
def split_layout_toggle_maximize():
114+
def split_maximize():
103115
actions.user.vim_run_normal_exterm_key("ctrl-w m")
104116

105117

@@ -116,3 +128,78 @@ def split_move_last_tab():
116128
def split_move_new_tab():
117129
"""Move the current window to a new tab"""
118130
actions.user.vim_run_normal_exterm_key("ctrl-w T")
131+
132+
# TEMPORARY: Once https://github.com/talonhub/community/pull/1446 is merged, this should be removed
133+
def split_focus_right():
134+
"""Focus on the split to the right of the current window"""
135+
136+
def split_focus_left():
137+
"""Focus on the split to the left of the current window"""
138+
139+
def split_focus_down():
140+
"""Focus on the split below the current window"""
141+
142+
def split_focus_up():
143+
"""Focus on the split above the current window"""
144+
145+
def split_focus_next():
146+
"""Goes to next split"""
147+
148+
def split_focus_last():
149+
"""Goes to last split"""
150+
151+
def split_focus_number(index: int):
152+
"""Navigates to the specified split"""
153+
154+
def split_focus_most_recent():
155+
"""Focus on the most recently focused split"""
156+
157+
# Arrangement
158+
def split_move_right():
159+
"""Move the split to the right"""
160+
161+
def split_move_left():
162+
"""Move the split to the left"""
163+
164+
def split_move_down():
165+
"""Move the split down"""
166+
167+
def split_move_up():
168+
"""Move the split up"""
169+
170+
def split_layout_toggle():
171+
"""Flips the orientation of the active split"""
172+
173+
def split_center():
174+
"""Centers the active split (eg: zen mode)"""
175+
176+
def split_rotate_right():
177+
"""Rotates the splits to the right"""
178+
179+
def split_rotate_left():
180+
"""Rotates the splits to the left"""
181+
182+
# Resizing
183+
def split_maximize():
184+
"""Maximizes the active split"""
185+
186+
def split_reset():
187+
"""Resets all the split sizes"""
188+
189+
def split_expand_width():
190+
"""Expands the split width"""
191+
192+
def split_expand_height():
193+
"""Expands the split height"""
194+
195+
def split_shrink_width():
196+
"""Shrinks the split width"""
197+
198+
def split_shrink_height():
199+
"""Shrinks the split height"""
200+
201+
def split_set_width(width: int):
202+
"""Sets the split width"""
203+
204+
def split_set_height(height: int):
205+
"""Sets the split height"""

Diff for: core/splits/splits.talon

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
app: neovim
2+
tag: user.splits
3+
-
4+
5+
(split|buf) move new tab: user.split_move_new_tab()
6+
(split|buf) move next tab: user.split_move_next_tab()
7+
(split|buf) move last tab: user.split_move_last_tab()
8+
9+
# TEMPORARY: Once https://github.com/talonhub/community/pull/1446 is merged, these should be removed
10+
# Navigation
11+
cross right: user.split_focus_right()
12+
cross left: user.split_focus_left()
13+
cross down: user.split_focus_down()
14+
cross up: user.split_focus_up()
15+
cross next: user.split_focus_next()
16+
cross last: user.split_focus_last()
17+
cross flip: user.split_focus_most_recent()
18+
(go split | cross) <number>: user.split_focus_number(number)
19+
20+
# Arrangement
21+
split move right: user.split_move_right()
22+
split move left: user.split_move_left()
23+
split move down: user.split_move_down()
24+
split move up: user.split_move_up()
25+
split toggle: user.split_layout_toggle()
26+
split center: user.split_center()
27+
split rotate right: user.split_rotate_right()
28+
split rotate left: user.split_rotate_left()
29+
30+
# Resizing
31+
split wider: user.split_expand_width()
32+
split taller: user.split_expand_height()
33+
split thinner: user.split_shrink_width()
34+
split shorter: user.split_shrink_height()
35+
split set width <number>: user.split_set_width(number)
36+
split set height <number>: user.split_set_height(number)

Diff for: core/tabs/tabs.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from talon import Context, actions
1+
from talon import Context, Module, actions
22

33
# TODO: should we also match tag: user.tabs or tabs are always present anyway so does not matter?
4+
mod = Module()
45
ctx = Context()
56
ctx.matches = r"""
67
app: neovim
@@ -48,3 +49,12 @@ def tab_move_right():
4849
# def tab_duplicate():
4950

5051
# def tab_back():
52+
53+
54+
@mod.action_class
55+
class TabActions:
56+
def tab_move_left():
57+
"""Moves the current tab to the left."""
58+
59+
def tab_move_right():
60+
"""Moves the current tab to the right."""

Diff for: core/vim_no_insert.talon

-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ app: neovim
44
# tag: user.vim_mode_normal_terminal
55
# TODO: commenting above for now as this is also needed in insert mode as otherwise we can't dictate things properly
66
-
7-
8-
# insert() will never use paste(). This is needed in lots of modes like command/normal/normal terminal to be
9-
# able to insert text without triggering the paste from clipboard
10-
tag(): user.insert_paste_disabled

0 commit comments

Comments
 (0)