Skip to content

Commit

Permalink
Merge branch 'main' of github.com:knausj85/knausj_talon
Browse files Browse the repository at this point in the history
# Conflicts:
#	lang/javascript/javascript.py
#	plugin/symbols/symbols.talon
#	settings.talon
  • Loading branch information
timo95 committed Feb 12, 2024
2 parents 64a7577 + fce77d0 commit 4353ee9
Show file tree
Hide file tree
Showing 77 changed files with 489 additions and 384 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"
Expand Down
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
- repo: https://github.com/ikamensh/flynt/
rev: "1.0.1"
hooks:
- id: flynt
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.11.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
hooks:
- id: black
args: ["--target-version", "py310"]
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
Expand Down
27 changes: 1 addition & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,32 +266,7 @@ into each editor.

## Settings

Several options are configurable via a single settings file out of the box. Any setting can be made context specific as needed (e.g., per-OS, per-app, etc).

https://github.com/talonhub/community/blob/main/settings.talon

```
#adjust the scale of the imgui to my liking
imgui.scale = 1.3
# enable if you'd like the picker gui to automatically appear when explorer has focus
user.file_manager_auto_show_pickers = 0
#set the max number of command lines per page in help
user.help_max_command_lines_per_page = 50
# set the max number of contexts display per page in help
user.help_max_contexts_per_page = 20
# The default amount used when scrolling continuously
user.mouse_continuous_scroll_amount = 80
#stop continuous scroll/gaze scroll with a pop
user.mouse_enable_pop_stops_scroll = 1
#enable pop click with 'control mouse' mode
user.mouse_enable_pop_click = 1
#When enabled, the 'Scroll Mouse' GUI will not be shown.
user.mouse_hide_mouse_gui = 0
#hide cursor when mouse_wake is called to enable zoom mouse
user.mouse_wake_hides_cursor = 0
#the amount to scroll up/down (equivalent to mouse wheel on Windows by default)
user.mouse_wheel_down_amount = 120
```
Several options are configurable via a [single settings file](settings.talon) out of the box. Any setting can be made context specific as needed (e.g., per-OS, per-app, etc).

The most commonly adjusted settings are probably

Expand Down
28 changes: 28 additions & 0 deletions apps/arc/arc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from talon import Context, Module, actions, app

ctx = Context()
mod = Module()

mod.apps.arc = "app.name: Arc"
mod.apps.arc = """
os: mac
app.bundle: company.thebrowser.Browser
"""
ctx.matches = r"""
app: arc
"""


@ctx.action_class("user")
class UserActions:
def tab_close_wrapper():
actions.sleep("180ms")
actions.app.tab_close()


@ctx.action_class("browser")
class BrowserActions:
def show_extensions():
actions.app.tab_open()
actions.browser.go("arc://extensions")
10 changes: 10 additions & 0 deletions apps/arc/arc_mac.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
app: arc
os: mac
-
tag(): browser
tag(): user.tabs

please [<user.text>]:
key("cmd-l")
sleep(200ms)
insert(user.text or "")
8 changes: 8 additions & 0 deletions apps/arc/little-arc_mac.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
user.running: arc
os: mac
-
# This assumes that you have not disabled Little Arc
little arc [<user.text>]:
key("cmd-alt-n")
sleep(200ms)
insert(user.text or "")
6 changes: 3 additions & 3 deletions apps/emacs/emacs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from typing import Optional

from talon import Context, Module, actions
from talon import Context, Module, actions, settings

