This commit is contained in:
whoami 2025-01-15 16:24:39 +00:00
commit 61d3539d2a
108 changed files with 4775 additions and 1760 deletions

View file

@ -1,7 +1,6 @@
// Paste this into surfingkeys advanced settings
// or use:
// Load settings from: https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/tools/browser/surfingkeys.js
// TODO: Visual Mode
// #region Example
/** Examples
@ -23,406 +22,458 @@ api.unmap('<ctrl-i>');
// Settings
settings.language = "zh-CN";
settings.showModeStatus = false;
// Keymap, reference https://github.com/texiwustion/colemak_config_for_surfingkeys/tree/main
// #region Helper
const {
aceVimMap,
addVimMapKey,
mapkey,
imap,
imapkey,
getClickableElements,
vmapkey,
map,
unmap,
cmap,
addSearchAlias,
removeSearchAlias,
tabOpenLink,
readText,
Clipboard,
Front,
Hints,
Visual,
RUNTIME,
} = api;
// Keymap, reference https://github.com/texiwustion/colemak_config_for_surfingkeys/tree/main
const forward = {
add: function (key) { // 转发即将被 unmap 的键
return api.map(`for${key}`, key)
add: function (key) {
// 转发即将被 unmap 的键
return api.map(`for${key}`, key);
},
cancel: function (key) { // 删除转发生成的键
api.unmap(`for${key}`)
api.unmap(key)
cancel: function (key) {
// 删除转发生成的键
api.unmap(`for${key}`);
api.unmap(key);
},
use: function (key) {
return `for${key}`
}
}
return `for${key}`;
},
};
const colemak = {
forward: function (key) { // 转发即将被 unmap 的键
api.map(key, `col${key}`)
api.unmap(`col${key}`)
forward: function (key) {
// 转发即将被 unmap 的键
api.map(key, `col${key}`);
api.unmap(`col${key}`);
},
use: function (key) {
return `col${key}`
return `col${key}`;
},
map: function (a, b) {
api.map(colemak.use(a), forward.use(b))
}
}
api.map(colemak.use(a), forward.use(b));
},
};
const vForward = {
add: function (key) {
// 转发即将被 unmap 的键
return api.vmap(`vfor${key}`, key);
},
cancel: function (key) {
// 删除转发生成的键
api.vunmap(`vfor${key}`);
api.vunmap(key);
},
use: function (key) {
return `vfor${key}`;
},
};
const vColemak = {
forward: function (key) {
// 转发即将被 unmap 的键
api.vmap(key, `vcol${key}`);
api.vunmap(`vcol${key}`);
},
use: function (key) {
return `vcol${key}`;
},
map: function (a, b) {
api.vmap(vColemak.use(a), vForward.use(b));
},
};
const forwardFactory = {
push: function (mapLists) { // forward original keys
push: function (mapLists) {
// forward original keys
for (let key in mapLists) {
forward.add(mapLists[key])
forward.add(mapLists[key]);
}
},
map: function (mapLists) {
for (let key in mapLists) {
colemak.map(key, mapLists[key])
colemak.map(key, mapLists[key]);
}
},
pull: function (mapLists) {
for (let key in mapLists) {
forward.cancel(mapLists[key])
forward.cancel(mapLists[key]);
}
for (let key in mapLists) {
colemak.forward(key)
colemak.forward(key);
}
}
}
},
};
const vForwardFactory = {
push: function (mapLists) {
// forward original keys
for (let key in mapLists) {
vForward.add(mapLists[key]);
}
},
map: function (mapLists) {
for (let key in mapLists) {
vColemak.map(key, mapLists[key]);
}
},
pull: function (mapLists) {
for (let key in mapLists) {
vForward.cancel(mapLists[key]);
}
for (let key in mapLists) {
vColemak.forward(key);
}
},
};
const parseSearchResponse = function (response) {
const res = JSON.parse(response.text);
return res.map((r) => r.phrase);
};
const _addSearchAlias = function (
alias,
name,
searchUrl,
acUrl = "https://duckduckgo.com/ac/?q=",
searchPrefix = "s",
parseResponse = parseSearchResponse,
) {
api.addSearchAlias(
alias,
name,
searchUrl,
searchPrefix,
acUrl,
parseResponse,
);
};
// #endregion
// #region Keymap
const mapLists = {
/// scroll page
// Arrow
'n': 'j',
'e': 'k',
'i': 'l',
n: "j",
e: "k",
i: "l",
// l <-> i
'l': 'i',
'L': 'I',
l: "i",
L: "I",
// k <-> n
'k': 'n',
'K': 'N',
k: "n",
K: "N",
// j <-> e
'j': 'e',
j: "e",
// PrevTab < H - I > NextTab
'H': 'E',
'I': 'R',
H: "E",
I: "R",
// E,N -> Up/Down HalfPage
'N': 'd',
'E': 'e',
N: "d",
E: "e",
// F -> Open Link in New Tab
'F': 'af',
F: "af",
// oH -> Tab History
'oH': 'H',
oH: "H",
// gh/gi -> Prev/Next History
'gh': 'S',
'gi': 'D',
gh: "S",
gi: "D",
// t -> Open Link in New Tab
't': 'gf',
t: "gf",
// 缩放
'zu': 'zi',
'zo': 'ze',
'zz': 'zr',
}
zu: "zi",
zo: "ze",
zz: "zr",
};
const vmapLists = {
'n': 'j',
'N': 'J',
'e': 'k',
'E': 'K',
'i': 'l',
'I': 'L',
'j': 'e',
'J': 'E',
'k': 'n',
'K': 'N',
}
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.map(mapLists)
forwardFactory.push(mapLists);
forwardFactory.map(mapLists);
vForwardFactory.push(vMapLists);
vForwardFactory.map(vMapLists);
// 鼠标点击
api.unmap('gi')
api.unmap('[[')
api.unmap(']]')
api.unmap(';m')
api.unmap(';fs')
api.unmap('O')
api.unmap('C')
api.map('g/', 'gU') // Goto Root Domain
forwardFactory.pull(mapLists)
api.unmap("gi");
api.unmap("[[");
api.unmap("]]");
api.unmap(";m");
api.unmap(";fs");
api.unmap("O");
api.unmap("C");
api.map("g/", "gU"); // Goto Root Domain
// p to site-specific
api.unmap("p");
api.unmap("<space>"); // Leader Key
forwardFactory.pull(mapLists);
vForwardFactory.pull(vMapLists);
// #endregion
// #region Search Alias
api.addSearchAlias('f', 'Felo', 'https://felo.ai/search?q=', 's', 'https://duckduckgo.com/ac/?q=', function (response) {
var res = JSON.parse(response.text);
return res.map(function (r) {
return r.phrase;
});
});
api.addSearchAlias('p', 'Perplexity', 'https://www.perplexity.ai/?q=', 's', 'https://duckduckgo.com/ac/?q=', function (response) {
var res = JSON.parse(response.text);
return res.map(function (r) {
return r.phrase;
});
});
api.addSearchAlias('r', 'Raindrop', 'https://app.raindrop.io/my/0/', 's', 'https://duckduckgo.com/ac/?q=', function (response) {
var res = JSON.parse(response.text);
return res.map(function (r) {
return r.phrase;
});
});
api.addSearchAlias('c', 'ChatGPT', 'https://chatgpt.com/?q=', 's', 'https://duckduckgo.com/ac/?q=', function (response) {
var res = JSON.parse(response.text);
return res.map(function (r) {
return r.phrase;
});
});
removeSearchAlias("s"); // StackOverflow
removeSearchAlias("d"); // DuckDuckGo
removeSearchAlias("g"); // Google
removeSearchAlias("b"); // Baidu
removeSearchAlias("w"); // Bing
removeSearchAlias("y"); // YouTube
/// Common
_addSearchAlias("dd", "DuckDuckGo", "https://duckduckgo.com/?q=");
_addSearchAlias("gg", "Google", "https://www.google.com/search?q=");
_addSearchAlias("bd", "Baidu", "https://www.baidu.com/s?wd=");
_addSearchAlias("bi", "Bing", "https://www.bing.com/search?q=");
_addSearchAlias(
"wk",
"Wikipedia",
"https://en.wikipedia.org/w/index.php?title=Special:Search&search=",
);
_addSearchAlias("re", "Reddit", "https://www.reddit.com/search?q=");
_addSearchAlias("st", "Steam", "https://store.steampowered.com/search/?term=");
_addSearchAlias(
"ud",
"UrbanDictionary",
"https://www.urbandictionary.com/define.php?term=",
);
_addSearchAlias("tw", "X", "https://twitter.com/search?q=");
_addSearchAlias("de", "Thesaurus", "https://www.onelook.com/?w=");
_addSearchAlias(
"ww",
"WantWords",
"https://www.shenyandayi.com/wantWordsResult?lang=zh&query=",
);
/// AI Search
_addSearchAlias("fe", "Felo", "https://felo.ai/search?q=");
_addSearchAlias("pp", "Perplexity", "https://www.perplexity.ai/?q=");
_addSearchAlias("cg", "ChatGPT", "https://chat.openai.com/?q=");
_addSearchAlias("mc", "Metacritic", "https://www.metacritic.com/search/");
/// EECS Related
_addSearchAlias(
"gh",
"GitHub",
"https://github.com/search?type=repositories&q=",
);
_addSearchAlias("so", "StackOverflow", "https://stackoverflow.com/search?q=");
_addSearchAlias("se", "StackExchange", "https://stackexchange.com/search?q=");
_addSearchAlias(
"aw",
"ArchWiki",
"https://wiki.archlinux.org/index.php?search=",
);
_addSearchAlias("wa", "WolframAlpha", "https://www.wolframalpha.com/input/?i=");
_addSearchAlias("eb", "ebay", "https://www.ebay.co.uk/sch/i.html?kw=");
// Programming language packages
_addSearchAlias("py", "pypi", "https://pypi.org/search/?q=");
_addSearchAlias("ng", "NuGet", "https://www.nuget.org/packages?q=");
_addSearchAlias("np", "npm", "https://www.npmjs.com/search?q=");
// Package Manager Search
_addSearchAlias("wg", "winget", "https://winget.ragerworks.com/search/all/");
_addSearchAlias("sc", "Scoop", "https://scoop.sh/#/apps?q=");
_addSearchAlias("br", "HomeBrew", "https://duckduckgo.com/?q=!brew ");
_addSearchAlias("au", "AUR", "https://aur.archlinux.org/packages?K=");
_addSearchAlias("pa", "Pacman", "https://archlinux.org/packages/?q=");
_addSearchAlias("ap", "APT", "https://packages.ubuntu.com/search?keywords=");
_addSearchAlias(
"a2",
"AlternativeTo",
"https://alternativeto.net/browse/search/?q=",
);
_addSearchAlias(
"cr",
"Chrome Web Store",
"https://chrome.google.com/webstore/search/",
);
/// Video
_addSearchAlias(
"yt",
"YouTube",
"https://www.youtube.com/results?search_query=",
);
_addSearchAlias("bl", "Bilibili", "https://search.bilibili.com/all?keyword=");
// #endregion
// #region Site-specific
// chatgpt.com
api.unmap('t', /chatgpt.com/);
api.mapkey('tn', 'New Chat', function () {
var btn = document.querySelector('div.no-draggable:nth-child(3) > span:nth-child(1) > button:nth-child(1)')
const chatgptNewChat = function () {
var btn = document.querySelector(
"div.no-draggable:nth-child(3) > span:nth-child(1) > button:nth-child(1)",
);
btn.click();
}, { domain: /chatgpt.com/ });
api.mapkey('ts', 'Start/Stop Generating', function () {
var btn = document.querySelector('button.h-8:nth-child(2)');
};
const chatgptStartStop = function () {
var btn = document.querySelector("button.h-8:nth-child(2)");
btn.click();
}, { domain: /chatgpt.com/ });
api.mapkey('ts', 'Start/Stop Generating', function () {
var btn = document.querySelector('button.h-8:nth-child(2)');
btn.click();
}, { domain: /chatgpt.com/ });
api.mapkey('S', 'Start/Stop Generating', function () {
var btn = document.querySelector('button.h-8:nth-child(2)');
btn.click();
}, { domain: /chatgpt.com/ });
};
api.unmap("t", /chatgpt.com/);
api.mapkey("tn", "New Chat", chatgptNewChat, { domain: /chatgpt.com/ });
api.mapkey("ts", "Start/Stop Generating", chatgptStartStop, {
domain: /chatgpt.com/,
});
api.mapkey("S", "Start/Stop Generating", chatgptStartStop, {
domain: /chatgpt.com/,
});
api.mapkey("an", "New Chat", chatgptNewChat, { domain: /chatgpt.com/ });
api.mapkey("as", "Start/Stop Generating", chatgptStartStop, {
domain: /chatgpt.com/,
});
//api.mapkey('tm', 'Toggle Model', function () {
// var btn = document.querySelector('#radix -\: r2i\:');
// btn.click();
//}, { domain: /chatgpt.com/ });
// perplexity.ai
api.unmap("<Ctrl-i>", /perplexity.ai/); // allows to use perplexity web keybindings
api.mapkey("aB", "Add Perplexity Bookmark", function () {
// button.border:nth-child(2)
var btn = document.querySelector("button.border:nth-child(2)");
btn.click();
});
// #endregion
// #region Theme
// reference to https://github.com/Foldex/surfingkeys-config
// api.Hints.style('border: solid 2px #4C566A; color:#A3BE8C; background: initial; background-color: #3B4252;');
// api.Hints.style("border: solid 2px #4C566A !important; padding: 1px !important; color: #E5E9F0 !important; background: #3B4252 !important;", "text");
// api.Visual.style('marks', 'background-color: #A3BE8C99;');
// api.Visual.style('cursor', 'background-color: #88C0D0;');
// settings.theme = `
// fg: #E5E9F0;
// bg: #3B4252;
// bg-dark: #2E3440;
// border: #4C566A;
// main-fg: #88C0D0;
// accent-fg: #A3BE8C;
// info-fg: #5E81AC;
// select: #4C566A;
// /* ---------- Generic ---------- */
// .sk_theme {
// background: var(--bg);
// color: var(--fg);
// background-color: var(--bg);
// border-color: var(--border);
// font-family: var(--font);
// font-size: var(--font-size);
// font-weight: var(--font-weight);
// }
// #region ACE Editor
addVimMapKey(
// Navigation
{
keys: "k",
type: "motion",
motion: "findNext",
motionArgs: { forward: true, toJumplist: true },
},
{
keys: "K",
type: "motion",
motion: "findNext",
motionArgs: { forward: false, toJumplist: true },
},
// input {
// font-family: var(--font);
// font-weight: var(--font-weight);
// }
// 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,
},
},
// .sk_theme tbody {
// color: var(--fg);
// }
// 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",
type: "keyToKey",
toKeys: "^",
},
{
keys: "I",
type: "keyToKey",
toKeys: "$",
},
{
keys: "Y",
type: "keyToKey",
toKeys: "y$",
},
);
// .sk_theme input {
// color: var(--fg);
// }
// /* Hints */
// #sk_hints .begin {
// color: var(--accent-fg) !important;
// }
// #sk_tabs .sk_tab {
// background: var(--bg-dark);
// border: 1px solid var(--border);
// }
// #sk_tabs .sk_tab_title {
// color: var(--fg);
// }
// #sk_tabs .sk_tab_url {
// color: var(--main-fg);
// }
// #sk_tabs .sk_tab_hint {
// background: var(--bg);
// border: 1px solid var(--border);
// color: var(--accent-fg);
// }
// .sk_theme #sk_frame {
// background: var(--bg);
// opacity: 0.2;
// color: var(--accent-fg);
// }
// /* ---------- Omnibar ---------- */
// /* Uncomment this and use settings.omnibarPosition = 'bottom' for Pentadactyl/Tridactyl style bottom bar */
// /* .sk_theme#sk_omnibar {
// width: 100%;
// left: 0;
// } */
// .sk_theme .title {
// color: var(--accent-fg);
// }
// .sk_theme .url {
// color: var(--main-fg);
// }
// .sk_theme .annotation {
// color: var(--accent-fg);
// }
// .sk_theme .omnibar_highlight {
// color: var(--accent-fg);
// }
// .sk_theme .omnibar_timestamp {
// color: var(--info-fg);
// }
// .sk_theme .omnibar_visitcount {
// color: var(--accent-fg);
// }
// .sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
// background: var(--bg-dark);
// }
// .sk_theme #sk_omnibarSearchResult ul li.focused {
// background: var(--border);
// }
// .sk_theme #sk_omnibarSearchArea {
// border-top-color: var(--border);
// border-bottom-color: var(--border);
// }
// .sk_theme #sk_omnibarSearchArea input,
// .sk_theme #sk_omnibarSearchArea span {
// font-size: var(--font-size);
// }
// .sk_theme .separator {
// color: var(--accent-fg);
// }
// /* ---------- Popup Notification Banner ---------- */
// #sk_banner {
// font-family: var(--font);
// font-size: var(--font-size);
// font-weight: var(--font-weight);
// background: var(--bg);
// border-color: var(--border);
// color: var(--fg);
// opacity: 0.9;
// }
// /* ---------- Popup Keys ---------- */
// #sk_keystroke {
// background-color: var(--bg);
// }
// .sk_theme kbd .candidates {
// color: var(--info-fg);
// }
// .sk_theme span.annotation {
// color: var(--accent-fg);
// }
// /* ---------- Popup Translation Bubble ---------- */
// #sk_bubble {
// background-color: var(--bg) !important;
// color: var(--fg) !important;
// border-color: var(--border) !important;
// }
// #sk_bubble * {
// color: var(--fg) !important;
// }
// #sk_bubble div.sk_arrow div:nth-of-type(1) {
// border-top-color: var(--border) !important;
// border-bottom-color: var(--border) !important;
// }
// #sk_bubble div.sk_arrow div:nth-of-type(2) {
// border-top-color: var(--bg) !important;
// border-bottom-color: var(--bg) !important;
// }
// /* ---------- Search ---------- */
// #sk_status,
// #sk_find {
// font-size: var(--font-size);
// border-color: var(--border);
// }
// .sk_theme kbd {
// background: var(--bg-dark);
// border-color: var(--border);
// box-shadow: none;
// color: var(--fg);
// }
// .sk_theme .feature_name span {
// color: var(--main-fg);
// }
// /* ---------- ACE Editor ---------- */
// #sk_editor {
// background: var(--bg-dark) !important;
// height: 50% !important;
// /* Remove this to restore the default editor size */
// }
// .ace_dialog-bottom {
// border-top: 1px solid var(--bg) !important;
// }
// .ace-chrome .ace_print-margin,
// .ace_gutter,
// .ace_gutter-cell,
// .ace_dialog {
// background: var(--bg) !important;
// }
// .ace-chrome {
// color: var(--fg) !important;
// }
// .ace_gutter,
// .ace_dialog {
// color: var(--fg) !important;
// }
// .ace_cursor {
// color: var(--fg) !important;
// }
// .normal-mode .ace_cursor {
// background-color: var(--fg) !important;
// border: var(--fg) !important;
// opacity: 0.7 !important;
// }
// .ace_marker-layer .ace_selection {
// background: var(--select) !important;
// }
// .ace_editor,
// .ace_dialog span,
// .ace_dialog input {
// font-family: var(--font);
// font-size: var(--font-size);
// font-weight: var(--font-weight);
// }`;
// click `Save` button to make above settings to take effect.</ctrl-i></ctrl-y>
// #endregion
// #region Hints
// #endregion

