From 73f008458a10b28f1fd82a41e00a17546bdf58d5 Mon Sep 17 00:00:00 2001 From: js0ny Date: Thu, 13 Feb 2025 01:28:55 +0000 Subject: [PATCH] Sync from Windows --- platforms/win/ahk/Caps.ahk | 3 +- platforms/win/ahk/Tab.ahk | 43 +++++++++++++++++++++++++ tools/browser/surfingkeys.js | 22 ++++++------- tools/doom/evil.el | 3 +- tools/doom/init.el | 2 +- tools/doom/org.el | 15 +++++++-- tools/doom/snippets/org-mode/unnumbered | 7 ++++ tools/nvim/lua/keymaps/basic.lua | 15 ++++----- 8 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 platforms/win/ahk/Tab.ahk create mode 100644 tools/doom/snippets/org-mode/unnumbered diff --git a/platforms/win/ahk/Caps.ahk b/platforms/win/ahk/Caps.ahk index 5f11baf..cfedbad 100644 --- a/platforms/win/ahk/Caps.ahk +++ b/platforms/win/ahk/Caps.ahk @@ -108,7 +108,8 @@ global g_ControlRepeatDetected := false ~*^F9:: ~*^F10:: ~*^F11:: -~*^F12:: { +~*^F12:: +{ global g_AbortSendEsc g_AbortSendEsc := true } diff --git a/platforms/win/ahk/Tab.ahk b/platforms/win/ahk/Tab.ahk new file mode 100644 index 0000000..555e4d5 --- /dev/null +++ b/platforms/win/ahk/Tab.ahk @@ -0,0 +1,43 @@ +#Requires AutoHotkey v2.0 +#SingleInstance Force + +Tab Up:: Send '{Tab ' (A_PriorKey = 'Tab' ? 1 : times) '}' +Tab:: global times := '' + +#HotIf GetKeyState('Tab', 'P') +h::Left +n::Down +e::Up +i::Right +H::Home +I::End +u::PgUp +d::PgDn +1::F1 +2::F2 +3::F3 +4::F4 +5::F5 +6::F6 +7::F7 +8::F8 +9::F9 +0::F10 +-::F11 +=::F12 ++:: global times .= ThisHotkey +#HotIf + +Enter Up:: Send '{Enter ' (A_PriorKey = 'Enter' ? 1 : times) '}' +Enter:: global times := '' + +#HotIf GetKeyState('Enter', 'P') +b:: { + Run("vivaldi.exe") +} +t:: { + Run("wezterm-gui.exe") +} +c:: { + Run("code.exe") +} diff --git a/tools/browser/surfingkeys.js b/tools/browser/surfingkeys.js index e3516f5..0625669 100644 --- a/tools/browser/surfingkeys.js +++ b/tools/browser/surfingkeys.js @@ -189,7 +189,7 @@ const mapLists = { e: "k", i: "l", // l <-> i - l: "i", + l: "gi", // Focus on first input box by default L: "I", // k <-> n k: "n", @@ -209,7 +209,7 @@ const mapLists = { // gh/gi -> Prev/Next History gh: "S", gi: "D", - gl: "gi", // Focus on first input box + gl: "i", // Use `gl` to search and focus on input box // t -> Open Link in New Tab t: "gf", // 缩放 @@ -322,7 +322,7 @@ searchAliases.forEach(([alias, name, url]) => { // #region Site-specific // This is a global keymap -mapkey(",s", "[s]hare without parameter", function () { +mapkey("yY", "yank link without parameter", function () { const url = new URL(window.location.href); Clipboard.write(url.origin + url.pathname); }); @@ -359,11 +359,11 @@ mapkey(",e", "Edit last input", function () { var btn = qs("div.ds-icon-button"); btn[btn.length - 5].click(); }, { domain: /chat.deepseek.com/ }); -mapkey(",y", "Yank last oupput", function () { +mapkey(",y", "[y]ank last oupput", function () { var btn = qs("div.ds-icon-button"); btn[btn.length - 4].click(); }, { domain: /chat.deepseek.com/ }); -mapkey(",r", "Regenerate last output", function () { +mapkey(",r", "[r]egenerate last output", function () { var btn = qs("div.ds-icon-button"); btn[btn.length - 3].click(); }, { domain: /chat.deepseek.com/ }); @@ -425,7 +425,8 @@ mapkey(",p", "Switch to GitHub Page", function () { repo = href.split("/")[4]; window.location.href = gh.pageLink(owner, repo); }, { domain: /github.com/ }); -mapkey(",r", "Copy short [r]efeference owner/repo", function () { +/// This might be useful for Vim plugins +mapkey(",y", "[y]ank short refeference owner/repo", function () { const href = window.location.href; owner = href.split("/")[3]; repo = href.split("/")[4]; @@ -475,10 +476,7 @@ mapkey(",S", "Open Source in GitHub (New Page)", function () { /** * 0 - 网络 * 1 - 学术 - * 2 - 数学 - * 3 - 写作 - * 4 - 视频 - * 5 - 社交 + * 2 - 社交 */ const perplexityFocusOn = function (n) { q("div.rounded-md").querySelectorAll("span")[1].click() @@ -492,7 +490,7 @@ mapkey(",b", "Add Perplexity [b]ookmark", function () { q("div.sticky.left-0").querySelectorAll("button")[2].click() }, { domain: /perplexity.ai/ }); mapkey(",w", "Toggle [w]riting/[w]eb Search", function () { - perplexityFocusOn(3); + perplexityFocusOn(0); }, { domain: /perplexity.ai/ }); mapkey(",s", "[s]tart Generating", function () { var btns = qs("span.grow button"); @@ -502,7 +500,7 @@ mapkey(",y", "[y]ank Last Output", function () { var toolbars = qs("div.mt-sm"); var last = toolbars[toolbars.length - 1]; var btns = last.querySelectorAll("button"); - btns[4].click(); + btns[5].click(); }, { domain: /perplexity.ai/ }); mapkey(",r", "Change model to [r]egenerate last output", function () { var toolbars = qs("div.mt-sm"); diff --git a/tools/doom/evil.el b/tools/doom/evil.el index fe352be..2a4bb55 100644 --- a/tools/doom/evil.el +++ b/tools/doom/evil.el @@ -20,4 +20,5 @@ ;; Swap ; and : (map! :leader ";" #'execute-extended-command - ":" #'pp-eval-expression) + ":" #'pp-eval-expression + "f h" #'consult-recent-file) diff --git a/tools/doom/init.el b/tools/doom/init.el index d65fbb7..33aaba0 100644 --- a/tools/doom/init.el +++ b/tools/doom/init.el @@ -178,7 +178,7 @@ ;;zig ; C, but simpler :email - (mu4e +org +gmail) + ;;(mu4e +org +gmail) ;;notmuch ;;(wanderlust +gmail) diff --git a/tools/doom/org.el b/tools/doom/org.el index 166f94e..d4c7eb4 100644 --- a/tools/doom/org.el +++ b/tools/doom/org.el @@ -24,7 +24,7 @@ ;; - (setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELLED(c@)") + (setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d@/!)" "CANCELLED(c@)") (sequence "[ ](T)" "[-](P)" "[?](Q)" "|" "[X](D)"))) ;; Keymaps @@ -40,7 +40,9 @@ (setq org-capture-templates '(("t" "Task" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Tasks") "* TODO %?\n %U\n %a\n %i" - :empty-lines 1))) + :empty-lines 1) + ("n" "Note" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Notes")) + )) ) @@ -64,3 +66,12 @@ :m "N" #'org-agenda-priority-up :m "E" #'org-agenda-priority-down :m "i" #'evil-forward-char) + + + +;; (use-package! org-download +;; :after org +;; :custom +;; (setq org-download-screenshot-method +;; "pwsh.exe -File 'D:\\script.ps1'") +;; ) diff --git a/tools/doom/snippets/org-mode/unnumbered b/tools/doom/snippets/org-mode/unnumbered new file mode 100644 index 0000000..02023d2 --- /dev/null +++ b/tools/doom/snippets/org-mode/unnumbered @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: unnumbered +# key: unnumbered +# -- +:PROPERTIES: +:UNNUMBERED: t +:END: diff --git a/tools/nvim/lua/keymaps/basic.lua b/tools/nvim/lua/keymaps/basic.lua index b808bc8..5e9d68b 100644 --- a/tools/nvim/lua/keymaps/basic.lua +++ b/tools/nvim/lua/keymaps/basic.lua @@ -1,4 +1,4 @@ -local mode_arrow = { "n", "v", "s", "x" } +local mode_arrow = { "n", "v", "s", "x", "o" } local keymaps_basic = { -- Modification of Original Keymap - Colemak -- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L8 @@ -56,17 +56,16 @@ local keymaps_basic = { -- Modification of Original Keymap - Colemak { mode = mode_arrow, keys = "i", cmd = "l", opts = { desc = "Right", silent = true } }, { keys = "H", cmd = ":bprevious", opts = { desc = "Previous Buffer" } }, { keys = "I", cmd = ":bnext", opts = { desc = "Next Buffer" } }, - { keys = "N", cmd = "5j", opts = { desc = "Up 5 Lines" } }, - { keys = "E", cmd = "5e", opts = { desc = "Down 5 Lines" } }, + { mode = mode_arrow, keys = "N", cmd = "5j", opts = { desc = "Up 5 Lines" } }, + { mode = mode_arrow, keys = "E", cmd = "5e", opts = { desc = "Down 5 Lines" } }, { keys = "Y", cmd = "y$", opts = { desc = "Yank to End of Line" } }, { keys = "E", cmd = "5k" }, - -- Text object implementation { mode = { "n", "o", "x" }, keys = "l", cmd = "i", opts = { desc = "Insert" } }, { keys = "L", cmd = "I", opts = { desc = "Insert at Start of Line" } }, - { keys = "k", cmd = "n", opts = { desc = "Next Search" } }, - { keys = "K", cmd = "N", opts = { desc = "Previous Search" } }, - { keys = "j", cmd = "e", opts = { desc = "jump to end of word" } }, - { keys = "J", cmd = "E", opts = { desc = "jump to end of WORD" } }, + { mode = mode_arrow, keys = "k", cmd = "n", opts = { desc = "Next Search" } }, + { mode = mode_arrow, keys = "K", cmd = "N", opts = { desc = "Previous Search" } }, + { mode = mode_arrow, keys = "j", cmd = "e", opts = { desc = "jump to end of word" } }, + { mode = mode_arrow, keys = "J", cmd = "E", opts = { desc = "jump to end of WORD" } }, -- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L60 { keys = "", cmd = "nohlsearchdiffupdate", opts = { desc = "Clear Search Highlight" } }, }