mod = Module()
setting_meta = mod.setting(
mod.setting(
"emacs_meta",
type=str,
default="esc",
Expand All @@ -28,7 +28,7 @@


def meta(keys):
m = setting_meta.get()
m = settings.get("user.emacs_meta")
if m == "alt":
return " ".join("alt-" + k for k in keys.split())
elif m == "cmd":
Expand Down
13 changes: 8 additions & 5 deletions apps/emacs/emacs.talon
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ save buffers kill emacs: user.emacs("save-buffers-kill-emacs")
save some buffers: user.emacs("save-some-buffers")
sort lines: user.emacs("sort-lines")
sort words: user.emacs("sort-words")
file [loop] continue: user.emacs("fileloop-continue")

go directory: user.emacs("dired-jump")
other go directory: user.emacs("dired-jump-other-window")

[toggle] debug on error: user.emacs("toggle-debug-on-error")
[toggle] debug on quit: user.emacs("toggle-debug-on-quit")
[toggle] input method: user.emacs("toggle-input-method")
[toggle] truncate lines: user.emacs("toggle-truncate-lines")
[toggle] word wrap: user.emacs("toggle-word-wrap")
Expand Down Expand Up @@ -204,8 +206,9 @@ search toggle case [fold | sensitive]: user.emacs_meta("c")
search toggle regex: user.emacs_meta("r")

highlight lines matching [regex]: user.emacs("highlight-lines-matching-regexp")
highlight phrase: user.emacs("highlight-phrase")
highlight regex: user.emacs("highlight-regexp")
unhighlight regex: user.emacs("unhighlight-regexp")
unhighlight (regex | phrase): user.emacs("unhighlight-regexp")
unhighlight all:
user.emacs_prefix()
user.emacs("unhighlight-regexp")
Expand Down Expand Up @@ -286,8 +289,8 @@ rectangle number lines: user.emacs("rectangle-number-lines")

# ----- PROJECT SUPPORT ----- #
project [find] file: user.emacs("project-find-file")
project [find] regexp: user.emacs("project-find-regexp")
project [query] replace regexp: user.emacs("project-query-replace-regexp")
project [find] (regex | grep): user.emacs("project-find-regexp")
project [query] replace regex: user.emacs("project-query-replace-regexp")
project (dired | directory): user.emacs("projectile-dired")
project [run] shell: user.emacs("projectile-run-shell")
project [run] eshell: user.emacs("projectile-run-eshell")
Expand All @@ -298,8 +301,8 @@ project [run] shell command: user.emacs("projectile-run-shell-command-in-root")
project [run] async shell command:
user.emacs("projectile-run-async-shell-command-in-root")
project (switch [to buffer] | buffer | buff): user.emacs("projectile-switch-to-buffer")
project kill buffers: user.emacs("projectile-kill-buffers")
project switch project: user.emacs("project-switch-project")
project kill [buffers]: user.emacs("projectile-kill-buffers")
project switch [project]: user.emacs("project-switch-project")

# ----- VC/GIT SUPPORT ----- #
vc (annotate | blame): user.emacs("vc-annotate")
Expand Down
12 changes: 9 additions & 3 deletions apps/emacs/emacs_commands.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ balance-windows, ctrl-x +
beginning-of-buffer, meta-<
browse-kill-ring,, b-k-r
buffer-menu, ctrl-x ctrl-b
next-buffer, ctrl-x right
previous-buffer, ctrl-x left
bury-buffer,, bur
byte-compile-file,, by-c
byte-recompile-directory
byte-recompile-file
clear-rectangle, ctrl-x r c
clone-indirect-buffer,, clo-i
comment-dwim, meta-;
comment-line,, comment-l
comment-region, ctrl-c ;
compile
compile-defun,, co-def
copy-rectangle-as-kill, ctrl-x r meta-w
copy-rectangle-to-register, ctrl-x r r
Expand Down Expand Up @@ -62,6 +64,7 @@ global-visual-line-mode,, gl-v-l-m
goto-line, meta-g meta-g
highlight-lines-matching-regexp, meta-s h l
highlight-regexp, meta-s h r
highlight-phrase, meta-s h p
hl-line-mode,, hl-l-m
indent-region, meta-ctrl-\
indent-rigidly, ctrl-x tab
Expand Down Expand Up @@ -95,6 +98,7 @@ mark-whole-buffer, ctrl-x h
move-beginning-of-line, ctrl-a
move-end-of-line, ctrl-e
narrow-to-region, ctrl-x n n
next-buffer, ctrl-x right
next-error, meta-g n
occur, meta-s o
open-rectangle, ctrl-x r o
Expand Down Expand Up @@ -125,6 +129,7 @@ overwrite-mode,, overwr
package-autoremove
pop-global-mark, ctrl-x ctrl-@
pop-to-mark-command, ctrl-u ctrl-space
previous-buffer, ctrl-x left
previous-error, meta-g p
project-find-file, ctrl-x p f
project-find-regexp, ctrl-x p g
Expand Down Expand Up @@ -192,7 +197,8 @@ tab-next, ctrl-x t o
tab-previous, ctrl-x t O
tab-undo, ctrl-x t u
text-mode,, text-m
toggle-debug-on-error
toggle-debug-on-error,, t-d-on-e
toggle-debug-on-quit,, t-d-on-q
toggle-input-method, ctrl-\
toggle-truncate-lines, ctrl-x x t
toggle-word-wrap
Expand Down
2 changes: 2 additions & 0 deletions apps/firefox/firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
apps.firefox = "app.name: Firefox Developer Edition"
apps.firefox = "app.name: firefox"
apps.firefox = "app.name: Firefox-esr"
apps.firefox = "app.name: LibreWolf"
apps.firefox = "app.name: waterfox"
apps.firefox = """
os: windows
and app.name: Firefox
Expand Down
4 changes: 2 additions & 2 deletions apps/git/git.talon
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ git {user.git_command} [<user.git_arguments>]:
git commit [<user.git_arguments>] message [<user.prose>]:
args = git_arguments or ""
message = prose or ""
user.insert_between("git commit{args} --message '{message}", "'")
user.insert_between('git commit{args} --message "{message}', '"')
git stash [push] [<user.git_arguments>] message [<user.prose>]:
args = git_arguments or ""
message = prose or ""
user.insert_between("git stash push{args} --message '{message}", "'")
user.insert_between('git stash push{args} --message "{message}', '"')

# Optimistic execution for frequently used commands that are harmless (don't
# change repository or index state).
Expand Down
2 changes: 2 additions & 0 deletions apps/gnome_terminal/gnome_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
and app.exe: gnome-terminal-server
os: linux
and app.name: Gnome-terminal
os: linux
and app.name: Mate-terminal
"""

# Context matching
Expand Down
2 changes: 2 additions & 0 deletions apps/jetbrains/jetbrains.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def idea_commands(commands):
mod.apps.jetbrains = """
os: mac
and app.bundle: com.jetbrains.pycharm
os: mac
and app.bundle: com.jetbrains.rider
"""
mod.apps.jetbrains = """
os: windows
Expand Down
6 changes: 3 additions & 3 deletions apps/mintty/mintty_win.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import subprocess

from talon import Context, Module, actions, ui
from talon import Context, Module, actions, settings, ui

mod = Module()
mod.apps.mintty = """
Expand All @@ -26,7 +26,7 @@
directories_to_remap = {}
directories_to_exclude = {}

setting_cyg_path = mod.setting(
mod.setting(
"cygpath",
type=str,
default="C:\\cygwin64\\bin\\cygpath.exe",
Expand All @@ -41,7 +41,7 @@ def get_win_path(cyg_path):
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
path = (
subprocess.check_output(
[setting_cyg_path.get(), "-w", cyg_path], startupinfo=si
[settings.get("user.cygpath"), "-w", cyg_path], startupinfo=si
)
.strip(b"\n")
.decode()
Expand Down
2 changes: 2 additions & 0 deletions apps/nautilus/nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
and app.exe: nautilus
os: linux
and app.name: Org.gnome.Nautilus
os: linux
and app.name: Caja
"""

# Context matching
Expand Down
6 changes: 3 additions & 3 deletions apps/tmux/tmux.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from talon import Context, Module, actions
from talon import Context, Module, actions, settings

mod = Module()

Expand All @@ -7,7 +7,7 @@
and tag: user.tmux
"""

setting_tmux_prefix_key = mod.setting(
mod.setting(
"tmux_prefix_key",
type=str,
default="ctrl-b",
Expand All @@ -19,7 +19,7 @@
class TmuxActions:
def tmux_prefix():
"""press control and the configured tmux prefix key"""
actions.key(f"{setting_tmux_prefix_key.get()}")
actions.key(settings.get("user.tmux_prefix_key"))

def tmux_keybind(key: str):
"""press tmux prefix followed by a key bind"""
Expand Down
4 changes: 4 additions & 0 deletions apps/vscode/vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
and app.name: VSCodium
os: windows
and app.exe: VSCodium.exe
os: windows
and app.name: Azure Data Studio
os: windows
and app.exe: azuredatastudio.exe
"""

ctx.matches = r"""
Expand Down
5 changes: 5 additions & 0 deletions apps/vscode/vscode.talon
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ show shortcuts: user.vscode("workbench.action.openGlobalKeybindings")
show shortcuts json: user.vscode("workbench.action.openGlobalKeybindingsFile")
show snippets: user.vscode("workbench.action.openSnippets")

# VSCode Snippets
snip (last | previous): user.vscode("jumpToPrevSnippetPlaceholder")
snip next: user.vscode("jumpToNextSnippetPlaceholder")

# Display
centered switch: user.vscode("workbench.action.toggleCenteredLayout")
fullscreen switch: user.vscode("workbench.action.toggleFullScreen")
Expand Down Expand Up @@ -266,6 +270,7 @@ join lines: user.vscode("editor.action.joinLines")
full screen: user.vscode("workbench.action.toggleFullScreen")

curse undo: user.vscode("cursorUndo")
curse redo: user.vscode("cursorRedo")

select word: user.vscode("editor.action.addSelectionToNextFindMatch")
skip word: user.vscode("editor.action.moveSelectionToNextFindMatch")
Expand Down
2 changes: 1 addition & 1 deletion core/app_switcher/app_name_overrides.windows.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
grip, DataGrip
term, iTerm2
term, WindowsTerminal.exe
one note, ONENOTE
lock, slack.exe
app, slack.exe
Expand Down
3 changes: 3 additions & 0 deletions core/app_switcher/app_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ def switcher_focus_app(app: ui.App):
raise RuntimeError(f"Can't focus app: {app.name}")
actions.sleep(0.1)

def switcher_focus_last():
"""Focus last window/application"""

def switcher_focus_window(window: ui.Window):
"""Focus window and wait until switch is made"""
window.focus()
Expand Down
Loading

0 comments on commit 4353ee9

Please sign in to comment.