View file

@ -1,62 +0,0 @@
// ~\.config\fastfetch\config.jsonc
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
// "type": "auto",
"source": "Windows 7",
"padding": {
"top": 2,
"left": 1,
"right": 2
}
},
"general": {
"multithreading": true
},
"display": {
"separator": " ",
"key": {
"width": 10,
"paddingLeft": 2,
"type": "icon"
}
},
"modules": [
{
"type": "title",
"format": "{#1}───────────── {#}{user-name-colored}@{host-name-colored}"
},
{
"type": "colors",
"symbol": "diamond",
"paddingLeft": 15
},
"os",
"host",
"kernel",
"uptime",
{
"type": "packages"
},
"shell",
"display",
"de",
"wm",
"wmtheme",
"theme",
"icons",
"font",
"cursor",
"terminal",
"terminalfont",
"cpu",
"gpu",
"memory",
"swap",
"disk",
"localip",
"battery",
"poweradapter",
"locale"
]
}

View file

@ -31,6 +31,9 @@ else if test -d /home/linuxbrew/.linuxbrew/bin # Linux
set -gx PATH /home/linuxbrew/.linuxbrew/bin $PATH
end
if command -v brew > /dev/null
set -gx HOMEBREW_NO_ENV_HINTS
end
# Azure CLI
if command -v az > /dev/null
@ -102,6 +105,7 @@ if command -v gem > /dev/null
set -gx PATH $dir $PATH
end
end
set -gx PATH $HOME/.local/share/gem/ruby/3.3.0/bin $PATH
end
# Spacemacs
if command -v emacs > /dev/null
@ -135,3 +139,18 @@ if status is-interactive
set IPYTHONDIR $XDG_CONFIG_HOME/ipython
end
end
# Coursier: Scala dependency manager
if command -v coursier > /dev/null
set -gx PATH "$PATH:$XDG_DATA_HOME/coursier/bin"
end
# pnpm
set -gx PNPM_HOME "$XDG_DATA_HOME/pnpm"
if not string match -q -- $PNPM_HOME $PATH
set -gx PATH "$PNPM_HOME" $PATH
end
# pnpm end
test -d /opt/miniconda3 && source /opt/miniconda3/etc/fish/conf.d/conda.fish
test -f /opt/miniconda3/etc/fish/conf.d/conda.fish && source /opt/miniconda3/etc/fish/conf.d/conda.fish

View file

@ -69,4 +69,11 @@ if command -v pacman > /dev/null
abbr --add paci "sudo pacman -S"
abbr --add pacr "sudo pacman -R"
abbr --add pacu "sudo pacman -Syu"
abbr --add pacs "sudo pacman -Ss"
end
if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty"
abbr --add icat "kitten icat"
else if test "$TERM_PROGRAM" = "WezTerm"
abbr --add icat "wezterm imgcat"
end

View file

@ -25,4 +25,4 @@ bind -M default 'i' forward-char
bind -M default -m insert l repaint-mode
bind -M default -m insert L beginning-of-line repaint-mode
# TODO: Add more key bindings here
fzf --fish | source

View file

@ -8,6 +8,6 @@
# ln -sf $DOTFILES/tools/fish ~/.config/fish
if command -v starship > /dev/null
set -gx STARSHIP_CONFIG $DOTFILES/tools/starship/starship_fish.toml
set -gx STARSHIP_CONFIG "~/.dotfiles/tools/starship/starship_fish.toml"
starship init fish | source
end

View file

@ -16,9 +16,22 @@ if status is-interactive
# macOS Specific
abbr --add clip pbcopy
abbr --add paste pbpaste
# Use GNU Coreutils
alias cp=gcp
alias ln=gln
alias mkdir=gmkdir
alias mv=gmv
alias rm=grm
alias rmdir=grmdir
alias touch=gtouch
case "Linux"
# Linux Specific
case '*'
# Default / Fallback case
end
end
# bun
set --export BUN_INSTALL "$HOME/.bun"
set --export PATH $BUN_INSTALL/bin $PATH

View file

@ -1 +0,0 @@
lazy-lock.json

View file

@ -5,24 +5,8 @@
@Date 2024-11-27
@Description neovim
]]
-- 针对特定文件类型设置快捷键
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown", -- 指定文件类型
callback = function()
vim.api.nvim_buf_set_keymap(0, "v", "`", "c`<C-r>\"`<Esc>", { noremap = true, silent = true, desc = "Wrap selection with backticks" })
end,
})
-- 加载配置
require("config.options")
-- 加载键位映射
require("config.keymaps")
-- 加载插件
require("config.plugins")
-- 加载主题
require("config.colorscheme")
-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
require("config.keymaps")

47
tools/nvim/lazy-lock.json Normal file
View file

@ -0,0 +1,47 @@
{
"LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" },
"alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" },
"auto-session": { "branch": "main", "commit": "021b64ed7d4ac68a37be3ad28d8e1cba5bec582c" },
"betterTerm.nvim": { "branch": "main", "commit": "6f03af3a1ed4d054ecbcb0aa8266ddaf610aa657" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"code_runner.nvim": { "branch": "main", "commit": "65218f8f646fe61e506090522df357539642ae83" },
"conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" },
"copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"gitsigns.nvim": { "branch": "main", "commit": "76d88f3b584e1f83b2aa51663a32cc6ee8d97eff" },
"hover.nvim": { "branch": "main", "commit": "140c4d0ae9397b76baa46b87c574f5377de09309" },
"kanagawa.nvim": { "branch": "master", "commit": "988082eb00b845e4afbcaa4fd8e903da8a3ab3b9" },
"lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"luasnip-latex-snippets.nvim": { "branch": "main", "commit": "cab134611eb755abe9ba95f5d86969f5cece448d" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" },
"nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" },
"nvim-lspconfig": { "branch": "master", "commit": "339ccc81e08793c3af9b83882a6ebd90c9cc0d3b" },
"nvim-tree.lua": { "branch": "master", "commit": "d529a99f88e0dff02e0aa275db2f595cd252a2c8" },
"nvim-treesitter": { "branch": "master", "commit": "f0c928dbe93533b7e35894a8f957f40150d1f663" },
"nvim-treesitter-context": { "branch": "master", "commit": "d0dd7ce5a9d0be1f28086e818e52fdc5c78975df" },
"nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" },
"obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" },
"onedarkpro.nvim": { "branch": "main", "commit": "0feb5f55dd777352f2dddd7478dd13d050864ee3" },
"orgmode": { "branch": "master", "commit": "4e4a14a7dd613953eddacbc0f0ff1583817d7de1" },
"plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" },
"project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" },
"render-markdown.nvim": { "branch": "main", "commit": "f0eb5893556200e9f945c0f0ea3c83bbd20dd963" },
"telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" },
"vim-floaterm": { "branch": "master", "commit": "4e28c8dd0271e10a5f55142fb6fe9b1599ee6160" },
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
"vim-just": { "branch": "main", "commit": "ed67f198e981f555c0f9e9ed5b69b4b06543a9e1" },
"vim-wakatime": { "branch": "master", "commit": "cf51327a9e08935569614d1cb24e779ee9f45519" },
"vimtex": { "branch": "master", "commit": "c8412f444bfaf447981242d685c40e45b1c96b82" },
"which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" },
"winbar.nvim": { "branch": "main", "commit": "13739fdb31be51a1000486189662596f07a59a31" },
"yanky.nvim": { "branch": "main", "commit": "f9b905994cccf3c55f41af3a0a1f4c76c844e411" }
}

View file

@ -1 +1 @@
vim.cmd.colorscheme("catppuccin")
vim.cmd.colorscheme("kanagawa")

View file

@ -1,2 +1 @@
require("keymaps")

View file

@ -25,6 +25,7 @@ opt.linebreak = true
-- Indentation
opt.expandtab = true
opt.shiftwidth = 4
opt.tabstop = 4
opt.shiftround = true
-- Case
@ -36,8 +37,10 @@ opt.cursorline = true
opt.termguicolors = true
-- Fold
opt.foldlevel = 99
opt.foldmethod = "expr"
opt.foldexpr = "nvim_treesitter#foldexpr()"
opt.foldlevel = 99
opt.foldlevelstart = 1
-- Statusline
opt.laststatus = 0
@ -50,3 +53,5 @@ opt.scrolloff = 5
opt.sidescrolloff = 10
opt.conceallevel = 2
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"

View file

@ -3,21 +3,15 @@
--- for available server and name
local M = {}
M.servers = {
"arduino_language_server", -- Arduino
"bashls", -- Bash
"clangd", -- C/C++
-- "cmake", -- CMake
"eslint", -- JavaScript
"gopls", -- Go
"html", -- HTML
"julials", -- Julia
"lua_ls", -- Lua
"omnisharp", -- C# & F#
"powershell_es", -- PowerShell
"pyright", -- Python
"rust_analyzer", -- Rust
"taplo", -- TOML
"vimls", -- vimscript
"clangd", -- C/C++
-- "cmake", -- CMake
"eslint", -- JavaScript
"html", -- HTML
"lua_ls", -- Lua
"omnisharp", -- C# & F#
"powershell_es", -- PowerShell
"pyright", -- Python
"vimls", -- vimscript
}
M.server_config = {

View file

@ -1,20 +1,74 @@
local mode_arrow = { "n", "v", "o", "s", "x" }
local mode_arrow = { "n", "v", "s", "x" }
local keymaps_basic = { -- Modification of Original Keymap - Colemak
{ mode = mode_arrow, keys = "n", cmd = "j" },
{ mode = mode_arrow, keys = "e", cmd = "k" },
{ mode = mode_arrow, keys = "i", cmd = "l" },
{ keys = "H", cmd = ":bprevious<CR>" },
{ keys = "N", cmd = "J" },
{ keys = "E", cmd = "K" },
{ keys = "I", cmd = ":bnext<CR>" },
{ keys = "l", cmd = "i" },
{ keys = "L", cmd = "I" },
{ keys = "k", cmd = "n" },
{ keys = "K", cmd = "N" },
{ keys = "j", cmd = "e" },
{ keys = "J", cmd = "E" },
{ keys = "Y", cmd = "y$"},
-- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L8
{
mode = mode_arrow,
keys = "n",
cmd = "v:count == 0 ? 'gj' : 'j'",
opts = { desc = "Down", expr = true, silent = true },
},
{
mode = mode_arrow,
keys = "<Down>",
cmd = "v:count == 0 ? 'gj' : 'j'",
opts = { desc = "Down", expr = true, silent = true },
},
{
mode = mode_arrow,
keys = "e",
cmd = "v:count == 0 ? 'gk' : 'k'",
opts = { desc = "Up", expr = true, silent = true },
},
{
mode = mode_arrow,
keys = "<Up>",
cmd = "v:count == 0 ? 'gk' : 'k'",
opts = { desc = "Up", expr = true, silent = true },
},
{
mode = "o",
keys = "n",
cmd = "j",
opts = { desc = "Down", silent = true },
},
{
mode = "o",
keys = "<Down>",
cmd = "j",
opts = { desc = "Down", silent = true },
},
{
mode = "o",
keys = "e",
cmd = "k",
opts = { desc = "Up", silent = true },
},
{
mode = "o",
keys = "<Up>",
cmd = "k",
opts = { desc = "Up", silent = true },
},
{ mode = mode_arrow, keys = "h", cmd = "h", opts = { desc = "Left", silent = true } },
{ mode = mode_arrow, keys = "i", cmd = "l", opts = { desc = "Right", silent = true } },
{ keys = "H", cmd = ":bprevious<CR>", opts = { desc = "Previous Buffer" } },
{ keys = "I", cmd = ":bnext<CR>", opts = { desc = "Next Buffer" } },
{ keys = "N", cmd = "5k", opts = { desc = "Up 5 Lines" } },
{ keys = "E", cmd = "5j", 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" } },
-- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L60
{ keys = "<Esc>", cmd = "<Cmd>nohlsearch<Bar>diffupdate<CR>", opts = { desc = "Clear Search Highlight" } },
}
return keymaps_basic

View file

@ -0,0 +1,55 @@
local M = {}
--- buffer that doesn't act as an editor or common buffer.
--- Use `q` to close the buffer.
local tmp_buf = {
"qf", -- quickfix
"crunner", -- code runner
}
local term_buf = {
"floaterm",
"term",
}
local term_mode = {
"n",
"i",
"t",
}
local term_keymaps = {
{ mode = term_mode, keys = "<C-q>", cmd = ":FloatermToggle", desc = "Exit terminal mode" },
}
M.tmp_buf_keymaps = {
{ mode = "n", keys = "q", cmd = "<Cmd>q<CR>", desc = "Close buffer" },
}
for _, buf in ipairs(tmp_buf) do
vim.api.nvim_create_autocmd("FileType", {
pattern = buf,
callback = function()
for _, map in ipairs(M.tmp_buf_keymaps) do
local opts = vim.tbl_extend("force", { buffer = 0 }, map.opts or {})
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
end
end,
})
end
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*",
callback = function()
-- 检查当前 buffer 的 buftype
local buftype = vim.bo.buftype
if buftype == "terminal" then
for _, map in ipairs(term_keymaps) do
local opts = vim.tbl_extend("force", { buffer = 0 }, map.opts or {})
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
end
end
end,
})
return M

