surfingkeys

This commit is contained in:
js0ny 2025-10-31 21:47:00 +00:00
parent 16ab036322
commit cf221c7c4b
4 changed files with 1082 additions and 146 deletions

View file

@ -0,0 +1,7 @@
---@type vim.lsp.Config
return {
cmd = { "typescript-language-server", "--stdio" },
root_markers = { "tsconfig.json", "jsconfig.json", "package.json" },
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
settings = {},
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
// vim:foldmethod=marker:foldmarker=#region,#endregion:foldlevel=0 // vim:foldmethod=marker:foldmarker=#region,#endregion:foldlevel=0
// Paste this into surfingkeys advanced settings // Paste this into surfingkeys advanced settings
// or use: // or use:
// Load settings from: https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/tools/browser/surfingkeys.js // Load settings from: https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/misc/browser/surfingkeys.js
// Browse to Extension > Surfingkeys > Allow access to file URLs to enable local file access // Browse to Extension > Surfingkeys > Allow access to file URLs to enable local file access
// Windows: file:///C:/Users/username/.dotfiles/tools/browser/surfingkeys.js // Windows: file:///C:/Users/username/.dotfiles/tools/browser/surfingkeys.js
// Linux: file:///home/username/.dotfiles/tools/browser/surfingkeys.js // Linux: file:///home/username/.dotfiles/tools/browser/surfingkeys.js
@ -186,33 +186,22 @@ const qs = (selector) => document.querySelectorAll(selector);
// #region Keymap // #region Keymap
// Normal Mode Keymap // Normal Mode Keymap
const mapLists = { const mapLists = {
/// scroll page // Prev History < H - L > Next History
// Arrow H: "S",
n: "j", L: "D",
e: "k", // J,K -> Up/Down HalfPage
i: "l", // J: "d",
// l <-> i // K: "e",
l: "gi", // Focus on first input box by default
L: "I",
// k <-> n
k: "n",
K: "N",
// j <-> e
j: "e",
// PrevTab < H - I > NextTab
H: "E",
I: "R",
// E,N -> Up/Down HalfPage
N: "d",
E: "e",
// F -> Open Link in New Tab // F -> Open Link in New Tab
F: "af", F: "af",
// oH -> Tab History // oH -> Tab History
oH: "H", oH: "H",
// gh/gi -> Prev/Next History // gh/gl -> Prev/Next Tab
gh: "S", gh: "E",
gi: "D", gl: "R",
gl: "i", // Use `gl` to search and focus on input box "<Alt-h>": "E",
"<Alt-l>": "R",
gi: "i", // Use `gl` to search and focus on input box
// t -> Open Link in New Tab // t -> Open Link in New Tab
t: "gf", t: "gf",
// 缩放 // 缩放
@ -220,25 +209,12 @@ const mapLists = {
zo: "ze", zo: "ze",
zz: "zr", zz: "zr",
}; };
// Visual Mode Keymap
const vMapLists = {
n: "j",
N: "J",
e: "k",
E: "K",
i: "l",
I: "L",
j: "e",
J: "E",
k: "n",
K: "N",
};
forwardFactory.push(mapLists); forwardFactory.push(mapLists);
forwardFactory.map(mapLists); forwardFactory.map(mapLists);
vForwardFactory.push(vMapLists); // vForwardFactory.push(vMapLists);
vForwardFactory.map(vMapLists); // vForwardFactory.map(vMapLists);
// All other unmapped keys should be defined here // All other unmapped keys should be defined here
// TODO: Add more mouse click keymap // TODO: Add more mouse click keymap
@ -249,20 +225,22 @@ api.map("g/", "gU"); // Goto Root Domain
api.unmap("<space>"); // Leader Key api.unmap("<space>"); // Leader Key
forwardFactory.pull(mapLists); forwardFactory.pull(mapLists);
vForwardFactory.pull(vMapLists); // vForwardFactory.pull(vMapLists);
api.map("gH", "g/"); api.map("gH", "g/");
api.map("J", "d");
api.map("K", "e");
// #endregion // #endregion
// #region Omnibar NOTE: Dosn't work // #region Omnibar NOTE: Dosn't work
// api.cmap("<Ctrl-a>", "<Ctrl-ArrowUp>"); api.cmap("<Ctrl-a>", "<Ctrl-ArrowUp>");
// api.cmap("<Ctrl-e>", "<Ctrl-ArrowDown>"); api.cmap("<Ctrl-e>", "<Ctrl-ArrowDown>");
// api.cmap("<Ctrl-f>", "<ArrowRight>"); api.cmap("<Ctrl-f>", "<ArrowRight>");
// api.cmap("<Ctrl-b>", "<ArrowLeft>"); api.cmap("<Ctrl-b>", "<ArrowLeft>");
// api.cmap("<Alt-f>", "<Ctrl-ArrowRight>"); api.cmap("<Alt-f>", "<Ctrl-ArrowRight>");
// api.cmap("<Alt-b>", "<Ctrl-ArrowLeft>"); api.cmap("<Alt-b>", "<Ctrl-ArrowLeft>");
// api.cmap("<Ctrl-h>", "<Backspace>"); api.cmap("<Ctrl-h>", "<Backspace>");
// api.cmap("<Ctrl-d>", "<Delete>"); api.cmap("<Ctrl-d>", "<Delete>");
// #endregion // #endregion
// #region Search Alias // #region Search Alias
@ -298,6 +276,7 @@ const searchAliases = [
["gg", "Google", "https://www.google.com/search?q="], ["gg", "Google", "https://www.google.com/search?q="],
["mc", "Metacritic", "https://www.metacritic.com/search/"], ["mc", "Metacritic", "https://www.metacritic.com/search/"],
["nx", "NixPackages", "https://search.nixos.org/packages?query="], ["nx", "NixPackages", "https://search.nixos.org/packages?query="],
["no", "NixOptions", "https://search.nixos.org/options?query="],
["ng", "NuGet", "https://www.nuget.org/packages?q="], ["ng", "NuGet", "https://www.nuget.org/packages?q="],
["np", "npm", "https://www.npmjs.com/search?q="], ["np", "npm", "https://www.npmjs.com/search?q="],
["pa", "Pacman", "https://archlinux.org/packages/?q="], ["pa", "Pacman", "https://archlinux.org/packages/?q="],
@ -341,9 +320,9 @@ mapkey("yY", "yank link without parameter", function () {
Clipboard.write(url.origin + url.pathname); Clipboard.write(url.origin + url.pathname);
}); });
unmap("yma") unmap("yma");
unmap("ymc") unmap("ymc");
unmap("ymv") unmap("ymv");
mapkey("ym", "yank link as markdown", function () { mapkey("ym", "yank link as markdown", function () {
const url = new URL(window.location.href); const url = new URL(window.location.href);
@ -602,7 +581,7 @@ mapkey(
function () { function () {
const url = new URL(window.location.href); const url = new URL(window.location.href);
var owner, repo; var owner, repo;
owner, (repo = url.pathname.split("/").slice(1, 3)); (owner, (repo = url.pathname.split("/").slice(1, 3)));
window.location.href = gh.repoLink(owner, repo); window.location.href = gh.repoLink(owner, repo);
}, },
{ domain: /raw.githubusercontent.com/ }, { domain: /raw.githubusercontent.com/ },
@ -613,7 +592,7 @@ mapkey(
function () { function () {
const url = new URL(window.location.href); const url = new URL(window.location.href);
var owner, repo; var owner, repo;
owner, (repo = url.pathname.split("/").slice(1, 3)); (owner, (repo = url.pathname.split("/").slice(1, 3)));
tabOpenLink(gh.repoLink(owner, repo)); tabOpenLink(gh.repoLink(owner, repo));
}, },
{ domain: /raw.githubusercontent.com/ }, { domain: /raw.githubusercontent.com/ },
@ -926,103 +905,13 @@ mapkey(
// #region ACE Editor // #region ACE Editor
addVimMapKey( addVimMapKey(
// Navigation
{
keys: "k",
type: "motion",
motion: "findNext",
motionArgs: { forward: true, toJumplist: true },
},
{
keys: "K",
type: "motion",
motion: "findNext",
motionArgs: { forward: false, toJumplist: true },
},
// Word movement
{
keys: "j",
type: "motion",
motion: "moveByWords",
motionArgs: { forward: true, wordEnd: true, inclusive: true },
},
{
keys: "J",
type: "motion",
motion: "moveByWords",
motionArgs: {
forward: true,
wordEnd: true,
bigWord: true,
inclusive: true,
},
},
// Insert mode entries
{
keys: "l",
type: "action",
action: "enterInsertMode",
isEdit: true,
actionArgs: { insertAt: "inplace" },
context: "normal",
},
{
keys: "gl",
type: "action",
action: "enterInsertMode",
isEdit: true,
actionArgs: { insertAt: "lastEdit" },
context: "normal",
},
{
keys: "L",
type: "action",
action: "enterInsertMode",
isEdit: true,
actionArgs: { insertAt: "firstNonBlank" },
context: "normal",
},
{
keys: "gL",
type: "action",
action: "enterInsertMode",
isEdit: true,
actionArgs: { insertAt: "bol" },
context: "normal",
},
{
keys: "L",
type: "action",
action: "enterInsertMode",
isEdit: true,
actionArgs: { insertAt: "startOfSelectedArea" },
context: "visual",
},
{
keys: "n",
type: "motion",
motion: "moveByLines",
motionArgs: { forward: true, linewise: true },
},
{
keys: "e",
type: "motion",
motion: "moveByLines",
motionArgs: { forward: false, linewise: true },
},
{
keys: "i",
type: "motion",
motion: "moveByCharacters",
motionArgs: { forward: true },
},
{ {
keys: "H", keys: "H",
type: "keyToKey", type: "keyToKey",
toKeys: "^", toKeys: "^",
}, },
{ {
keys: "I", keys: "L",
type: "keyToKey", type: "keyToKey",
toKeys: "$", toKeys: "$",
}, },
@ -1036,5 +925,5 @@ addVimMapKey(
// #endregion // #endregion
// #region Hints // #region Hints
api.Hints.setCharacters("qwfpgarstdcv"); // Left-hand keys api.Hints.setCharacters("qwertasdfgzx"); // Left-hand keys
// #endregion // #endregion

View file

@ -14,7 +14,7 @@
../../modules/nixos/desktop/laptop.nix ../../modules/nixos/desktop/laptop.nix
# hardware drivers # hardware drivers
../../modules/nixos/hardware/nvidia.nix ../../modules/nixos/hardware/nvidia-disable.nix
# udev rules # udev rules
../../modules/nixos/hardware/udev/basys3.nix ../../modules/nixos/hardware/udev/basys3.nix