View file

@ -1,52 +1,48 @@
local M = {}
local global_default_opts = { noremap = true, silent = true }
local global_default_mode = { "n" }
-- local mode_arrow = { "n", "v", "o", "s", "x" }
local keymaps_user_command = require("keymaps.user-command")
local utils = require("keymaps.utils")
local function set_keymaps(maps, default_opts, default_mode)
for _, map in ipairs(maps) do
local opts = vim.tbl_extend("force", default_opts, map.opts or {})
local mode = map.mode or default_mode
vim.keymap.set(mode, map.keys, map.cmd, opts)
end
end
local keymaps_basic = require("keymaps.basic")
local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global
local keymaps_leader = require("keymaps.leaders")
set_keymaps(keymaps_basic, global_default_opts, global_default_mode)
set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode)
set_keymaps(keymaps_leader, global_default_opts, global_default_mode)
local keymaps_general = vim.tbl_extend("force", {}, require("keymaps.leaders"), require("keymaps.lspkeys"))
-- Tables cannot be merged since `mode` are set in some keymaps of `keymaps_basic`
local keymaps_basic = require("keymaps.basic")
local keymaps_buffer = require("keymaps.buffer")
-- local keymaps_leader = require("keymaps.leaders")
-- local keymaps_lsp = require("keymaps.lspkeys")
utils.set_keymaps(keymaps_general)
utils.set_keymaps(keymaps_basic)
utils.set_keymaps(keymaps_nvim_tree_general)
utils.set_keymaps(keymaps_buffer)
M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin
--- `map` default for `cmp.mapping`
function M.cmp_nvim_keymaps(map)
return {
{ keys = "<C-n>", cmd = map.select_next_item(), desc = "Select next completion item" },
{ keys = "<C-p>", cmd = map.select_prev_item(), desc = "Select previous completion item" },
{ keys = "<C-y>", cmd = map.confirm({ select = true }), desc = "Confirm completion" },
{ keys = "<Tab>", cmd = map.confirm({ select = true }), desc = "Confirm completion" },
{ keys = "<C-Space>", cmd = map.complete(), desc = "Trigger completion" },
{ keys = "<C-e>", cmd = map.abort(), desc = "Abort completion" },
{ keys = "<C-n>", cmd = map.select_next_item(), opts = { desc = "Select next completion item" } },
{ keys = "<C-p>", cmd = map.select_prev_item(), opts = { desc = "Select previous completion item" } },
{ keys = "<C-y>", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } },
{ keys = "<Tab>", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } },
{ keys = "<C-Space>", cmd = map.complete(), opts = { desc = "Trigger completion" } },
{ keys = "<C-e>", cmd = map.abort(), opts = { desc = "Abort completion" } },
}
end
local function set_markdown_keymaps(bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("v", "`", "c`<C-r>\"`<Esc>", opts)
end
-- local function set_markdown_keymaps(bufnr)
-- local opts = { noremap = true, silent = true, buffer = bufnr }
-- vim.keymap.set("v", "`", 'c`<C-r>"`<Esc>', opts)
-- end
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
set_markdown_keymaps(0)
end,
})
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = "markdown",
-- callback = function()
-- set_markdown_keymaps(0)
-- end,
-- })
require("keymaps.language")
-- which-key.nvim
require("keymaps.which")
return M

View file

@ -1,6 +1,5 @@
local M = {}
-- Markdown
local function set_markdown_keymaps(bufnr)
@ -11,20 +10,19 @@ local function set_markdown_keymaps(bufnr)
end
end
M.markdown = {
{ mode = "v", keys = "`", cmd = "c`<Esc>pi`<Esc>" , desc = "Wrap selection in ` for inline code" },
{ mode = "v", keys = "*", cmd = "c**<Esc>pi**<Esc>" , desc = "Wrap selection in ** for bold" },
{ mode = "v", keys = "_", cmd = "c*<Esc>pi*<Esc>" , desc = "Wrap selection in * for italic" },
{ mode = "v", keys = "`", cmd = "c`<Esc>pi`<Esc>", desc = "Wrap selection in ` for inline code" },
{ mode = "v", keys = "*", cmd = "c**<Esc>pi**<Esc>", desc = "Wrap selection in ** for bold" },
{ mode = "v", keys = "_", cmd = "c*<Esc>pi*<Esc>", desc = "Wrap selection in * for italic" },
}
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
set_markdown_keymaps(0)
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end,
pattern = "markdown",
callback = function()
set_markdown_keymaps(0)
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end,
})
return M

View file

@ -1,79 +1,135 @@
local M = {}
local leader_general = {
{ keys = "<space>", cmd = ":Telescope find_files<CR>", desc = "Find Files" },
{ keys = "/", cmd = ":Telescope live_grep<CR>", desc = "Grep Files" },
}
for _,map in ipairs(leader_general) do
map.keys = "<leader>" .. map.keys
table.insert(M, map)
local formatFx = function()
require("conform").format({ async = true })
end
local leader_q = { -- leader q: Quit
{ keys = "q", cmd = ":q<CR>", desc = "Quit" },
{ keys = "Q", cmd = ":qa!<CR>", desc = "Force Quit" },
{ keys = "w", cmd = ":wq<CR>", desc = "Write and Quit" },
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", desc = "Write all and Force Quit" },
}
local renameCurrentBuffer = function()
local old_name = vim.fn.expand("%:p")
local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/")
local leader_w = { -- leader w: Windows Management
{ keys = "h", cmd = "<C-w>h", desc = "Left Window" },
{ keys = "n", cmd = "<C-w>j", desc = "Down Window" },
{ keys = "e", cmd = "<C-w>k", desc = "Up Window" },
{ keys = "i", cmd = "<C-w>l", desc = "Right Window" },
{ keys = "-", cmd = ":split<CR>", desc = "Split to down" },
{ keys = "|", cmd = ":vsplit<CR>", desc = "Split to right" },
{ keys = "c", cmd = "<C-w>c", desc = "Close Window" },
{ keys = "o", cmd = "<C-w>o", desc = "Close Other Windows" },
{ keys = "r", cmd = "<C-w>r", desc = "Rotate Windows" },
{ keys = "R", cmd = "<C-w>R", desc = "Reverse Rotate Windows" },
{ keys = "t", cmd = "<C-w>T", desc = "Move Window to New Tab" },
{ keys = "H", cmd = ":vertical resize -5<CR>", desc = "Decrease Window Height" },
{ keys = "N", cmd = ":resize +5<CR>", desc = "Increase Window Height" },
{ keys = "E", cmd = ":vertical resize +5<CR>", desc = "Increase Window Width" },
{ keys = "I", cmd = ":resize -5<CR>", desc = "Decrease Window Width" },
}
if new_name == "" then
print("No new name provided")
return
elseif new_name == old_name then
return
end
local leader_f = { -- leader f: Files/Find
{ keys = "f", cmd = ":Telescope fd<CR>", desc = "Find Files"},
{ keys = "s", cmd = ":Telescope live_grep<CR>", desc = "Grep Files"},
{ keys = "b", cmd = ":Telescope buffers<CR>", desc = "List Buffers"},
{ keys = "e", cmd = ":NvimTreeToggle<CR>", desc = "Toggle File Explorer" },
}
vim.cmd("write")
local leader_p = { -- leader p: Project
}
local success, err = os.rename(old_name, new_name)
if not success then
print("Error renaming file: " .. err)
return
end
local leader_b = { -- leader b: Buffer
{ keys = "d", cmd = ":bdelete<CR>", desc = "Delete Buffer" },
{ keys = "h", cmd = ":bprevious<CR>", desc = "Previous Buffer" },
{ keys = "i", cmd = ":bnext<CR>", desc = "Next Buffer" },
{ keys = "H", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "I", cmd = ":blast<CR>", desc = "Last Buffer" },
{ keys = "0", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "^", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "$", cmd = ":blast<CR>", desc = "Last Buffer" },
}
for _, map in ipairs(leader_q) do
map.keys = "<leader>q" .. map.keys
table.insert(M, map)
vim.cmd("edit " .. new_name)
vim.cmd("bdelete " .. old_name)
end
for _, map in ipairs(leader_w) do
map.keys = "<leader>w" .. map.keys
table.insert(M, map)
-- 通用映射函数
local function apply_mappings(maps, prefix)
for _, map in ipairs(maps) do
local new_map = {
keys = prefix .. map.keys,
cmd = map.cmd,
opts = map.opts,
}
table.insert(M, new_map)
end
end
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})
for _, map in ipairs(leader_f) do
map.keys = "<leader>f" .. map.keys
table.insert(M, map)
end
local leader_mappings = {
general = {
{ keys = "<leader>", cmd = ":Telescope find_files<CR>", opts = { desc = "Find Files" } },
{ keys = "/", cmd = ":Telescope live_grep<CR>", opts = { desc = "Grep Files" } },
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
{ keys = "\\", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
{ keys = "<Tab>", cmd = "<Cmd>b#<CR>", opts = { desc = "Switch to last buffer" } },
{ keys = "!", cmd = ":FloatermToggle<CR>", opts = { desc = "" } },
},
b = { -- +buffer
{ keys = "a", cmd = ":Alpha<CR>", opts = { desc = "Dashboard" } },
{ keys = "b", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
{ keys = "d", cmd = ":bdelete<CR>", opts = { desc = "Delete Buffer" } },
{ keys = "h", cmd = ":bprevious<CR>", opts = { desc = "Previous Buffer" } },
{ keys = "i", cmd = ":bnext<CR>", opts = { desc = "Next Buffer" } },
{ keys = "H", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "I", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
{ keys = "0", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "^", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "$", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
-- { keys = "s", cmd = ":Telescope buffers<CR>", opts = { desc = "Search buffers" } },
},
c = { -- +code/compile
{ keys = "r", cmd = ":RunCode<CR>", opts = { desc = "Run code" } },
{ keys = "e", cmd = ":Telescope diagnostics<CR>", opts = { desc = "Navigate errors/warnings" } },
{ keys = "f", cmd = formatFx, opts = { desc = "Format buffer" } },
{ keys = "s", cmd = ":Telescope treesitter<CR>", opts = { desc = "Search symbols" } },
{ keys = "S", cmd = ":Telescope grep_string<CR>", opts = { desc = "Search current symbol" } },
},
f = { -- +file/find
{ keys = "f", cmd = ":Telescope fd<CR>", opts = { desc = "Find Files" } },
{ keys = "s", cmd = ":Telescope live_grep<CR>", opts = { desc = "Grep Files" } },
{ keys = "b", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
{ keys = "e", cmd = ":NvimTreeToggle<CR>", opts = { desc = "Toggle File Explorer" } },
{ keys = "t", cmd = ":FloatermToggle<CR>", opts = { desc = "toggle visibility of the float terminal" } },
{ keys = "T", cmd = ":FloatermNew<CR>", opts = { desc = "Spawn a float terminal" } },
{ keys = "h", cmd = ":Telescope oldfiles<CR>", opts = { desc = "Search history files" } },
{ keys = "c", cmd = ":Telescope find_files cwd=~/.config/nvim<CR>", opts = { desc = "Search Config" } },
{ keys = "o", cmd = ":!open %", opts = { desc = "Open file in default program" } },
{ keys = "R", cmd = renameCurrentBuffer, opts = { desc = "Rename current file" } },
},
p = { -- +project
{ keys = "p", cmd = ":Telescope projects<CR>", opts = { desc = "List all Projects" } },
{ keys = "g", cmd = ":Telescope projects<CR>", opts = { desc = "List all Git Projects" } },
{ keys = "s", cmd = ":Telescope session-lens<CR>", opts = { desc = "List all sessions" } },
},
q = { -- +quit
{ keys = "q", cmd = ":q<CR>", opts = { desc = "Quit" } },
{ keys = "Q", cmd = ":qa!<CR>", opts = { desc = "Force Quit" } },
{ keys = "w", cmd = ":wq<CR>", opts = { desc = "Write and Quit" } },
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", opts = { desc = "Write all and Force Quit" } },
},
t = { -- +toggle
{ keys = "f", cmd = ":NvimTreeToggle", opts = { desc = "Toggle File Explorer" } },
{ keys = "F", cmd = ":FormatToggle<CR>", opts = { desc = "Toggle autoformat-on-save" } },
{ keys = "t", cmd = ":FloatermToggle<CR>", opts = { desc = "toggle visibility of the float terminal" } },
},
u = { -- +ui
{ keys = "i", cmd = ":Telescope colorscheme<CR>", opts = { desc = "Change colorscheme" } },
},
w = { -- +window
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "c", cmd = "<C-w>c", opts = { desc = "Close Window" } },
{ keys = "o", cmd = "<C-w>o", opts = { desc = "Close Other Windows" } },
{ keys = "r", cmd = "<C-w>r", opts = { desc = "Rotate Windows" } },
{ keys = "R", cmd = "<C-w>R", opts = { desc = "Reverse Rotate Windows" } },
{ keys = "t", cmd = "<C-w>T", opts = { desc = "Move Window to New Tab" } },
{ keys = "H", cmd = ":vertical resize -5<CR>", opts = { desc = "Decrease Window Height" } },
{ keys = "N", cmd = ":resize +5<CR>", opts = { desc = "Increase Window Height" } },
{ keys = "E", cmd = ":vertical resize +5<CR>", opts = { desc = "Increase Window Width" } },
{ keys = "I", cmd = ":resize -5<CR>", opts = { desc = "Decrease Window Width" } },
},
}
for _, map in ipairs(leader_b) do
map.keys = "<leader>b" .. map.keys
table.insert(M, map)
for key, maps in pairs(leader_mappings) do
if key == "general" then
apply_mappings(maps, "<leader>")
else
apply_mappings(maps, "<leader>" .. key)
end
end
return M

View file

@ -0,0 +1,8 @@
local M = {
{ keys = "gd", cmd = vim.lsp.buf.definition, opts = { desc = "Goto Definition" } },
{ keys = "gD", cmd = vim.lsp.buf.declaration, opts = { desc = "Goto Declaration" } },
{ keys = "gr", cmd = vim.lsp.buf.references, opts = { desc = "Goto References" } },
{ keys = "gi", cmd = vim.lsp.buf.implementation, opts = { desc = "Goto Implementation" } },
}
return M

View file

@ -1,80 +1,84 @@
local M = {}
M.global = {
{ mode = "n", keys = "<leader>e", cmd = ":NvimTreeToggle<CR>" },
{ mode = "n", keys = "<leader>E", cmd = ":NvimTreeToggle<CR>" },
{ mode = "n", keys = "<A-0>", cmd = ":NvimTreeFocus<CR>" },
}
function M.plugin(api, opts)
-- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua`
return {
-- Toggle
{ keys = "<leader>e", cmd = ":NvimTreeToggle<CR>", opts = opts("Toggle") },
{ keys = "<leader>e", cmd = ":NvimTreeToggle<CR>", opts = opts("Toggle") },
-- Arrow 箭头 hnei
{ keys = "h", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "i", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "H", cmd = api.tree.toggle_hidden_filter, opts = opts("Toggle Dotfiles") },
{ keys = "N", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "E", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = "I", cmd = api.tree.toggle_gitignore_filter, opts = opts("Toggle GitIgnored") },
{ keys = "h", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "i", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "H", cmd = api.tree.toggle_hidden_filter, opts = opts("Toggle Dotfiles") },
{ keys = "N", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "E", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = "I", cmd = api.tree.toggle_gitignore_filter, opts = opts("Toggle GitIgnored") },
-- CONTROL KEYS 控制键
{ keys = "<BS>", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "<CR>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<Tab>", cmd = api.node.open.preview, opts = opts("Open Preview") },
{ keys = "<BS>", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "<CR>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<Tab>", cmd = api.node.open.preview, opts = opts("Open Preview") },
-- Alpha 字母键
{ keys = "a", cmd = api.fs.create, opts = opts("Create") },
{ keys = "A", cmd = api.fs.create, opts = opts("Create") },
{ keys = "bd", cmd = api.marks.bulk.delete, opts = opts("Delete Bookmarked") },
{ keys = "bt", cmd = api.marks.bulk.trash, opts = opts("Trash Bookmarked") },
{ keys = "bmv", cmd = api.marks.bulk.move, opts = opts("Move Bookmarked") },
{ keys = "B", cmd = api.tree.toggle_no_buffer_filter, opts = opts("Toggle Filter: No Buffer") },
{ keys = "c", cmd = api.fs.copy.node, opts = opts("Copy") },
{ keys = "C", cmd = api.fs.copy.filename, opts = opts("Copy") },
{ keys = "d", cmd = api.fs.remove, opts = opts("Delete") },
{ keys = "D", cmd = api.fs.trash, opts = opts("Trash") },
{ keys = "]e", cmd = api.node.navigate.diagnostics.next, opts = opts("Next Diagnostic") },
{ keys = "[e", cmd = api.node.navigate.diagnostics.prev, opts = opts("Prev Diagnostic") },
{ keys = "F", cmd = api.live_filter.clear, opts = opts("Live Filter: Clear") },
{ keys = "f", cmd = api.live_filter.start, opts = opts("Live Filter: Start") },
{ keys = "[g", cmd = api.node.navigate.git.prev, opts = opts("Prev Git") },
{ keys = "]g", cmd = api.node.navigate.git.next, opts = opts("Next Git") },
{ keys = "L", cmd = api.node.open.toggle_group_empty, opts = opts("Toggle Group Empty") },
{ keys = "M", cmd = api.tree.toggle_no_bookmark_filter, opts = opts("Toggle Filter: No Bookmark") },
{ keys = "m", cmd = api.marks.toggle, opts = opts("Toggle Bookmark") },
{ keys = "o", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "O", cmd = api.node.open.no_window_picker, opts = opts("Open: No Window Picker") },
{ keys = "p", cmd = api.fs.paste, opts = opts("Paste") },
{ keys = "P", cmd = api.node.navigate.parent, opts = opts("Parent Directory") },
{ keys = "q", cmd = api.tree.close, opts = opts("Close") },
{ keys = "r", cmd = api.fs.rename, opts = opts("Rename") },
{ keys = "R", cmd = api.tree.reload, opts = opts("Refresh") },
{ keys = "s", cmd = api.node.run.system, opts = opts("Run System") },
{ keys = "S", cmd = api.tree.search_node, opts = opts("Search") },
{ keys = "u", cmd = api.fs.rename_full, opts = opts("Rename: Full Path") },
{ keys = "U", cmd = api.tree.toggle_custom_filter, opts = opts("Toggle Filter: Hidden") },
{ keys = "W", cmd = api.tree.collapse_all, opts = opts("Collapse") },
{ keys = "x", cmd = api.fs.cut, opts = opts("Cut") },
{ keys = "y", cmd = api.fs.copy.relative_path, opts = opts("Copy Relative Path") },
{ keys = "Y", cmd = api.fs.copy.absolute_path, opts = opts("Copy Absolute Path") },
{ keys = "a", cmd = api.fs.create, opts = opts("Create") },
{ keys = "A", cmd = api.fs.create, opts = opts("Create") },
{ keys = "bd", cmd = api.marks.bulk.delete, opts = opts("Delete Bookmarked") },
{ keys = "bt", cmd = api.marks.bulk.trash, opts = opts("Trash Bookmarked") },
{ keys = "bmv", cmd = api.marks.bulk.move, opts = opts("Move Bookmarked") },
{ keys = "B", cmd = api.tree.toggle_no_buffer_filter, opts = opts("Toggle Filter: No Buffer") },
{ keys = "c", cmd = api.fs.copy.node, opts = opts("Copy") },
{ keys = "C", cmd = api.fs.copy.filename, opts = opts("Copy") },
{ keys = "d", cmd = api.fs.remove, opts = opts("Delete") },
{ keys = "D", cmd = api.fs.trash, opts = opts("Trash") },
{ keys = "]e", cmd = api.node.navigate.diagnostics.next, opts = opts("Next Diagnostic") },
{ keys = "[e", cmd = api.node.navigate.diagnostics.prev, opts = opts("Prev Diagnostic") },
{ keys = "F", cmd = api.live_filter.clear, opts = opts("Live Filter: Clear") },
{ keys = "f", cmd = api.live_filter.start, opts = opts("Live Filter: Start") },
{ keys = "[g", cmd = api.node.navigate.git.prev, opts = opts("Prev Git") },
{ keys = "]g", cmd = api.node.navigate.git.next, opts = opts("Next Git") },
{ keys = "L", cmd = api.node.open.toggle_group_empty, opts = opts("Toggle Group Empty") },
{ keys = "M", cmd = api.tree.toggle_no_bookmark_filter, opts = opts("Toggle Filter: No Bookmark") },
{ keys = "m", cmd = api.marks.toggle, opts = opts("Toggle Bookmark") },
{ keys = "o", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "O", cmd = api.node.open.no_window_picker, opts = opts("Open: No Window Picker") },
{ keys = "p", cmd = api.fs.paste, opts = opts("Paste") },
{ keys = "P", cmd = api.node.navigate.parent, opts = opts("Parent Directory") },
{ keys = "q", cmd = api.tree.close, opts = opts("Close") },
{ keys = "r", cmd = api.fs.rename, opts = opts("Rename") },
{ keys = "R", cmd = api.tree.reload, opts = opts("Refresh") },
{ keys = "s", cmd = api.node.run.system, opts = opts("Run System") },
{ keys = "S", cmd = api.tree.search_node, opts = opts("Search") },
{ keys = "u", cmd = api.fs.rename_full, opts = opts("Rename: Full Path") },
{ keys = "U", cmd = api.tree.toggle_custom_filter, opts = opts("Toggle Filter: Hidden") },
{ keys = "W", cmd = api.tree.collapse_all, opts = opts("Collapse") },
{ keys = "x", cmd = api.fs.cut, opts = opts("Cut") },
{ keys = "y", cmd = api.fs.copy.relative_path, opts = opts("Copy Relative Path") },
{ keys = "Y", cmd = api.fs.copy.absolute_path, opts = opts("Copy Absolute Path") },
-- From Directory Opus
{ keys = "#", cmd = "<Cmd>set relativenumber!<CR>", opts = opts("Toggle Relative Number") },
-- Numeric 数字键
{ keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") },
-- Non-Alphanumeric 非字母数字键
{ keys = "?", cmd = api.tree.toggle_help, opts = opts("Help") },
{ keys = ">", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "<", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = ".", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = ";", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = "-", cmd = api.tree.change_root_to_parent, opts = opts("Up") },
{ keys = "?", cmd = api.tree.toggle_help, opts = opts("Help") },
{ keys = ">", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "<", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = ".", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = ";", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = "-", cmd = api.tree.change_root_to_parent, opts = opts("Up") },
-- MOD KEYS Ctrl+
{ keys = "<C-]>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
{ keys = "<C-e>", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") },
{ keys = "<C-k>", cmd = api.node.show_info_popup, opts = opts("Info") },
{ keys = "<C-r>", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") },
{ keys = "<C-t>", cmd = api.node.open.tab, opts = opts("Open: New Tab") },
{ keys = "<C-v>", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") },
{ keys = "<C-h>", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") },
{ keys = "<C-]>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
{ keys = "<C-e>", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") },
{ keys = "<C-k>", cmd = api.node.show_info_popup, opts = opts("Info") },
{ keys = "<C-r>", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") },
{ keys = "<C-t>", cmd = api.node.open.tab, opts = opts("Open: New Tab") },
{ keys = "<C-v>", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") },
{ keys = "<C-h>", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") },
{ keys = "<A-0>", cmd = ":b#<CR>", opts = opts("Focus to previous buffer") },
-- Mouse 鼠标键
{ keys = "<2-LeftMouse>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<2-RightMouse>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
{ keys = "<2-LeftMouse>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<2-RightMouse>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
}
end

View file

@ -0,0 +1,30 @@
vim.api.nvim_create_user_command("Format", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
["end"] = { args.line2, end_line:len() },
}
end
require("conform").format({ async = true, lsp_format = "fallback", range = range })
end, { range = true })
vim.api.nvim_create_user_command("FormatToggle", function(args)
local buffer_local = args.bang
if buffer_local then
-- Toggle buffer-local formatting
vim.b.disable_autoformat = not vim.b.disable_autoformat
else
-- Toggle global formatting
vim.g.disable_autoformat = not vim.g.disable_autoformat
end
-- Print current status
local scope = buffer_local and "buffer" or "global"
local status = buffer_local and vim.b.disable_autoformat or vim.g.disable_autoformat
print(string.format("Format-on-save %s: %s", scope, status and "disabled" or "enabled"))
end, {
desc = "Toggle autoformat-on-save (use ! for buffer-local)",
bang = true,
})

View file

@ -0,0 +1,33 @@
local M = {}
-- local mode_arrow = { "n", "v", "o", "s", "x" }
local default_opts = { noremap = true, silent = true }
local default_mode = { "n" }
M.set_keymaps = function(maps)
for _, map in ipairs(maps) do
local opts = vim.tbl_extend("force", default_opts, map.opts or {})
local mode = map.mode or default_mode
vim.keymap.set(mode, map.keys, map.cmd, opts)
end
end
M.set_lang_keymaps = function(maps)
vim.api.create_autocmd("FileType", {
pattern = maps.filetype,
callback = function()
M.set_keymaps(maps.keymaps)
end,
})
end
M.set_buf_keymaps = function(maps)
vim.api.create_autocmd("BufEnter", {
pattern = maps.filetype,
callback = function()
M.set_keymaps(maps.keymaps)
end,
})
end
return M

View file

@ -0,0 +1,42 @@
local wk = require("which-key")
wk.add({
-- https://github.com/folke/which-key.nvim/tree/main?tab=readme-ov-file#%EF%B8%8F-mappings
{
-- Nested mappings are allowed and can be added in any order
-- Most attributes can be inherited or overridden on any level
-- There's no limit to the depth of nesting
mode = { "n" },
{ "<leader>b", group = "Buffer" }, -- no need to specify mode since it's inherited
{ "<leader>c", group = "Code/Compile" },
{ "<leader>f", group = "File" },
{ "<leader>p", group = "Project", icon = "" },
{ "<leader>q", group = "Quit" },
{ "<leader>t", group = "Toggle" },
{ "<leader>u", group = "UI" },
{ "<leader>w", group = "Window" },
},
{ -- https://github.com/folke/which-key.nvim/blob/1f8d414f61e0b05958c342df9b6a4c89ce268766/lua/which-key/plugins/presets.lua#L57-L98
-- text objects
mode = { "o", "x" },
{ "l", group = "inside" },
{ 'l"', desc = 'inner " string' },
{ "l'", desc = "inner ' string" },
{ "l(", desc = "inner [(])" },
{ "l)", desc = "inner [(])" },
{ "l<", desc = "inner <>" },
{ "l>", desc = "inner <>" },
{ "lB", desc = "inner [{]}" },
{ "lW", desc = "inner WORD" },
{ "l[", desc = "inner []" },
{ "l]", desc = "inner []" },
{ "l`", desc = "inner ` string" },
{ "lb", desc = "inner [(])" },
{ "lp", desc = "inner paragraph" },
{ "ls", desc = "inner sentence" },
{ "lt", desc = "inner tag block" },
{ "lw", desc = "inner word" },
{ "l{", desc = "inner [{]}" },
{ "l}", desc = "inner [{]}" },
{ "i", desc = "Right" },
},
})

View file

@ -1,9 +1,11 @@
return {
{ "catppuccin/nvim", name = "catppuccin" },
{ "olimorris/onedarkpro.nvim" },
{ "rebelot/kanagawa.nvim" },
{ "RRethy/vim-illuminate" },
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("plugins.mod.lualine")
end,
@ -18,9 +20,9 @@ return {
timer = 500,
},
})
end
end,
},
{ import = "plugins.mod.alpha-nvim" },
{ import = "plugins.mod.winbar-nvim"},
{ import = "plugins.mod.winbar-nvim" },
{ import = "plugins.mod.bufferline" },
}

View file

@ -1,6 +1,55 @@
return {
{ import = "plugins.mod.auto-session" },
{ import = "plugins.mod.nvim-tree" },
{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
{ import = "plugins.mod.projects" }
{ import = "plugins.mod.nvim-tree" },
{ import = "plugins.mod.telescope" },
{ import = "plugins.mod.projects" },
{
"lewis6991/hover.nvim",
config = function()
require("hover").setup({
init = function()
-- Require providers
require("hover.providers.lsp")
-- require('hover.providers.gh')
-- require('hover.providers.gh_user')
-- require('hover.providers.jira')
-- require('hover.providers.dap')
-- require('hover.providers.fold_preview')
require("hover.providers.diagnostic")
-- require('hover.providers.man')
-- require('hover.providers.dictionary')
end,
preview_opts = {
border = "single",
},
-- Whether the contents of a currently open hover window should be moved
-- to a :h preview-window when pressing the hover keymap.
preview_window = false,
title = true,
mouse_providers = {
"LSP",
},
mouse_delay = 1000,
})
-- Setup keymaps
vim.keymap.set("n", "gE", require("hover").hover_select, { desc = "hover.nvim (select)" })
vim.keymap.set("n", "<C-p>", function()
require("hover").hover_switch("previous")
end, { desc = "hover.nvim (previous source)" })
vim.keymap.set("n", "<C-n>", function()
require("hover").hover_switch("next")
end, { desc = "hover.nvim (next source)" })
-- Mouse support
vim.keymap.set("n", "<MouseMove>", require("hover").hover_mouse, { desc = "hover.nvim (mouse)" })
vim.o.mousemoveevent = true
end,
},
{
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup()
end,
},
}

View file

@ -1,26 +1,2 @@
-- Entry point of the plugin manager
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{ import = "plugins.appearance" },
{ import = "plugins.completion" },
{ import = "plugins.fileutils" },
{ import = "plugins.lsp" },
{ import = "plugins.syntax" },
{ import = "plugins.misc" },
})
require("plugins.lazy-nvim")

View file

@ -0,0 +1,39 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins.appearance" },
{ import = "plugins.completion" },
{ import = "plugins.fileutils" },
{ import = "plugins.lsp" },
{ import = "plugins.syntax" },
{ import = "plugins.misc" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
-- automatically check for plugin updates
checker = { enabled = true },
})

View file

@ -1,17 +1,29 @@
return {
{ import = "plugins.mod.lspconfig" },
{ "MeanderingProgrammer/render-markdown.nvim" },
-- {
-- "OXY2DEV/markview.nvim",
-- lazy = false, -- Recommended
-- -- ft = "markdown" -- If you decide to lazy-load anyway
--
-- dependencies = {
-- "nvim-treesitter/nvim-treesitter",
-- "nvim-tree/nvim-web-devicons"
-- }
-- },
{
"neovim/nvim-lspconfig",
lazy = false,
},
{ import = "plugins.mod.render-markdown" },
-- { import = "plugins.mod.markview" },
{
"lervag/vimtex",
lazy = false, -- we don't want to lazy load VimTeX
-- tag = "v2.15", -- uncomment to pin to a specific release
init = function()
-- VimTeX configuration goes here, e.g.
vim.g.vimtex_view_method = "sioyek"
end,
},
{
"iurimateus/luasnip-latex-snippets.nvim",
-- vimtex isn't required if using treesitter
requires = { "L3MON4D3/LuaSnip", "lervag/vimtex" },
config = function()
require("luasnip-latex-snippets").setup()
-- or setup({ use_treesitter = true })
require("luasnip").config.setup({ enable_autosnippets = true })
end,
},
{ "williamboman/mason.nvim", config = true },
{
"williamboman/mason-lspconfig.nvim",
@ -27,6 +39,31 @@ return {
mason_lspconfig.setup({
ensure_installed = servers,
})
end
end,
},
{
"nvim-orgmode/orgmode",
event = "VeryLazy",
ft = { "org" },
config = function()
-- Setup orgmode
require("orgmode").setup({
org_agenda_files = "~/orgfiles/**/*",
org_default_notes_file = "~/orgfiles/refile.org",
})
-- NOTE: If you are using nvim-treesitter with ~ensure_installed = "all"~ option
-- add ~org~ to ignore_install
-- require('nvim-treesitter.configs').setup({
-- ensure_installed = 'all',
-- ignore_install = { 'org' },
-- })
end,
},
{ import = "plugins.mod.conform-nvim" },
{ "nvim-treesitter/nvim-treesitter-context" },
{
"NoahTheDuke/vim-just",
ft = { "just" },
},
}

View file

@ -1,26 +1,15 @@
return {
{ 'wakatime/vim-wakatime', lazy = false },
{ "wakatime/vim-wakatime", lazy = false },
{ "voldikss/vim-floaterm" },
{ "CRAG666/betterTerm.nvim", opts = {
position = "bot",
size = 15,
} },
{ "CRAG666/code_runner.nvim", config = true },
{ import = "plugins.mod.obsidian-nvim" },
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
},
{ import = "plugins.mod.which-keys-nvim" },
{
"github/copilot.vim",
lazy = false,
}
},
}

View file

@ -1,14 +1,14 @@
-- alpha-nvim.lua
return {
{
'goolord/alpha-nvim',
"goolord/alpha-nvim",
dependencies = {
-- 'echasnovski/mini.icons',
-- 'nvim-lua/plenary.nvim'
},
config = function ()
local alpha = require'alpha'
local dashboard = require'alpha.themes.dashboard'
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = {
" ",
"================= =============== =============== ======== ========",
@ -34,11 +34,11 @@ return {
dashboard.section.buttons.val.leader = "SPC"
dashboard.section.buttons.val = {
-- leader = "SPC",
dashboard.button('p', '󰈞 查找项目', ':Telescope projects<CR>'),
dashboard.button('h', ' 历史文件', ':Telescope oldfiles<CR>'),
dashboard.button('l', ' 加载会话', ':SessionSearch<CR>'),
dashboard.button('c', ' 转到设置', ':Telescope find_files cwd=~/.config/nvim<CR>'),
dashboard.button('SPC q', '󱊷 退出', ':qa<CR>'),
dashboard.button("p", "󰈞 查找项目", ":Telescope projects<CR>"),
dashboard.button("h", " 历史文件", ":Telescope oldfiles<CR>"),
dashboard.button("l", " 加载会话", ":SessionSearch<CR>"),
dashboard.button("c", " 转到设置", ":Telescope find_files cwd=~/.config/nvim<CR>"),
dashboard.button("SPC q", "󱊷 退出", ":qa<CR>"),
}
dashboard.section.footer.val = "今日 " .. os.date("%Y-%m-%d %A") .. " "
@ -47,6 +47,6 @@ return {
-- vim.cmd[[autocmd User AlphaReady echo 'Alpha ready!']]
alpha.setup(dashboard.config)
end
};
end,
},
}

View file

@ -1,15 +1,15 @@
---@diagnostic disable: undefined-doc-name
return {
{
'rmagatti/auto-session',
"rmagatti/auto-session",
lazy = false,
---enables autocomplete for opts
---@module "auto-session"
---@type AutoSession.Config
opts = {
suppressed_dirs = { '~/', '~/Projects', '~/Downloads', '/' },
suppressed_dirs = { "~/", "~/Projects", "~/Downloads", "/" },
-- log_level = 'debug',
}
}
},
},
}

View file

@ -1,17 +1,17 @@
return {
"akinsho/bufferline.nvim",
dependencies = "nvim-tree/nvim-web-devicons", -- 图标支持
config = function()
require("bufferline").setup({
options = {
numbers = "ordinal", -- 显示 buffer 序号
close_command = "bdelete! %d", -- 关闭 buffer 的命令
right_mouse_command = "bdelete! %d", -- 右键关闭
offsets = {
{ filetype = "NvimTree", text = "资源管理器", text_align = "center" },
},
separator_style = "thin",
},
})
end,
"akinsho/bufferline.nvim",
dependencies = "nvim-tree/nvim-web-devicons", -- 图标支持
config = function()
require("bufferline").setup({
options = {
numbers = "ordinal", -- 显示 buffer 序号
close_command = "bdelete! %d", -- 关闭 buffer 的命令
right_mouse_command = "bdelete! %d", -- 右键关闭
offsets = {
{ filetype = "NvimTree", text = "资源管理器", text_align = "center" },
},
separator_style = "thin",
},
})
end,
}

View file

@ -0,0 +1,38 @@
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
-- This will provide type hinting with LuaLS
---@module "conform"
---@type conform.setupOpts
opts = {
-- Define your formatters
formatters_by_ft = {
lua = { "stylua" },
python = { "isort", "black" },
javascript = { "prettierd", "prettier", stop_after_first = true },
},
-- Set default options
default_format_opts = {
lsp_format = "fallback",
},
-- Set up format-on-save
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_format = "fallback" }
end,
-- Customize formatters
formatters = {
shfmt = {
prepend_args = { "-i", "2" },
},
},
},
init = function()
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
}

View file

@ -1,4 +1,4 @@
return {
"neovim/nvim-lspconfig",
lazy = false
lazy = false,
}

View file

@ -1,6 +1,6 @@
-- Author: shadmansaleh
-- Credit: glepnir
local lualine = require('lualine')
local lualine = require("lualine")
-- Color table for highlights
-- stylua: ignore
@ -20,14 +20,14 @@ local colors = {
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand('%:p:h')
local gitdir = vim.fn.finddir('.git', filepath .. ';')
local filepath = vim.fn.expand("%:p:h")
local gitdir = vim.fn.finddir(".git", filepath .. ";")
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
@ -36,11 +36,11 @@ local conditions = {
local config = {
options = {
disabled_filetypes = {
statusline = { "NvimTree", "alpha" }
statusline = { "NvimTree", "alpha" },
},
-- Disable sections and component separators
component_separators = '',
section_separators = '',
component_separators = "",
section_separators = "",
theme = {
-- We are going to use lualine_c an lualine_x as left and
-- right section. Both are highlighted by c theme . So we
@ -80,18 +80,18 @@ local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
ins_left({
function()
return ''
return ""
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- We don't need space before this
}
})
ins_left {
ins_left({
-- mode component
function()
return ''
return ""
end,
color = function()
-- auto change color according to neovims mode
@ -99,13 +99,13 @@ ins_left {
n = colors.red,
i = colors.green,
v = colors.blue,
[''] = colors.blue,
[""] = colors.blue,
V = colors.blue,
c = colors.magenta,
no = colors.red,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
[""] = colors.orange,
ic = colors.yellow,
R = colors.violet,
Rv = colors.violet,
@ -113,14 +113,14 @@ ins_left {
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
["r?"] = colors.cyan,
["!"] = colors.red,
t = colors.red,
}
return { fg = mode_color[vim.fn.mode()] }
end,
padding = { right = 1 },
}
})
-- ins_left {
-- -- filesize component
@ -134,42 +134,39 @@ ins_left {
-- color = { fg = colors.magenta, gui = 'bold' },
-- }
-- ins_left { 'location' }
ins_right { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_right({ "progress", color = { fg = colors.fg, gui = "bold" } })
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
ins_left({
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = { error = "", warn = "", info = "" },
diagnostics_color = {
error = { fg = colors.red },
warn = { fg = colors.yellow },
info = { fg = colors.cyan },
},
}
})
ins_left {
ins_left({
function()
return vim.bo.filetype
end,
color = { fg = colors.blue, gui = 'bold' },
}
color = { fg = colors.blue, gui = "bold" },
})
ins_left {
ins_left({
function()
return vim.bo.shiftwidth .. " space"
end,
}
})
ins_left {
ins_left({
-- Lsp server name .
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 })
local msg = "No Active Lsp"
local buf_ft = vim.api.nvim_get_option_value("filetype", { buf = 0 })
local clients = vim.lsp.get_clients()
if next(clients) == nil then
return msg
@ -182,59 +179,58 @@ ins_left {
end
return msg
end,
icon = '',
color = { fg = '#ffffff', gui = 'bold' },
}
icon = "",
color = { fg = "#ffffff", gui = "bold" },
})
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
ins_left({
function()
return '%='
return "%="
end,
}
})
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
ins_right({
"o:encoding", -- option component same as &encoding in viml
fmt = string.upper, -- I'm not sure why it's upper case either ;)
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
color = { fg = colors.green, gui = "bold" },
})
ins_right {
'fileformat',
ins_right({
"fileformat",
fmt = string.upper,
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
color = { fg = colors.green, gui = 'bold' },
}
color = { fg = colors.green, gui = "bold" },
})
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right({
"branch",
icon = "",
color = { fg = colors.violet, gui = "bold" },
})
ins_right {
'diff',
ins_right({
"diff",
-- Is it me or the symbol for modified us really weird
symbols = { added = '', modified = '󰝤 ', removed = '' },
symbols = { added = "", modified = "󰝤 ", removed = "" },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
})
ins_right {
ins_right({
function()
return ''
return ""
end,
color = { fg = colors.blue },
padding = { left = 1 },
}
})
-- Now don't forget to initialize lualine
lualine.setup(config)

View file

@ -0,0 +1,30 @@
return {
{
"OXY2DEV/markview.nvim",
lazy = false,
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons",
},
config = function()
local presets = require("markview.presets")
require("markview").setup({
checkboxes = presets.checkboxes.nerd,
headings = {
enable = true,
shift_width = 1,
heading_1 = {
style = "label",
hl = "MarkviewH1",
},
},
code_blocks = {
style = "language",
language_direction = "right",
hl = "MarkviewCode",
info_hl = "MarkviewCodeInfo",
},
})
end,
},
}

View file

@ -1,9 +1,9 @@
local function set_keymaps(keymaps_cmp)
local mappings = {}
for _, map in ipairs(keymaps_cmp) do
mappings[map.keys] = map.cmd
end
return mappings
for _, map in ipairs(keymaps_cmp) do
mappings[map.keys] = map.cmd
end
return mappings
end
return {

View file

@ -1,6 +1,6 @@
local function my_on_attach(bufnr)
-- local keymaps = require("config.keymaps")
local api = require "nvim-tree.api"
local api = require("nvim-tree.api")
local default_mode = { "n" }
local keymaps = require("keymaps")
@ -8,7 +8,6 @@ local function my_on_attach(bufnr)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
local function set_keymaps(maps)
for _, map in ipairs(maps) do
local mode = map.mode or default_mode
@ -28,10 +27,26 @@ return {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("nvim-tree").setup {
require("nvim-tree").setup({
on_attach = my_on_attach,
sync_root_with_cwd = true,
respect_buf_cwd = true,
}
end
disable_netrw = true,
renderer = {
icons = {
glyphs = {
git = { -- https://github.com/nvim-neo-tree/neo-tree.nvim/blob/main/doc/neo-tree.txt#L1077C1-L1077C29
unmerged = "",
renamed = "",
deleted = "",
untracked = "",
ignored = "",
unstaged = "󰄱",
staged = "",
},
},
},
},
})
end,
}

View file

@ -1,11 +1,11 @@
return {
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline" },
highlight = { enable = true },
indent = { enable = true },
})
end,
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline", "latex", "python" },
highlight = { enable = true },
indent = { enable = true },
})
end,
}

View file

@ -1,6 +1,6 @@
return {
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
version = "*", -- recommended, use latest release instead of latest commit
lazy = false,
ft = "markdown",
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
@ -26,8 +26,11 @@ return {
},
completion = {
nvim_cmp = true,
min_chars = 2
}
min_chars = 2,
},
ui = {
enable = false,
},
-- see below for full list of options 👇
},
}

View file

@ -1,15 +1,15 @@
return {
"ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup({
detection_methods = { "lsp", "pattern" },
patterns = { ".git", "Makefile", "package.json" },
sync_root_with_cwd = true,
silent_chdir = true,
scope_chdir = "global",
})
"ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup({
detection_methods = { "lsp", "pattern" },
patterns = { ".git", "Makefile", "package.json" },
sync_root_with_cwd = true,
silent_chdir = true,
scope_chdir = "global",
})
require("telescope").load_extension("projects")
end,
dependencies = { "nvim-telescope/telescope.nvim" },
require("telescope").load_extension("projects")
end,
dependencies = { "nvim-telescope/telescope.nvim" },
}

View file

@ -0,0 +1,74 @@
return {
{
"MeanderingProgrammer/render-markdown.nvim",
lazy = false,
config = function()
require("render-markdown").setup({
render_modes = { "n", "c", "t" },
latex = {
enabled = true,
converter = "latex2text",
highlight = "RenderMarkdownMath",
top_pad = 0,
bottom_pad = 0,
},
heading = {
sign = false,
position = "inline",
width = "block",
left_margin = 0.5,
left_pad = 0.2,
right_pad = 0.2,
},
link = {
custom = {
python = { pattern = "%.py", icon = "" },
lua = { pattern = "%.lua", icon = "" },
markdown = { pattern = "%.md", icon = "" },
},
},
bullet = {
icons = { "󰮯 ", "", "", "", "" },
},
checkbox = {
checked = { scope_highlight = "@markup.strikethrough" },
unchecked = { scope_highlight = "@comment.todo" },
},
code = {
position = "right",
width = "block",
right_pad = 10,
},
callout = {
note = { raw = "[!NOTE]", rendered = "󰋽 Note", highlight = "RenderMarkdownInfo" },
tip = { raw = "[!TIP]", rendered = "󰌶 Tip", highlight = "RenderMarkdownSuccess" },
important = { raw = "[!IMPORTANT]", rendered = "󰅾 Important", highlight = "RenderMarkdownHint" },
warning = { raw = "[!WARNING]", rendered = "󰀪 Warning", highlight = "RenderMarkdownWarn" },
caution = { raw = "[!CAUTION]", rendered = "󰳦 Caution", highlight = "RenderMarkdownError" },
abstract = { raw = "[!ABSTRACT]", rendered = "󰨸 Abstract", highlight = "RenderMarkdownInfo" },
summary = { raw = "[!SUMMARY]", rendered = "󰨸 Summary", highlight = "RenderMarkdownInfo" },
tldr = { raw = "[!TLDR]", rendered = "󰨸 Tldr", highlight = "RenderMarkdownInfo" },
info = { raw = "[!INFO]", rendered = "󰋽 Info", highlight = "RenderMarkdownInfo" },
todo = { raw = "[!TODO]", rendered = "󰗡 Todo", highlight = "RenderMarkdownInfo" },
hint = { raw = "[!HINT]", rendered = "󰌶 Hint", highlight = "RenderMarkdownSuccess" },
success = { raw = "[!SUCCESS]", rendered = "󰄬 Success", highlight = "RenderMarkdownSuccess" },
check = { raw = "[!CHECK]", rendered = "󰄬 Check", highlight = "RenderMarkdownSuccess" },
done = { raw = "[!DONE]", rendered = "󰄬 Done", highlight = "RenderMarkdownSuccess" },
question = { raw = "[!QUESTION]", rendered = "󰘥 Question", highlight = "RenderMarkdownWarn" },
help = { raw = "[!HELP]", rendered = "󰘥 Help", highlight = "RenderMarkdownWarn" },
faq = { raw = "[!FAQ]", rendered = "󰘥 Faq", highlight = "RenderMarkdownWarn" },
attention = { raw = "[!ATTENTION]", rendered = "󰀪 Attention", highlight = "RenderMarkdownWarn" },
failure = { raw = "[!FAILURE]", rendered = "󰅖 Failure", highlight = "RenderMarkdownError" },
fail = { raw = "[!FAIL]", rendered = "󰅖 Fail", highlight = "RenderMarkdownError" },
missing = { raw = "[!MISSING]", rendered = "󰅖 Missing", highlight = "RenderMarkdownError" },
danger = { raw = "[!DANGER]", rendered = "󱐌 Danger", highlight = "RenderMarkdownError" },
error = { raw = "[!ERROR]", rendered = "󱐌 Error", highlight = "RenderMarkdownError" },
bug = { raw = "[!BUG]", rendered = "󰨰 Bug", highlight = "RenderMarkdownError" },
example = { raw = "[!EXAMPLE]", rendered = "󰉹 Example", highlight = "RenderMarkdownHint" },
quote = { raw = "[!QUOTE]", rendered = "󱆨 Quote", highlight = "RenderMarkdownQuote" },
cite = { raw = "[!CITE]", rendered = "󱆨 Cite", highlight = "RenderMarkdownQuote" },
},
})
end,
},
}

View file

@ -0,0 +1,32 @@
return {
"nvim-telescope/telescope.nvim",
config = function()
require("telescope").setup({
defaults = {
prompt_prefix = "",
selection_caret = " ",
entry_prefix = " ",
layout_config = { -- https://github.com/NvChad/NvChad/blob/v2.5/lua/nvchad/configs/telescope.lua
horizontal = {
prompt_position = "top",
preview_width = 0.55,
},
width = 0.87,
height = 0.80,
},
mappings = {
n = {
["n"] = "move_selection_next",
["e"] = "move_selection_previous",
["w"] = "preview_scrolling_up",
["r"] = "preview_scrolling_down",
["a"] = "preview_scrolling_left",
["s"] = "preview_scrolling_right",
["q"] = require("telescope.actions").close,
},
},
},
})
end,
dependencies = { "nvim-lua/plenary.nvim" },
}

View file

@ -0,0 +1,18 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}

View file

@ -7,33 +7,32 @@ return {
show_file_path = true,
show_symbols = true,
colors = {
path = '#9c1d91',
file_name = '',
symbols = '',
path = "#9c1d91",
file_name = "",
symbols = "",
},
icons = {
file_icon_default = '',
seperator = '>',
editor_state = '',
lock_icon = '',
file_icon_default = "",
seperator = ">",
editor_state = "",
lock_icon = "",
},
exclude_filetype = {
'help',
'startify',
'dashboard',
'packer',
'neogitstatus',
'NvimTree',
'Trouble',
'alpha',
'lir',
'Outline',
'spectre_panel',
'toggleterm',
'qf',
}
"help",
"startify",
"dashboard",
"packer",
"neogitstatus",
"NvimTree",
"Trouble",
"alpha",
"lir",
"Outline",
"spectre_panel",
"toggleterm",
"qf",
},
})
end,
},
}

View file

@ -1,9 +1,10 @@
return {
{ import = "plugins.mod.nvim-treesitter", },
{ 'echasnovski/mini.pairs', version = false,
{ import = "plugins.mod.nvim-treesitter" },
{
"echasnovski/mini.pairs",
version = false,
config = function()
require("mini.pairs").setup()
end,
},
}

View file

@ -0,0 +1,4 @@
(((
This is a playground file.
{(1 + 2) * 3}
)))

View file

@ -31,5 +31,6 @@ Set-Alias "py" "python"
Set-Alias "ipy" "ipython"
if ($isWindows) {
function kex { wsl -d kali-linux kex --sl -s }
# Debugging
# function kex { wsl -d kali-linux kex --sl -s }
}

View file

@ -0,0 +1,42 @@
function Invoke-Completion {
param ([string]$command)
switch ($command) {
'docker' { docker completion powershell | Out-String | Invoke-Expression }
'dotnet' {
# https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#powershell
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
dotnet complete --position $cursorPosition "$commandAst" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
'git' { Import-Module Posh-Git }
'hugo' { hugo completion powershell | Out-String | Invoke-Expression }
'pip' { pip completion --powershell | Out-String | Invoke-Expression }
'rg' { rg --generate complete-powershell | Out-String | Invoke-Expression }
'uv' { uv generate-shell-completion powershell | Out-String | Invoke-Expression }
'wezterm' { wezterm shell-completion --shell power-shell | Out-String | Invoke-Expression }
'winget' {
# https://learn.microsoft.com/en-us/windows/package-manager/winget/tab-completion
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
}
}
Set-Alias "icmp" "Invoke-Completion"
Register-ArgumentCompleter -CommandName Invoke-Completion -ParameterName 'command' -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$cmds = @('docker', 'dotnet', 'git', 'hugo', 'pip', 'rg', 'uv', 'wezterm', 'winget')
$cmds | Where-Object { $_ -like "$wordToComplete*" }
}

View file

@ -1,7 +1,8 @@
# Use XDG Base Directory Specification and its similar structure for Windows
# wget
${function:wget} = {wget --hsts-file $XDG_CACHE_HOME/wget-hsts $args}
# yarn v1
${function:yarn} = {yarn --use-yarnrc $XDG_CONFIG_HOME/yarn/config.yaml $args}
if ($Env:WEZTERM) {
# Environment variable injected by wezterm/wezterm.lua
${function:icat} = { wezterm imgcat $args }
}
elseif ($Env:KITTY) {
${function:icat} = { kitty +kitten icat $args }
}

View file

@ -23,6 +23,9 @@ Set-PSReadLineKeyHandler -Chord "N" -Function ViJoinLines -ViMode Command
Set-PSReadLineKeyHandler -Chord "Control+Oem4" -Function ViCommandMode -ViMode Insert # ^[ to Escape
Set-PSReadLineKeyHandler -Chord "Ctrl+a" -Function BeginningOfLine
Set-PSReadLineKeyHandler -Chord "Ctrl+e" -Function EndOfLine
Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory
Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory
Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function NextHistory
## Use <Tab> to Invoke MenuComplete
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

View file

@ -1,4 +1,4 @@
Import-Module -Name Terminal-Icons
# Import-Module -Name Terminal-Icons
Import-Module -Name CompletionPredictor
if ($IsWindows) {
# Chocolatey

View file

@ -4,92 +4,4 @@
# Use starship to set prompt
$ENV:STARSHIP_CONFIG = Join-Path $DOTFILES "tools" "starship" "starship_pwsh.toml"
# Invoke-Expression (&starship init powershell)
# Below is the backup of original prompt function
# $promptTime = $true
# # $promptWeather = $false
# function prompt {
# $prompt = "`e[35m"
# # Time
# if ($promptTime) {
# $promptTime = Get-Date -Format HH:mm
# $prompt += "`[$promptTime]"
# }
# # UserInfo
# $prompt += " $Env:Username @ $Env:Userdomain"
# # Directory
# $promptCurrentDirectory = $(PWD).Path
# $promptCurrentDirectory = $promptCurrentDirectory.Replace("$HOME", "~")
# $prompt += "`e[0m in `e[33m$promptCurrentDirectory "
# # Git
# if ($(git rev-parse --is-inside-work-tree 2> $null) -eq "true") {
# $prompt += "`e[32m`u{e702} $(git branch --show-current)"
# }
# # Conda
# if ( $Env:CONDA_PROMPT_MODIFIER ) {
# $promptConda = $Env:CONDA_PROMPT_MODIFIER.Replace("`(","").Replace(")","")
# $pythonVersion = $(python --version).Split(" ")[1]
# $prompt += " `e[33m`u{e73c} $promptConda $pythonVersion"
# }
# # Programming Language (by Get-ChildItem)
# ## Python
# if (Test-Path -Path "$PWD\pyproject.toml") {
# $pythonVersion = $(python --version).Split(" ")[1]
# $prompt += " `e[33m`u{e73c} $pythonVersion"
# }
# ## Node.js
# if (Test-Path -Path "$PWD\package.json") {
# $nodeVersion = $(node --version)
# $prompt += " `e[32m`u{e3a0} $nodeVersion"
# # Locked
# if (Test-Path -Path "$PWD\yarn.lock" || Test-Path -Path "$PWD\package-lock.json") {
# $prompt += "`u{f023}"
# }
# }
# ## .NET
# ### C Sharp
# if (Test-Path -Path "$PWD\*.csproj") {
# $dotnetVersion = $(dotnet --version)
# $prompt += " `e[34m`u{e648} $dotnetVersion"
# }
# ### F Sharp
# if (Test-Path -Path "$PWD\*.fsproj") {
# $dotnetVersion = $(dotnet --version)
# $prompt += " `e[35m`u{e65a} $dotnetVersion"
# }
# ## Rust
# if (Test-Path -Path "$PWD\Cargo.toml") {
# $rustVersion = $(cargo --version).Split(" ")[1]
# $prompt += " `e[31m`u{e7a8} $rustVersion"
# }
# ## Java
# if (Test-Path -Path "$PWD\pom.xml" || Test-Path -Path "$PWD\build.gradle") {
# $javaVersion = $(java --version).Split(" ")[1]
# $prompt += " `e[31m`u{e738} $javaVersion"
# }
# ## Makefile
# if (Test-Path -Path "$PWD\Makefile") {
# $prompt += " `e[32m`u{e673}"
# }
# if (Test-Path -Path "$PWD\CMakeLists.txt") {
# $prompt += " `e[32m `u{e61d}"
# }
# # Docker
# if (Test-Path -Path "$PWD\Dockerfile" || Test-Path -Path "$PWD\docker-compose.yml") {
# $prompt += " `e[33m`u{f21f}"
# }
# # Weather
# # if ( $global:promptWeather ) {
# # $prompt += $(Write-WeatherCurrent -City "Edinburgh" -Country "UK" -Unit "metric" -Inline -Apikey $Env:WEATHER_API_KEY)
# # }
# # Error on last command
# ## TODO: Seems does not work
# if ($?) {
# $prompt += "`n`e[32m PS > `e[0m"
# } else {
# $prompt += "`n`e[31m PS > `e[0m"
# }
# return $prompt
# }
Invoke-Expression (&starship init powershell)

View file

@ -20,3 +20,20 @@ This is the cross-platform PowerShell profile for PowerShell Core
| `^a` | To Beginning of Line | All |
| `^e` | To End of Line | All |
| `^[` | To Normal Mode | Insert |
## `Get-Command` vs `which.exe` under Windows
```powershell
PS > hyperfine "pwsh.exe -NoProfile -Command 'Get-Command which'" "pwsh.exe -NoProfile -Command 'which which'" --warmup 10
Benchmark 1: pwsh.exe -NoProfile -Command 'Get-Command which'
Time (mean ± σ): 152.1 ms ± 1.3 ms [User: 112.2 ms, System: 89.3 ms]
Range (min … max): 150.0 ms … 155.3 ms 18 runs
Benchmark 2: pwsh.exe -NoProfile -Command 'which which'
Time (mean ± σ): 153.7 ms ± 6.4 ms [User: 126.7 ms, System: 101.9 ms]
Range (min … max): 147.8 ms … 169.5 ms 19 runs
Summary
pwsh.exe -NoProfile -Command 'Get-Command which' ran
1.01 ± 0.04 times faster than pwsh.exe -NoProfile -Command 'which which'
```

View file

@ -1,202 +0,0 @@
# starship.toml
# ~/.config/starship.toml
format = '''$os$time $username @ $hostname $directory $all$character'''
add_newline = true
[time]
disabled = false
format = '[\[$time\]](purple)'
time_format = '%H:%M'
[username]
format = '[$user](bold)'
show_always = true
[hostname]
ssh_only = false
ssh_symbol = '󰞉 '
[directory]
truncation_length = 2
truncate_to_repo = true
read_only = " 󰌾"
style ="bold cyan"
truncation_symbol = ".../"
[directory.substitutions]
"~/Documents" = "󰈙 "
"~/Downloads" = " "
"~/Music" = " "
"~/Pictures" = " "
"Source" = " "
"src" = " "
[aws]
symbol = " "
[buf]
symbol = " "
[c]
symbol = " "
[conda]
symbol = " "
[crystal]
symbol = " "
[dart]
symbol = " "
[docker_context]
symbol = " "
[elixir]
symbol = " "
[elm]
symbol = " "
[fennel]
symbol = " "
[fossil_branch]
symbol = " "
[git_branch]
symbol = " "
[git_commit]
tag_symbol = '  '
[golang]
symbol = " "
[guix_shell]
symbol = " "
[haskell]
symbol = " "
[haxe]
symbol = " "
[hg_branch]
symbol = " "
[java]
symbol = " "
[julia]
symbol = " "
[kotlin]
symbol = " "
[lua]
symbol = " "
[memory_usage]
symbol = "󰍛 "
[meson]
symbol = "󰔷 "
[nim]
symbol = "󰆥 "
[nix_shell]
symbol = " "
[nodejs]
symbol = " "
[ocaml]
symbol = " "
[os]
disabled = false
[os.symbols]
Alpaquita = " "
Alpine = " "
AlmaLinux = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Kali = " "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
RockyLinux = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Void = " "
Windows = "󰍲 "
[package]
symbol = "󰏗 "
[perl]
symbol = " "
[php]
symbol = " "
[pijul_channel]
symbol = " "
[python]
symbol = " "
[rlang]
symbol = "󰟔 "
[ruby]
symbol = " "
[rust]
symbol = "󱘗 "
[scala]
symbol = " "
[swift]
symbol = " "
[zig]
symbol = " "
[gradle]
symbol = " "

View file

@ -1,208 +1,144 @@
# starship.toml
# ~/.config/starship.toml
format = '''$os$time $username @ $hostname $directory $all$character'''
continuation_prompt = "[r % ](bold cyan) " # Doesn't work in fish
format = """
[](#9A348E)\
$os\
$username\
[](bg:#DA627D fg:#9A348E)\
$directory\
[](fg:#DA627D bg:#FCA17D)\
$git_branch\
$git_status\
[](fg:#FCA17D bg:#86BBD8)\
$c\
$elixir\
$elm\
$golang\
$gradle\
$haskell\
$java\
$julia\
$nodejs\
$nim\
$rust\
$scala\
[](fg:#86BBD8 bg:#06969A)\
$docker_context\
[](fg:#06969A bg:#33658A)\
$time\
[ ](fg:#33658A)\
"""
add_newline = true
[time]
disabled = false
format = '[\[$time\]](purple)'
time_format = '%H:%M'
# Disable the blank line at the start of the prompt
# add_newline = false
# You can also replace your username with a neat symbol like  or disable this
# and use the os module below
[username]
format = '[$user](bold)'
show_always = true
style_user = "bg:#9A348E"
style_root = "bg:#9A348E"
format = '[$user ]($style)'
disabled = false
[hostname]
ssh_only = false
ssh_symbol = '󰞉 '
[character]
success_symbol = "[󰈺 >](bold green)"
error_symbol = "[󰈺 >](bold red)"
vimcmd_symbol = "[ <](bold green)"
# An alternative to the username module which displays a symbol that
# represents the current operating system
[os]
style = "bg:#9A348E"
disabled = true # Disabled by default
[directory]
truncation_length = 2
truncate_to_repo = true
read_only = " 󰌾"
style = "bold cyan"
truncation_symbol = ".../"
style = "bg:#DA627D"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
# Here is how you can shorten some long paths by text replacement
# similar to mapped_locations in Oh My Posh:
[directory.substitutions]
"~/Documents" = "󰈙 "
"~/Downloads" = " "
"~/Music" = " "
"~/Pictures" = " "
"Source" = " "
"src" = " "
[aws]
symbol = " "
[buf]
symbol = " "
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
# Keep in mind that the order matters. For example:
# "Important Documents" = " 󰈙 "
# will not be replaced, because "Documents" was already substituted before.
# So either put "Important Documents" before "Documents" or use the substituted version:
# "Important 󰈙 " = " 󰈙 "
[c]
symbol = " "
[conda]
symbol = " "
[crystal]
symbol = " "
[dart]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[docker_context]
symbol = " "
style = "bg:#06969A"
format = '[ $symbol $context ]($style)'
[elixir]
symbol = " "
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[elm]
symbol = " "
[fennel]
symbol = " "
[fossil_branch]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[git_branch]
symbol = " "
symbol = ""
style = "bg:#FCA17D"
format = '[ $symbol $branch ]($style)'
[git_commit]
tag_symbol = '  '
[git_status]
style = "bg:#FCA17D"
format = '[$all_status$ahead_behind ]($style)'
[golang]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[guix_shell]
symbol = " "
[gradle]
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[haskell]
symbol = " "
[haxe]
symbol = " "
[hg_branch]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[java]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[julia]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[kotlin]
symbol = " "
[lua]
symbol = " "
[memory_usage]
symbol = "󰍛 "
[meson]
symbol = "󰔷 "
[nodejs]
symbol = ""
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[nim]
symbol = "󰆥 "
[nix_shell]
symbol = " "
[nodejs]
symbol = " "
[ocaml]
symbol = " "
[os]
disabled = false
[os.symbols]
Alpaquita = " "
Alpine = " "
AlmaLinux = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Kali = " "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
RockyLinux = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Void = " "
Windows = "󰍲 "
[package]
symbol = "󰏗 "
[perl]
symbol = " "
[php]
symbol = " "
[pijul_channel]
symbol = " "
[python]
symbol = " "
[rlang]
symbol = "󰟔 "
[ruby]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[rust]
symbol = "󱘗 "
symbol = ""
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[scala]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[swift]
symbol = " "
[zig]
symbol = " "
[gradle]
symbol = " "
[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "bg:#33658A"
format = '[ ♥ $time ]($style)'

View file

@ -380,37 +380,37 @@
// #region Terminal Control, use ^a as prefix / leader key
// tmux-like terminal control
{ // prefix + x : kill terminal
"key": "ctrl+a x",
"key": "ctrl+q x",
"command": "workbench.action.terminal.kill",
"when": "terminalFocus"
},
{ // prefix + c : create new terminal
"key": "ctrl+a c",
"key": "ctrl+q c",
"command": "workbench.action.terminal.new",
"when": "terminalFocus"
},
{ // prefix + | : split terminal vertically
"key": "ctrl+a shift+\\",
"key": "ctrl+q shift+\\",
"command": "workbench.action.terminal.split",
"when": "terminalFocus"
},
{ // prefix + \ : split terminal vertically
"key": "ctrl+a \\",
"key": "ctrl+q \\",
"command": "workbench.action.terminal.split",
"when": "terminalFocus"
},
{ // prefix + / : search
"key": "ctrl+a /",
"key": "ctrl+q /",
"command": "workbench.action.terminal.focusFind",
"when": "terminalFocus"
},
{ // prefix + t : toggle terminal
"key": "ctrl+a t",
"key": "ctrl+q t",
"command": "workbench.action.terminal.toggleTerminal",
"when": "terminalFocus"
},
{ // prefix + ^a: show information
"key": "ctrl+a ctrl+a",
"key": "ctrl+q ctrl+q",
"command": "workbench.action.terminal.focusHover",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalIsOpen || terminalFocus && terminalProcessSupported || terminalHasBeenCreated && terminalTabsFocus || terminalIsOpen && terminalTabsFocus || terminalProcessSupported && terminalTabsFocus"
},
@ -420,22 +420,22 @@
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalIsOpen || terminalFocus && terminalProcessSupported || terminalHasBeenCreated && terminalTabsFocus || terminalIsOpen && terminalTabsFocus || terminalProcessSupported && terminalTabsFocus"
},
{ // prefix + 1 : focus terminal 1
"key": "ctrl+a 1",
"key": "ctrl+q 1",
"command": "workbench.action.terminal.focusAtIndex1",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalIsOpen || terminalFocus && terminalProcessSupported || terminalHasBeenCreated && terminalTabsFocus || terminalIsOpen && terminalTabsFocus || terminalProcessSupported && terminalTabsFocus"
},
{ // prefix + 2 : focus terminal 2
"key": "ctrl+a 2",
"key": "ctrl+q 2",
"command": "workbench.action.terminal.focusAtIndex2",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalIsOpen || terminalFocus && terminalProcessSupported || terminalHasBeenCreated && terminalTabsFocus || terminalIsOpen && terminalTabsFocus || terminalProcessSupported && terminalTabsFocus"
},
{ // prefix + 3 : focus terminal 3
"key": "ctrl+a 3",
"key": "ctrl+q 3",
"command": "workbench.action.terminal.focusAtIndex3",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalIsOpen || terminalFocus && terminalProcessSupported || terminalHasBeenCreated && terminalTabsFocus || terminalIsOpen && terminalTabsFocus || terminalProcessSupported && terminalTabsFocus"
},
{ // prefix + g : Go to recent directory
"key": "ctrl+a g",
"key": "ctrl+q g",
"command": "workbench.action.terminal.goToRecentDirectory",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
@ -445,42 +445,42 @@
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{ // prefix + d : detach terminal
"key": "ctrl+a d",
"key": "ctrl+q d",
"command": "workbench.action.terminal.detachSession",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{ // prefix + a : attach to session
"key": "ctrl+a a",
"key": "ctrl+q a",
"command": "workbench.action.terminal.attachToSession",
"when": "terminalFocus"
},
{
"key": "ctrl+a h",
"key": "ctrl+q h",
"command": "workbench.action.terminal.focusPreviousPane",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+a i",
"key": "ctrl+q i",
"command": "workbench.action.terminal.focusNextPane",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+a shift+H",
"key": "ctrl+q shift+H",
"command": "workbench.action.terminal.resizePaneLeft",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+a shift+N",
"key": "ctrl+q shift+N",
"command": "workbench.action.terminal.resizePaneDown",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+a shift+E",
"key": "ctrl+q shift+E",
"command": "workbench.action.terminal.resizePaneUp",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+a shift+I",
"key": "ctrl+q shift+I",
"command": "workbench.action.terminal.resizePaneRight",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
}

View file

@ -0,0 +1,169 @@
" ~/.config/vscode/vscode.vimrc
" New-Item -ItemType SymbolicLink -Path ~\.config\vscode\vscode.vimrc -Target ~\.dotfiles\vscode\vscode.vimrc
" ln -sf $DOTFILES/vscode/vscode.vimrc $XDG_CONFIG_HOME/vscode/vscode.vimrc
" And go to vscode vim setting:
"vim.vimrc.path": "$HOME/.config/vscode/vscode.vimrc",
" Arrow remap
noremap n j
noremap e k
noremap i l
" Switch between tabs
noremap H :bprevious<CR>
noremap I :bnext<CR>
noremap N 5j
noremap E 5k
" Similar position to i
" The `noremap` implements text-object-like behavior in VSCodeVim
noremap l i
noremap L I
" ne[k]st
noremap k n
noremap K N
" [j]ump
noremap j e
noremap J E
" Y to yank to end of line
noremap Y y$
" Define in settings.json, since this will remap <esc> under visual mode
" noremap <esc> :nohlsearch<CR>
" 分词版本的w和b支持中文需要插件
" 为了保证递归解析,而不是打断,使用 `nmap` 而不是 `nnoremap`
" Comment if you don't use cjk or the plugin
nmap w cjkWordHandler.cursorWordEndRight
nmap b cjkWordHandler.cursorWordStartLeft
" keep selection after indent (define in settings.json)
" voremap < <gv
" voremap > >gv
" lsp
noremap gi editor.action.goToImplementation
noremap gpi editor.action.peekImplementation
noremap gd editor.action.goToDefinition
noremap gpd editor.action.peekDefinition
noremap gt editor.action.goToTypeDefinition
noremap gpt editor.action.peekTypeDefinition
noremap gh editor.action.showDefinitionPreviewHover
noremap <leader><leader> workbench.action.quickOpen
noremap <leader>/ workbench.action.quickTextSearch
noremap <leader>: workbench.action.showCommands
noremap <leader>E workbench.view.explorer
noremap <leader>- workbench.action.splitEditorDown
noremap <leader>| workbench.action.splitEditorRight
noremap <leader>\ workbench.action.splitEditorRight
" <leader>a : +ai/action
noremap <leader>aa inlineChat.start
noremap <leader>aA workbench.panel.chat
noremap <leader>ae workbench.action.chat.openEditSession
" <leader>b : +buffer
noremap <leader>bb workbench.action.showAllEditors
noremap <leader>bd :bdelete<CR>
noremap <leader>bh :bprevious<CR>
noremap <leader>bi :bnext<CR>
noremap <leader>bp :bprevious<CR>
noremap <leader>bn :bnext<CR>
" <leader>c : +code/compile
noremap <leader>cr code-runner.run
noremap <leader>cf editor.action.formatDocument
noremap <leader>c<leader> editor.action.trimTrailingWhitespace
noremap <leader>cs workbench.action.gotoSymbol
noremap <leader>cS workbench.action.showAllSymbols
noremap <leader>ce editor.action.marker.next
noremap <leader>cE editor.action.marker.prev
noremap <leader>cg editor.action.dirtydiff.next
noremap <leader>cG editor.action.dirtydiff.previous
noremap <leader>cR editor.action.rename
" <leader>d : +debug
" <leader>f : +file
noremap <leader>ff workbench.action.quickOpen
noremap <leader>fF workbench.view.search
noremap <leader>fc workbench.action.openSettings
noremap <leader>fC workbench.action.openFolderSettingsFile
noremap <leader>fe workbench.view.explorer
noremap <leader>fo openInExternalApp.open
noremap <leader>fr workbench.action.showAllEditorsByMostRecentlyUsed
" Can only rename tracked files
noremap <leader>fR git.rename
" noremap <leader>fs workbench.action.search.toggleQueryDetails
noremap <leader>ft workbench.action.terminal.toggleTerminal
noremap <leader>fx workbench.view.extensions
" <leader>g : +git
noremap <leader>gg workbench.view.scm
noremap <leader>gS git.stageAll
" <leader>h : +help
" <leader>j : +jump
noremap <leader>jj workbench.action.gotoLine
" <leader>l : +language (define in settings.json)
" <leader>p : +project (requires Project Manager extension)
noremap <leader>pp projectManager.listProjects
noremap <leader>pP projectManager.listAnyProjects#sideBarAny
noremap <leader>pc projectManager.openSettings#sideBarAny
noremap <leader>pe projectManager.editProjects
noremap <leader>pf projectManager.addToFavorites
noremap <leader>pF projectManager.filterProjectsByTag
noremap <leader>pg projectManager.listGitProjects#sideBarGit
noremap <leader>pr workbench.action.openRecent
noremap <leader>ps projectManager.saveProject
" <leader>q : +quit
noremap <leader>qq :quit<CR>
noremap <leader>qQ :qall<CR>
noremap <leader>Q :quit<CR>
" <leader>r : +refactor
" <leader>s : +search
" <leader>t : +test
noremap <leader>tt testing.runAll
noremap <leader>tT testing.debugAll
noremap <leader>ta testing.runAll
noremap <leader>tA testing.debugAll
noremap <leader>tf testing.reRunFailedTests
noremap <leader>tF testing.debugFailedTests
noremap <leader>tl testing.reRunLastRun
noremap <leader>tL testing.debugLastRun
noremap <leader>tc testing.runCurrentTest
noremap <leader>tC testing.debugCurrentTest
noremap <leader>tx testing.cancelTestRun
" <leader>u : +ui
noremap <leader>ui workbench.action.selectTheme
noremap <leader>uw editor.action.toggleWordWrap
noremap <leader>uz workbench.action.toggleZenMode
" <leader>w : +write/window
noremap <leader>ww :write<CR>
noremap <leader>wa :wall<CR>
noremap <leader>wq :wq<CR>
noremap <leader>W :write<CR>
noremap <leader>wh workbench.action.focusLeftGroup
noremap <leader>wH workbench.action.splitEditorLeft
noremap <leader>wn workbench.action.focusBelowGroup
noremap <leader>wN workbench.action.splitEditorDown
noremap <leader>we workbench.action.focusAboveGroup
noremap <leader>wE workbench.action.splitEditorUp
noremap <leader>wi workbench.action.focusRightGroup
noremap <leader>wI workbench.action.splitEditorRight
noremap <leader>w- workbench.action.splitEditorDown
noremap <leader>w| workbench.action.splitEditorRight
noremap <leader>w\ workbench.action.splitEditorRight

View file

@ -4,6 +4,10 @@
" And go to vscode vim setting:
"vim.vimrc.path": "$HOME/.config/vscode/vscode.vimrc",
" Use VSpaceCode instead of <leader>
noremap <space> vspacecode.space
" Arrow remap
noremap n j
noremap e k
@ -17,6 +21,7 @@ noremap N 5j
noremap E 5k
" Similar position to i
" The `noremap` implements text-object-like behavior in VSCodeVim
noremap l i
noremap L I
" ne[k]st
@ -29,9 +34,11 @@ noremap J E
" Y to yank to end of line
noremap Y y$
" Define in settings.json, since this will remap <esc> under visual mode
" noremap <esc> :nohlsearch<CR>
" 分词版本的w和b支持中文需要插件
" 为了保证递归解析,而不是打断,使用 `nmap` 而不是 `nnoremap`
" 由于 VSCode Vim 的限制递归解析存在缺陷目前这种情况2w 符合预期,但 dw 不符合预期
" Comment if you don't use cjk or the plugin
nmap w cjkWordHandler.cursorWordEndRight
nmap b cjkWordHandler.cursorWordStartLeft
@ -48,98 +55,3 @@ noremap gpd editor.action.peekDefinition
noremap gt editor.action.goToTypeDefinition
noremap gpt editor.action.peekTypeDefinition
noremap gh editor.action.showDefinitionPreviewHover
noremap <leader><leader> workbench.action.quickOpen
noremap <leader>: workbench.action.showCommands
noremap <leader>E workbench.view.explorer
" <leader>q : +quit
noremap <leader>qq :quit<CR>
noremap <leader>qQ :qall<CR>
noremap <leader>Q :quit<CR>
" <leader>w : +write/window
noremap <leader>ww :write<CR>
noremap <leader>wa :wall<CR>
noremap <leader>wq :wq<CR>
noremap <leader>W :write<CR>
noremap <leader>wh workbench.action.focusLeftGroup
noremap <leader>wH workbench.action.splitEditorLeft
noremap <leader>wn workbench.action.focusBelowGroup
noremap <leader>wN workbench.action.splitEditorDown
noremap <leader>we workbench.action.focusAboveGroup
noremap <leader>wE workbench.action.splitEditorUp
noremap <leader>wi workbench.action.focusRightGroup
noremap <leader>wI workbench.action.splitEditorRight
" <leader>f : +find/file
noremap <leader>ff workbench.action.quickOpen
noremap <leader>fF workbench.view.search
noremap <leader>fc workbench.action.openSettings
noremap <leader>fC workbench.action.openFolderSettingsFile
noremap <leader>fe workbench.view.explorer
noremap <leader>fr workbench.action.showAllEditorsByMostRecentlyUsed
noremap <leader>fR workbench.action.openRecent
noremap <leader>fs workbench.action.search.toggleQueryDetails
noremap <leader>ft workbench.action.terminal.toggleTerminal
noremap <leader>fx workbench.view.extensions
" <leader>p : +project (requires Project Manager extension)
noremap <leader>pp projectManager.listProjects
noremap <leader>pP projectManager.listAnyProjects#sideBarAny
noremap <leader>pc projectManager.openSettings#sideBarAny
noremap <leader>pe projectManager.editProjects
noremap <leader>pf projectManager.addToFavorites
noremap <leader>pF projectManager.filterProjectsByTag
noremap <leader>pg projectManager.listGitProjects#sideBarGit
noremap <leader>pr workbench.action.openRecent
noremap <leader>ps projectManager.saveProject
" <leader>g : +git
noremap <leader>gg workbench.view.scm
noremap <leader>gS git.stageAll
" <leader>j : +jump
noremap <leader>jj workbench.action.gotoLine
" <leader>l : +language (define in settings.json)
" <leader>u : +ui
noremap <leader>ui workbench.action.selectTheme
noremap <leader>uw editor.action.toggleWordWrap
noremap <leader>uz workbench.action.toggleZenMode
" <leader>a : +ai/action
noremap <leader>aa inlineChat.start
noremap <leader>aA workbench.panel.chat
noremap <leader>ae workbench.action.chat.openEditSession
" <leader>r : +refactor
" <leader>s : +search
" <leader>t : +test
noremap <leader>tt testing.runAll
noremap <leader>tT testing.debugAll
noremap <leader>ta testing.runAll
noremap <leader>tA testing.debugAll
noremap <leader>tf testing.reRunFailedTests
noremap <leader>tF testing.debugFailedTests
noremap <leader>tl testing.reRunLastRun
noremap <leader>tL testing.debugLastRun
noremap <leader>tc testing.runCurrentTest
noremap <leader>tC testing.debugCurrentTest
noremap <leader>tx testing.cancelTestRun
" <leader>d : +debug
" <leader>h : +help
" <leader>c : +code
noremap <leader>cr code-runner.run
noremap <leader>cf editor.action.formatDocument
noremap <leader>c<leader> editor.action.trimTrailingWhitespace
noremap <leader>cs workbench.action.gotoSymbol
noremap <leader>cS workbench.action.showAllSymbols
" <leader>b : +buffer
noremap <leader>bb workbench.action.showAllEditors
noremap <leader>bd :bdelete<CR>
noremap <leader>bh :bprevious<CR>
noremap <leader>bi :bnext<CR>
" 中文分词测试用例

12
tools/wezterm/.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
# $DOTFILES/tools/wezterm/
# Date: 2025-01-06
# Author: js0ny
# Location:
# $XDG_CONFIG_HOME/wezterm/wezterm.lua (works Windows)
# Linking: Link the whole directory
# ln -sf $DOTFILES/tools/wezterm $XDG_CONFIG_HOME/wezterm
# New-Item -ItemType SymbolicLink -Target $DOTFILES\tools\wezterm -Path $Env:XDG_CONFIG_HOME\wezterm
*.json
check_update

278
tools/wezterm/wezterm.lua Normal file
View file

@ -0,0 +1,278 @@
-- $DOTFILES/tools/wezterm/wezterm.lua
-- Date: 2024-12-22
-- Author: js0ny
--#region Import & Setup
local wezterm = require("wezterm")
local action = wezterm.action
local config = {}
--#endregion
--#region Helper
--[[
local function detect_os()
local detected_os = ""
if package.config:sub(1, 1) == "\\" then
-- Windows
detected_os = "Windows"
elseif package.config:sub(1, 1) == "/" then
-- Unix-like (Linux, macOS, etc.)
if os.getenv("HOME") then
detected_os = "Unix-like"
-- You can differentiate further by checking for macOS or Linux if needed
if os.getenv("XDG_SESSION_TYPE") then
-- Likely Linux
detected_os = "Linux"
elseif os.execute("uname -s | grep -i darwin") == 0 then
-- macOS
detected_os = "macOS"
end
end
end
return detected_os
end
--]]
--[[
wezterm.on("text-selection-callback", function(window, pane)
local text = window:get_selection_text_for_pane(pane)
end)
--]]
local function detect_os()
local os_type = ""
if wezterm.target_triple == "x86_64-pc-windows-msvc" then
os_type = "Windows"
elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then
os_type = "Linux"
elseif wezterm.target_triple == "aarch64-apple-darwin" then
os_type = "macOS"
end
return os_type
end
-- OS light/dark theme detection
local function detect_theme() end
--#endregion
--#region Constant
local os_type = detect_os()
--#endregion
--#region Appearance
-- Font and color scheme
-- config.font = 'FiraCode Nerd Font'
config.max_fps = 120
config.font = wezterm.font({
family = "CaskaydiaCove Nerd Font",
})
config.color_scheme = "Catppuccin Frappe"
config.font_size = 12.0
config.front_end = "WebGpu"
config.webgpu_power_preference = "HighPerformance"
if os_type == "Windows" then
config.window_background_opacity = 0.7 -- Not working under WebGpu
config.win32_system_backdrop = "Mica"
end
-- Tab appearance
config.hide_tab_bar_if_only_one_tab = true
config.tab_bar_at_bottom = true
-- Cursor
-- config.animation_fps = 120
-- config.cursor_blink_ease_in = 'EaseOut'
-- config.cursor_blink_ease_out = 'EaseOut'
-- config.default_cursor_style = 'BlinkingBlock'
-- config.cursor_blink_rate = 650
-- Visual Bell
config.visual_bell = {
fade_in_function = "EaseIn",
fade_in_duration_ms = 250,
fade_out_function = "EaseOut",
fade_out_duration_ms = 250,
target = "CursorColor",
}
--#endregion
--#region Keybindings
config.leader = { key = "q", mods = "CTRL" }
config.keys = {
{
key = "q",
mods = "LEADER",
action = action.SendKey({ key = "q", mods = "CTRL" }),
},
-- Windows Management
{ -- leader keys
key = "|",
mods = "LEADER|SHIFT",
action = action.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
{
key = "-",
mods = "LEADER",
action = action.SplitVertical({ domain = "CurrentPaneDomain" }),
},
{
key = "h",
mods = "LEADER",
action = action.ActivatePaneDirection("Left"),
},
{
key = "n",
mods = "LEADER",
action = action.ActivatePaneDirection("Down"),
},
{
key = "e",
mods = "LEADER",
action = action.ActivatePaneDirection("Up"),
},
{
key = "i",
mods = "LEADER",
action = action.ActivatePaneDirection("Right"),
},
{
key = "H",
mods = "LEADER",
action = action.AdjustPaneSize({ "Left", 5 }),
},
{
key = "N",
mods = "LEADER",
action = action.AdjustPaneSize({ "Down", 5 }),
},
{
key = "E",
mods = "LEADER",
action = action.AdjustPaneSize({ "Up", 5 }),
},
{
key = "I",
mods = "LEADER",
action = action.AdjustPaneSize({ "Right", 5 }),
},
{
key = "/",
mods = "LEADER",
action = action.Search({ Regex = "" }),
},
{
key = "?",
mods = "LEADER|SHIFT",
action = action.Search({ CaseSensitiveString = "" }),
},
{
key = ";",
mods = "LEADER",
action = action.ShowLauncher,
},
{
key = ":",
mods = "LEADER|SHIFT",
action = action.ActivateCommandPalette,
},
{
key = "W",
mods = "CTRL",
action = action.CloseCurrentPane({ confirm = true }),
},
{ -- ^C to copy if selection is active, otherwise send signal
-- https://wezfurlong.org/wezterm/config/lua/keyassignment/ClearSelection.html?h=selection
key = "c",
mods = "CTRL",
action = wezterm.action_callback(function(window, pane)
local has_selection = window:get_selection_text_for_pane(pane) ~= ""
if has_selection then
window:perform_action(action.CopyTo("ClipboardAndPrimarySelection"), pane)
window:perform_action(action.ClearSelection, pane)
else
window:perform_action(action.SendKey({ key = "c", mods = "CTRL" }), pane)
end
end),
},
}
config.mouse_bindings = {
{
event = { Up = { streak = 1, button = "Left" } },
mods = "CTRL",
action = action.OpenLinkAtMouseCursor,
},
{
event = { Up = { streak = 1, button = "Left" } },
mods = "SUPER",
action = action.OpenLinkAtMouseCursor,
},
}
--#endregion
--#region Environment
config.set_environment_variables = {
}
--#endregion
--#region Launching
if os_type == "Windows" then
config.default_prog = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }
config.launch_menu = {
{
label = "Local - PowerShell",
args = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" },
},
{
label = "Local - PowerShell Administator",
args = { "sudo.exe", "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" },
},
{
label = "WSL1 - Arch",
args = { "wsl.exe", "-d", "Arch" },
},
{
label = "WSL2 - kali-linux",
args = { "wsl.exe", "-d", "kali-linux" },
},
{
label = "Local - NuShell",
args = { "nu" },
},
{
label = "Local - Windows PowerShell",
args = { "powershell.exe" },
},
{
label = "Local - Command Prompt",
args = { "cmd.exe" },
},
{
label = "WSL1 - Arch Zsh",
args = { "wsl.exe", "-d", "Arch", "zsh" },
},
}
elseif os_type == "macOS" then
config.default_prog = { "/opt/homebrew/bin/fish", "-l"}
else
config.default_prog = { "fish" }
config.launch_menu = {
{
label = "Local - Fish",
args = { "fish", "-l" },
},
{
label = "Local - Zsh",
args = { "zsh", "-l" },
},
{
label = "Local - PowerShell",
args = { "pwsh", "-NoLogo", "-NoProfileLoadTime", "-Login" },
},
{
label = "Local - NuShell",
args = { "nu", "-l" },
},
}
end
--#endregion
return config

View file

@ -83,7 +83,7 @@ if command -v apt > /dev/null; then
alias apt="sudo apt"
alias apti="sudo apt install"
alias aptu="sudo apt update && sudo apt upgrade"
alias aptr="sudo apt autoremove && sudo apt remove"
alias aptr="sudo apt remove"
fi
if command -v brew > /dev/null; then

View file

@ -38,8 +38,4 @@ done
# Use `set -k` to mark leading `#` as a comment character
set -k
# # TODO: Below should be reorganized
# export PATH=$HOME/.local/bin:$PATH
# export NVM_DIR="$HOME/.config/nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
source <(fzf --zsh)

View file

@ -37,9 +37,7 @@ bindkey '^B' backward-char
bindkey '^P' up-line-or-history
bindkey '^N' down-line-or-history
bindkey '^R' history-incremental-search-backward
# TODO: did not test
bindkey '^K' kill-line
bindkey '^X^E' edit-command-line
# LEADER CONVENTION
# ^X defines as a prefix key in shell

View file

@ -6,3 +6,4 @@
export STARSHIP_CONFIG=$DOTFILES/tools/starship/starship_zsh.toml
eval "$(starship init zsh)"

View file

@ -158,7 +158,7 @@ if command -v z > /dev/null; then
fi
# zsh .zcompdump
# compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
# Vcpkg TODO: Move vcpkg path
# Vcpkg
if command -v vcpkg > /dev/null; then
export VCPKG_ROOT="$XDG_DATA_HOME"/vcpkg
fi