From 12efeede26f2791e29dd0108f449fa47f0239d57 Mon Sep 17 00:00:00 2001 From: js0ny Date: Thu, 9 Jan 2025 15:16:12 +0000 Subject: [PATCH 1/4] format with stylua --- common/ideavimrc | 152 +++++++++++----- tools/nvim/lua/config/keymaps.lua | 1 - tools/nvim/lua/config/options.lua | 1 - tools/nvim/lua/config/servers.lua | 30 ++-- tools/nvim/lua/keymaps/basic.lua | 6 +- tools/nvim/lua/keymaps/init.lua | 26 ++- tools/nvim/lua/keymaps/language.lua | 20 +-- tools/nvim/lua/keymaps/leaders.lua | 19 +- tools/nvim/lua/keymaps/nvim-tree.lua | 120 ++++++------- tools/nvim/lua/plugins/appearance.lua | 8 +- tools/nvim/lua/plugins/fileutils.lua | 6 +- tools/nvim/lua/plugins/init.lua | 13 +- tools/nvim/lua/plugins/lsp.lua | 32 +++- tools/nvim/lua/plugins/misc.lua | 4 +- tools/nvim/lua/plugins/mod/alpha-nvim.lua | 22 +-- tools/nvim/lua/plugins/mod/auto-session.lua | 8 +- tools/nvim/lua/plugins/mod/bufferline.lua | 30 ++-- tools/nvim/lua/plugins/mod/lspconfig.lua | 2 +- tools/nvim/lua/plugins/mod/lualine.lua | 118 ++++++------- tools/nvim/lua/plugins/mod/markview.lua | 12 +- tools/nvim/lua/plugins/mod/nvim-cmp.lua | 8 +- tools/nvim/lua/plugins/mod/nvim-tree.lua | 9 +- .../nvim/lua/plugins/mod/nvim-treesitter.lua | 18 +- tools/nvim/lua/plugins/mod/obsidian-nvim.lua | 8 +- tools/nvim/lua/plugins/mod/projects.lua | 24 +-- tools/nvim/lua/plugins/mod/telescope.lua | 13 +- tools/nvim/lua/plugins/mod/winbar-nvim.lua | 43 +++-- tools/nvim/lua/plugins/syntax.lua | 7 +- tools/vscode/vscode.vimrc | 163 ++++++++++-------- tools/wezterm/wezterm.lua | 131 +++++++------- 30 files changed, 571 insertions(+), 483 deletions(-) diff --git a/common/ideavimrc b/common/ideavimrc index f1236ac..f4b0436 100644 --- a/common/ideavimrc +++ b/common/ideavimrc @@ -67,6 +67,11 @@ Plug 'easymotion/vim-easymotion' """ Keybindings """ +"" don't lose selection when indenting "" +vnoremap < >gv +vnoremap = =gv + "" edit ideavim config v + "" nnoremap vv :e ~/.ideavimrc nnoremap vr :source ~/.ideavimrc @@ -82,49 +87,7 @@ nmap S (easymotion-F) nmap f (sneak-s) nmap F (sneak-S) -"" Miscs "" -nnoremap : :action GotoAction -nnoremap :action GotoFile - -"" AI Related a + "" -nnoremap ac :action copilot.chat.show -nnoremap ad :action copilot.disableCopilot -nnoremap ae :action copilot.enableCopilot -nnoremap ai :action copilot.openCopilot - -"" Codes Action c + "" -nnoremap cf :action ReformatCode -nnoremap cs :action GotoSymbol -nnoremap c/ :action CommentByLineComment - -"" Project Action p + "" -nnoremap pr :action Run -nnoremap pd :action Debug -nnoremap pb :action Build - -"" Files Action f + "" -nnoremap fe :NERDTreeToggle -nnoremap ft :action ActivateTerminalToolWindow - -"" Tab Actions + "" -nnoremap :action Switcher - -"" Collapse and Expand z + "" -nnoremap zi :action ExpandCollapseToggleAction -nnoremap zc :action CollapseRegion -nnoremap zC :action CollapseRegionRecursively -nnoremap zM :action CollapseAll -nnoremap zo :action ExpandRegion -nnoremap zO :action ExpandRegionRecursively -nnoremap zR :action ExpandAll - -"" don't lose selection when indenting "" -vnoremap < >gv -vnoremap = =gv - - -nnoremap a :action FindInPath +"" Language Server Protocol "" nnoremap gd :action GotoDeclaration nnoremap gtd :action GotoTypeDeclaration nnoremap gtD :action QuickTypeDefinition @@ -136,13 +99,82 @@ nnoremap ga :action nnoremap gq :action ShowIntentionActions nnoremap ge :action GotoNextError -nnoremap :action ParameterInfo -inoremap :action ParameterInfo +"" Collapse and Expand z + "" +nnoremap zi :action ExpandCollapseToggleAction +nnoremap zc :action CollapseRegion +nnoremap zC :action CollapseRegionRecursively +nnoremap zM :action CollapseAll +nnoremap zo :action ExpandRegion +nnoremap zO :action ExpandRegionRecursively +nnoremap zR :action ExpandAll -"" Refractor r + "" +"" Miscs "" +nnoremap : :action GotoAction +nnoremap :action GotoFile +nnoremap h :action PrevSplitter +nnoremap i :action NextSplitter +"" AI Related a + "" +nnoremap ac :action copilot.chat.show +nnoremap ad :action copilot.disableCopilot +nnoremap ae :action copilot.enableCopilot +nnoremap aa :action copilot.openCopilot + +" b : +buffer +nnoremap bb :action Switcher +noremap bd :bdelete +noremap bh :bprevious +noremap bi :bnext +noremap bp :bprevious +noremap bn :bnext + +" c : +code/compile +nnoremap cr :action Run +nnoremap cf :action ReformatCode +nnoremap cs :action GotoSymbol +nnoremap cS :action GotoSymbol +nnoremap cR :action RenameElement +""" Works for Rider only +nnoremap ce :action ReSharperGotoNextErrorInSolution +nnoremap cE :action ReSharperGotoPrevErrorInSolution + +" d : +debug + +" f : +file +nnoremap ff :action GotoFile +nnoremap fF :action TextSearchAction +nnoremap fc :action ShowSettings +nnoremap fC :action ShowSettings +nnoremap fe :NERDTreeToggle +nnoremap fo :OpenInAssociatedApplication +nnoremap ft :action ActivateTerminalToolWindow +nnoremap fx :action WelcomeScreen.Plugins + +" g : +git +nnoremap gp :action Git.Pull +nnoremap gP :action Vcs.Push +nnoremap gb :action Git.Branches +nnoremap gR :action Git.Rebase +nnoremap gM :action Git.Merge +nnoremap gc :action CheckinProject +nnoremap gC :action Git.Clone +nnoremap gg :action ActivateVersionControlToolWindow +nnoremap gS :action Git.Stash + +" h : +help + +" p : +project +nnoremap pr :action Run +nnoremap pd :action Debug +nnoremap pb :action Build + +" q : +quit +nnoremap qq :action Exit +nnoremap Q :action Exit + +" r : +refactor nnoremap ri :action Inline -nnoremap rr :action RenameElement +nnoremap rr :action RenamElement nnoremap rev :action IntroduceVariable vnoremap rev :action IntroduceVariable nnoremap rem :action ExtractMethod @@ -151,6 +183,32 @@ nnoremap rm :action Move nnoremap ro :action OptimizeImports nnoremap rG :action Generate +" t : +test +nnoremap tt :action RiderUnitTestRunSolutionAction +nnoremap tT :action Rider.UnitTesting.MainMenu + +" u : +ui +nnoremap ui :action ChangeLaf +nnoremap uw :action EditorToggleUseSoftWraps + +" w : +write/window +nnoremap ww :write +nnoremap wa :wall +nnoremap wq :wq +nnoremap W :write +nnoremap wh :action PrevSplitter +nnoremap wi :action NextSplitter +nnoremap wH :action SplitHorizontally +nnoremap wI :action SplitHorizontally +nnoremap wN :action SplitVertically +nnoremap wE :action SplitVertically +nnoremap w- :action SplitHorizontally +nnoremap w| :action SplitVertically +nnoremap w\ :action SplitVertically + +nnoremap :action ParameterInfo +inoremap :action ParameterInfo + """ Handling Ctrls """ sethandler i:ide diff --git a/tools/nvim/lua/config/keymaps.lua b/tools/nvim/lua/config/keymaps.lua index dfc1d55..85058c1 100644 --- a/tools/nvim/lua/config/keymaps.lua +++ b/tools/nvim/lua/config/keymaps.lua @@ -1,2 +1 @@ require("keymaps") - diff --git a/tools/nvim/lua/config/options.lua b/tools/nvim/lua/config/options.lua index dea8357..a3d6e36 100644 --- a/tools/nvim/lua/config/options.lua +++ b/tools/nvim/lua/config/options.lua @@ -54,4 +54,3 @@ opt.sidescrolloff = 10 opt.conceallevel = 2 vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" - diff --git a/tools/nvim/lua/config/servers.lua b/tools/nvim/lua/config/servers.lua index 38cc888..e99c5da 100644 --- a/tools/nvim/lua/config/servers.lua +++ b/tools/nvim/lua/config/servers.lua @@ -3,21 +3,21 @@ --- 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 + "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 } M.server_config = { diff --git a/tools/nvim/lua/keymaps/basic.lua b/tools/nvim/lua/keymaps/basic.lua index 00fa177..325c6ae 100644 --- a/tools/nvim/lua/keymaps/basic.lua +++ b/tools/nvim/lua/keymaps/basic.lua @@ -5,8 +5,8 @@ local keymaps_basic = { -- Modification of Original Keymap - Colemak { mode = mode_arrow, keys = "e", cmd = "k" }, { mode = mode_arrow, keys = "i", cmd = "l" }, { keys = "H", cmd = ":bprevious" }, - { keys = "N", cmd = "J" }, - { keys = "E", cmd = "K" }, + { keys = "N", cmd = "5j" }, + { keys = "E", cmd = "5k" }, { keys = "I", cmd = ":bnext" }, { keys = "l", cmd = "i" }, { keys = "L", cmd = "I" }, @@ -14,7 +14,7 @@ local keymaps_basic = { -- Modification of Original Keymap - Colemak { keys = "K", cmd = "N" }, { keys = "j", cmd = "e" }, { keys = "J", cmd = "E" }, - { keys = "Y", cmd = "y$"}, + { keys = "Y", cmd = "y$" }, } return keymaps_basic diff --git a/tools/nvim/lua/keymaps/init.lua b/tools/nvim/lua/keymaps/init.lua index 4849d72..ed688e2 100644 --- a/tools/nvim/lua/keymaps/init.lua +++ b/tools/nvim/lua/keymaps/init.lua @@ -11,8 +11,6 @@ local function set_keymaps(maps, default_opts, default_mode) end end - - local keymaps_basic = require("keymaps.basic") local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global local keymaps_leader = require("keymaps.leaders") @@ -26,25 +24,25 @@ M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin --- `map` default for `cmp.mapping` function M.cmp_nvim_keymaps(map) return { - { keys = "", cmd = map.select_next_item(), desc = "Select next completion item" }, - { keys = "", cmd = map.select_prev_item(), desc = "Select previous completion item" }, - { keys = "", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, - { keys = "", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, - { keys = "", cmd = map.complete(), desc = "Trigger completion" }, - { keys = "", cmd = map.abort(), desc = "Abort completion" }, + { keys = "", cmd = map.select_next_item(), desc = "Select next completion item" }, + { keys = "", cmd = map.select_prev_item(), desc = "Select previous completion item" }, + { keys = "", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, + { keys = "", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, + { keys = "", cmd = map.complete(), desc = "Trigger completion" }, + { keys = "", cmd = map.abort(), desc = "Abort completion" }, } end local function set_markdown_keymaps(bufnr) - local opts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("v", "`", "c`\"`", opts) + local opts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("v", "`", 'c`"`', opts) end vim.api.nvim_create_autocmd("FileType", { - pattern = "markdown", - callback = function() - set_markdown_keymaps(0) - end, + pattern = "markdown", + callback = function() + set_markdown_keymaps(0) + end, }) require("keymaps.language") diff --git a/tools/nvim/lua/keymaps/language.lua b/tools/nvim/lua/keymaps/language.lua index 29f5d97..a2093b1 100644 --- a/tools/nvim/lua/keymaps/language.lua +++ b/tools/nvim/lua/keymaps/language.lua @@ -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`pi`" , desc = "Wrap selection in ` for inline code" }, - { mode = "v", keys = "*", cmd = "c**pi**" , desc = "Wrap selection in ** for bold" }, - { mode = "v", keys = "_", cmd = "c*pi*" , desc = "Wrap selection in * for italic" }, + { mode = "v", keys = "`", cmd = "c`pi`", desc = "Wrap selection in ` for inline code" }, + { mode = "v", keys = "*", cmd = "c**pi**", desc = "Wrap selection in ** for bold" }, + { mode = "v", keys = "_", cmd = "c*pi*", 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 diff --git a/tools/nvim/lua/keymaps/leaders.lua b/tools/nvim/lua/keymaps/leaders.lua index 3cfe04a..e79bd3f 100644 --- a/tools/nvim/lua/keymaps/leaders.lua +++ b/tools/nvim/lua/keymaps/leaders.lua @@ -2,10 +2,17 @@ local M = {} local leader_general = { { keys = "", cmd = ":Telescope find_files", desc = "Find Files" }, - { keys = "/", cmd = ":Telescope live_grep", desc = "Grep Files" }, + { keys = "/", cmd = ":Telescope live_grep", desc = "Grep Files" }, + { keys = "-", cmd = ":split", desc = "Split to down" }, + { keys = "\\", cmd = ":vsplit", desc = "Split to right" }, + { keys = "|", cmd = ":vsplit", desc = "Split to right" }, + { keys = "h", cmd = "h", desc = "Left Window" }, + { keys = "n", cmd = "j", desc = "Down Window" }, + { keys = "e", cmd = "k", desc = "Up Window" }, + { keys = "i", cmd = "l", desc = "Right Window" }, } -for _,map in ipairs(leader_general) do +for _, map in ipairs(leader_general) do map.keys = "" .. map.keys table.insert(M, map) end @@ -36,9 +43,9 @@ local leader_w = { -- leader w: Windows Management } local leader_f = { -- leader f: Files/Find - { keys = "f", cmd = ":Telescope fd", desc = "Find Files"}, - { keys = "s", cmd = ":Telescope live_grep", desc = "Grep Files"}, - { keys = "b", cmd = ":Telescope buffers", desc = "List Buffers"}, + { keys = "f", cmd = ":Telescope fd", desc = "Find Files" }, + { keys = "s", cmd = ":Telescope live_grep", desc = "Grep Files" }, + { keys = "b", cmd = ":Telescope buffers", desc = "List Buffers" }, { keys = "e", cmd = ":NvimTreeToggle", desc = "Toggle File Explorer" }, } @@ -46,6 +53,7 @@ local leader_p = { -- leader p: Project } local leader_b = { -- leader b: Buffer + { keys = "a", cmd = ":Alpha", desc = "Dashboard" }, { keys = "d", cmd = ":bdelete", desc = "Delete Buffer" }, { keys = "h", cmd = ":bprevious", desc = "Previous Buffer" }, { keys = "i", cmd = ":bnext", desc = "Next Buffer" }, @@ -54,6 +62,7 @@ local leader_b = { -- leader b: Buffer { keys = "0", cmd = ":bfirst", desc = "First Buffer" }, { keys = "^", cmd = ":bfirst", desc = "First Buffer" }, { keys = "$", cmd = ":blast", desc = "Last Buffer" }, + { keys = "s", cmd = ":Telescope buffers", desc = "Search buffers" }, } for _, map in ipairs(leader_q) do diff --git a/tools/nvim/lua/keymaps/nvim-tree.lua b/tools/nvim/lua/keymaps/nvim-tree.lua index 2e8f57b..262944e 100644 --- a/tools/nvim/lua/keymaps/nvim-tree.lua +++ b/tools/nvim/lua/keymaps/nvim-tree.lua @@ -8,73 +8,73 @@ function M.plugin(api, opts) -- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua` return { -- Toggle - { keys = "e", cmd = ":NvimTreeToggle", opts = opts("Toggle") }, + { keys = "e", cmd = ":NvimTreeToggle", 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 = "", cmd = api.node.navigate.parent_close, opts = opts("Close node") }, - { keys = "", cmd = api.node.open.edit, opts = opts("Open") }, - { keys = "", cmd = api.node.open.preview, opts = opts("Open Preview") }, + { keys = "", cmd = api.node.navigate.parent_close, opts = opts("Close node") }, + { keys = "", cmd = api.node.open.edit, opts = opts("Open") }, + { keys = "", 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") }, -- 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 = "", cmd = api.tree.change_root_to_node, opts = opts("CD") }, - { keys = "", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") }, - { keys = "", cmd = api.node.show_info_popup, opts = opts("Info") }, - { keys = "", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") }, - { keys = "", cmd = api.node.open.tab, opts = opts("Open: New Tab") }, - { keys = "", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") }, - { keys = "", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") }, + { keys = "", cmd = api.tree.change_root_to_node, opts = opts("CD") }, + { keys = "", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") }, + { keys = "", cmd = api.node.show_info_popup, opts = opts("Info") }, + { keys = "", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") }, + { keys = "", cmd = api.node.open.tab, opts = opts("Open: New Tab") }, + { keys = "", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") }, + { keys = "", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") }, -- 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 diff --git a/tools/nvim/lua/plugins/appearance.lua b/tools/nvim/lua/plugins/appearance.lua index f6c58b3..c6e8f88 100644 --- a/tools/nvim/lua/plugins/appearance.lua +++ b/tools/nvim/lua/plugins/appearance.lua @@ -2,8 +2,8 @@ return { { "catppuccin/nvim", name = "catppuccin" }, { "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 +18,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" }, } diff --git a/tools/nvim/lua/plugins/fileutils.lua b/tools/nvim/lua/plugins/fileutils.lua index 1744739..ec30275 100644 --- a/tools/nvim/lua/plugins/fileutils.lua +++ b/tools/nvim/lua/plugins/fileutils.lua @@ -1,6 +1,6 @@ return { { import = "plugins.mod.auto-session" }, - { import = "plugins.mod.nvim-tree" }, - { import = "plugins.mod.telescope" }, - { import = "plugins.mod.projects" } + { import = "plugins.mod.nvim-tree" }, + { import = "plugins.mod.telescope" }, + { import = "plugins.mod.projects" }, } diff --git a/tools/nvim/lua/plugins/init.lua b/tools/nvim/lua/plugins/init.lua index 866228d..53217be 100644 --- a/tools/nvim/lua/plugins/init.lua +++ b/tools/nvim/lua/plugins/init.lua @@ -15,12 +15,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then 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" }, + { import = "plugins.appearance" }, + { import = "plugins.completion" }, + { import = "plugins.fileutils" }, + { import = "plugins.lsp" }, + { import = "plugins.syntax" }, + { import = "plugins.misc" }, }) diff --git a/tools/nvim/lua/plugins/lsp.lua b/tools/nvim/lua/plugins/lsp.lua index 67931fe..ea0cd3a 100644 --- a/tools/nvim/lua/plugins/lsp.lua +++ b/tools/nvim/lua/plugins/lsp.lua @@ -1,29 +1,28 @@ - return { { import = "plugins.mod.lspconfig" }, { "NoahTheDuke/vim-just", - ft = { "just" } + ft = { "just" }, }, { import = "plugins.mod.render-markdown" }, -- { import = "plugins.mod.markview" }, { "lervag/vimtex", - lazy = false, -- we don't want to lazy load 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 + 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() + require("luasnip-latex-snippets").setup() -- or setup({ use_treesitter = true }) - require("luasnip").config.setup { enable_autosnippets = true } + require("luasnip").config.setup({ enable_autosnippets = true }) end, }, { "williamboman/mason.nvim", config = true }, @@ -41,6 +40,25 @@ 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, }, } diff --git a/tools/nvim/lua/plugins/misc.lua b/tools/nvim/lua/plugins/misc.lua index 15b2070..ae0965e 100644 --- a/tools/nvim/lua/plugins/misc.lua +++ b/tools/nvim/lua/plugins/misc.lua @@ -1,5 +1,5 @@ return { - { 'wakatime/vim-wakatime', lazy = false }, + { "wakatime/vim-wakatime", lazy = false }, { import = "plugins.mod.obsidian-nvim" }, { "folke/which-key.nvim", @@ -22,5 +22,5 @@ return { { "github/copilot.vim", lazy = false, - } + }, } diff --git a/tools/nvim/lua/plugins/mod/alpha-nvim.lua b/tools/nvim/lua/plugins/mod/alpha-nvim.lua index 3fe33dc..5db1a28 100644 --- a/tools/nvim/lua/plugins/mod/alpha-nvim.lua +++ b/tools/nvim/lua/plugins/mod/alpha-nvim.lua @@ -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'), - dashboard.button('h', ' 历史文件', ':Telescope oldfiles'), - dashboard.button('l', ' 加载会话', ':SessionSearch'), - dashboard.button('c', ' 转到设置', ':Telescope find_files cwd=~/.config/nvim'), - dashboard.button('SPC q', '󱊷 退出', ':qa'), + dashboard.button("p", "󰈞 查找项目", ":Telescope projects"), + dashboard.button("h", " 历史文件", ":Telescope oldfiles"), + dashboard.button("l", " 加载会话", ":SessionSearch"), + dashboard.button("c", " 转到设置", ":Telescope find_files cwd=~/.config/nvim"), + dashboard.button("SPC q", "󱊷 退出", ":qa"), } 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, + }, } diff --git a/tools/nvim/lua/plugins/mod/auto-session.lua b/tools/nvim/lua/plugins/mod/auto-session.lua index 80ab9f7..829f1c5 100644 --- a/tools/nvim/lua/plugins/mod/auto-session.lua +++ b/tools/nvim/lua/plugins/mod/auto-session.lua @@ -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', - } - } + }, + }, } diff --git a/tools/nvim/lua/plugins/mod/bufferline.lua b/tools/nvim/lua/plugins/mod/bufferline.lua index e389de8..c02f345 100644 --- a/tools/nvim/lua/plugins/mod/bufferline.lua +++ b/tools/nvim/lua/plugins/mod/bufferline.lua @@ -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, } diff --git a/tools/nvim/lua/plugins/mod/lspconfig.lua b/tools/nvim/lua/plugins/mod/lspconfig.lua index a190a7c..3d657d0 100644 --- a/tools/nvim/lua/plugins/mod/lspconfig.lua +++ b/tools/nvim/lua/plugins/mod/lspconfig.lua @@ -1,4 +1,4 @@ return { "neovim/nvim-lspconfig", - lazy = false + lazy = false, } diff --git a/tools/nvim/lua/plugins/mod/lualine.lua b/tools/nvim/lua/plugins/mod/lualine.lua index 5cddc86..7282117 100644 --- a/tools/nvim/lua/plugins/mod/lualine.lua +++ b/tools/nvim/lua/plugins/mod/lualine.lua @@ -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) diff --git a/tools/nvim/lua/plugins/mod/markview.lua b/tools/nvim/lua/plugins/mod/markview.lua index 98e7261..f4a097f 100644 --- a/tools/nvim/lua/plugins/mod/markview.lua +++ b/tools/nvim/lua/plugins/mod/markview.lua @@ -15,16 +15,16 @@ return { shift_width = 1, heading_1 = { style = "label", - hl = "MarkviewH1" - } + hl = "MarkviewH1", + }, }, code_blocks = { style = "language", language_direction = "right", hl = "MarkviewCode", - info_hl = "MarkviewCodeInfo" - } + info_hl = "MarkviewCodeInfo", + }, }) - end - } + end, + }, } diff --git a/tools/nvim/lua/plugins/mod/nvim-cmp.lua b/tools/nvim/lua/plugins/mod/nvim-cmp.lua index 100697b..165da17 100644 --- a/tools/nvim/lua/plugins/mod/nvim-cmp.lua +++ b/tools/nvim/lua/plugins/mod/nvim-cmp.lua @@ -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 { diff --git a/tools/nvim/lua/plugins/mod/nvim-tree.lua b/tools/nvim/lua/plugins/mod/nvim-tree.lua index 32c312c..53b0bf0 100644 --- a/tools/nvim/lua/plugins/mod/nvim-tree.lua +++ b/tools/nvim/lua/plugins/mod/nvim-tree.lua @@ -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,10 @@ 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 + }) + end, } diff --git a/tools/nvim/lua/plugins/mod/nvim-treesitter.lua b/tools/nvim/lua/plugins/mod/nvim-treesitter.lua index f4366fc..ca5ba90 100644 --- a/tools/nvim/lua/plugins/mod/nvim-treesitter.lua +++ b/tools/nvim/lua/plugins/mod/nvim-treesitter.lua @@ -1,11 +1,11 @@ return { - "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, + "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, } diff --git a/tools/nvim/lua/plugins/mod/obsidian-nvim.lua b/tools/nvim/lua/plugins/mod/obsidian-nvim.lua index f20b8e8..b71bef5 100644 --- a/tools/nvim/lua/plugins/mod/obsidian-nvim.lua +++ b/tools/nvim/lua/plugins/mod/obsidian-nvim.lua @@ -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,11 +26,11 @@ return { }, completion = { nvim_cmp = true, - min_chars = 2 + min_chars = 2, }, ui = { - enable = false - } + enable = false, + }, -- see below for full list of options 👇 }, } diff --git a/tools/nvim/lua/plugins/mod/projects.lua b/tools/nvim/lua/plugins/mod/projects.lua index 9135b33..d8b66e0 100644 --- a/tools/nvim/lua/plugins/mod/projects.lua +++ b/tools/nvim/lua/plugins/mod/projects.lua @@ -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" }, } diff --git a/tools/nvim/lua/plugins/mod/telescope.lua b/tools/nvim/lua/plugins/mod/telescope.lua index b5dba1e..5f1f53a 100644 --- a/tools/nvim/lua/plugins/mod/telescope.lua +++ b/tools/nvim/lua/plugins/mod/telescope.lua @@ -1,7 +1,7 @@ return { "nvim-telescope/telescope.nvim", - config = function () - require("telescope").setup { + config = function() + require("telescope").setup({ defaults = { mappings = { n = { @@ -11,11 +11,10 @@ return { ["r"] = "preview_scrolling_down", ["a"] = "preview_scrolling_left", ["s"] = "preview_scrolling_right", - } - } - } - } + }, + }, + }, + }) end, dependencies = { "nvim-lua/plenary.nvim" }, } - diff --git a/tools/nvim/lua/plugins/mod/winbar-nvim.lua b/tools/nvim/lua/plugins/mod/winbar-nvim.lua index ca27161..496ce0c 100644 --- a/tools/nvim/lua/plugins/mod/winbar-nvim.lua +++ b/tools/nvim/lua/plugins/mod/winbar-nvim.lua @@ -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, }, } - diff --git a/tools/nvim/lua/plugins/syntax.lua b/tools/nvim/lua/plugins/syntax.lua index f32cff2..eea5c64 100644 --- a/tools/nvim/lua/plugins/syntax.lua +++ b/tools/nvim/lua/plugins/syntax.lua @@ -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, }, } - diff --git a/tools/vscode/vscode.vimrc b/tools/vscode/vscode.vimrc index 84ab90d..f63ba45 100644 --- a/tools/vscode/vscode.vimrc +++ b/tools/vscode/vscode.vimrc @@ -50,14 +50,102 @@ noremap gpt editor.action.peekTypeDefinition noremap gh editor.action.showDefinitionPreviewHover noremap workbench.action.quickOpen +noremap / workbench.action.quickTextSearch noremap : workbench.action.showCommands noremap E workbench.view.explorer +noremap - workbench.action.splitEditorDown +noremap | workbench.action.splitEditorRight +noremap \ workbench.action.splitEditorRight + +" a : +ai/action +noremap aa inlineChat.start +noremap aA workbench.panel.chat +noremap ae workbench.action.chat.openEditSession + +" b : +buffer +noremap bb workbench.action.showAllEditors +noremap bd :bdelete +noremap bh :bprevious +noremap bi :bnext +noremap bp :bprevious +noremap bn :bnext + +" c : +code/compile +noremap cr code-runner.run +noremap cf editor.action.formatDocument +noremap c editor.action.trimTrailingWhitespace +noremap cs workbench.action.gotoSymbol +noremap cS workbench.action.showAllSymbols +noremap ce editor.action.marker.next +noremap cE editor.action.marker.prev +noremap cg editor.action.dirtydiff.next +noremap cG editor.action.dirtydiff.previous +noremap cR editor.action.rename + +" d : +debug + +" f : +file +noremap ff workbench.action.quickOpen +noremap fF workbench.view.search +noremap fc workbench.action.openSettings +noremap fC workbench.action.openFolderSettingsFile +noremap fe workbench.view.explorer +noremap fo openInExternalApp.open +noremap fr workbench.action.showAllEditorsByMostRecentlyUsed +noremap fR git.rename " Rename file +" noremap fs workbench.action.search.toggleQueryDetails +noremap ft workbench.action.terminal.toggleTerminal +noremap fx workbench.view.extensions + +" g : +git +noremap gg workbench.view.scm +noremap gS git.stageAll + +" h : +help + +" j : +jump +noremap jj workbench.action.gotoLine + +" l : +language (define in settings.json) + +" p : +project (requires Project Manager extension) +noremap pp projectManager.listProjects +noremap pP projectManager.listAnyProjects#sideBarAny +noremap pc projectManager.openSettings#sideBarAny +noremap pe projectManager.editProjects +noremap pf projectManager.addToFavorites +noremap pF projectManager.filterProjectsByTag +noremap pg projectManager.listGitProjects#sideBarGit +noremap pr workbench.action.openRecent +noremap ps projectManager.saveProject " q : +quit noremap qq :quit noremap qQ :qall noremap Q :quit +" r : +refactor + +" s : +search + +" t : +test +noremap tt testing.runAll +noremap tT testing.debugAll +noremap ta testing.runAll +noremap tA testing.debugAll +noremap tf testing.reRunFailedTests +noremap tF testing.debugFailedTests +noremap tl testing.reRunLastRun +noremap tL testing.debugLastRun +noremap tc testing.runCurrentTest +noremap tC testing.debugCurrentTest +noremap tx testing.cancelTestRun + +" u : +ui +noremap ui workbench.action.selectTheme +noremap uw editor.action.toggleWordWrap +noremap uz workbench.action.toggleZenMode + " w : +write/window noremap ww :write noremap wa :wall @@ -71,75 +159,6 @@ noremap we workbench.action.focusAboveGroup noremap wE workbench.action.splitEditorUp noremap wi workbench.action.focusRightGroup noremap wI workbench.action.splitEditorRight - -" f : +find/file -noremap ff workbench.action.quickOpen -noremap fF workbench.view.search -noremap fc workbench.action.openSettings -noremap fC workbench.action.openFolderSettingsFile -noremap fe workbench.view.explorer -noremap fr workbench.action.showAllEditorsByMostRecentlyUsed -noremap fR workbench.action.openRecent -noremap fs workbench.action.search.toggleQueryDetails -noremap ft workbench.action.terminal.toggleTerminal -noremap fx workbench.view.extensions - -" p : +project (requires Project Manager extension) -noremap pp projectManager.listProjects -noremap pP projectManager.listAnyProjects#sideBarAny -noremap pc projectManager.openSettings#sideBarAny -noremap pe projectManager.editProjects -noremap pf projectManager.addToFavorites -noremap pF projectManager.filterProjectsByTag -noremap pg projectManager.listGitProjects#sideBarGit -noremap pr workbench.action.openRecent -noremap ps projectManager.saveProject - -" g : +git -noremap gg workbench.view.scm -noremap gS git.stageAll - -" j : +jump -noremap jj workbench.action.gotoLine - -" l : +language (define in settings.json) - -" u : +ui -noremap ui workbench.action.selectTheme -noremap uw editor.action.toggleWordWrap -noremap uz workbench.action.toggleZenMode -" a : +ai/action -noremap aa inlineChat.start -noremap aA workbench.panel.chat -noremap ae workbench.action.chat.openEditSession -" r : +refactor -" s : +search -" t : +test -noremap tt testing.runAll -noremap tT testing.debugAll -noremap ta testing.runAll -noremap tA testing.debugAll -noremap tf testing.reRunFailedTests -noremap tF testing.debugFailedTests -noremap tl testing.reRunLastRun -noremap tL testing.debugLastRun -noremap tc testing.runCurrentTest -noremap tC testing.debugCurrentTest -noremap tx testing.cancelTestRun -" d : +debug -" h : +help - -" c : +code -noremap cr code-runner.run -noremap cf editor.action.formatDocument -noremap c editor.action.trimTrailingWhitespace -noremap cs workbench.action.gotoSymbol -noremap cS workbench.action.showAllSymbols - -" b : +buffer -noremap bb workbench.action.showAllEditors -noremap bd :bdelete -noremap bh :bprevious -noremap bi :bnext - -" 中文分词测试用例 +noremap w- workbench.action.splitEditorDown +noremap w| workbench.action.splitEditorRight +noremap w\ workbench.action.splitEditorRight diff --git a/tools/wezterm/wezterm.lua b/tools/wezterm/wezterm.lua index b90ce40..4b39b4d 100644 --- a/tools/wezterm/wezterm.lua +++ b/tools/wezterm/wezterm.lua @@ -3,7 +3,7 @@ -- Author: js0ny --#region Import & Setup -local wezterm = require 'wezterm' +local wezterm = require("wezterm") local action = wezterm.action local config = {} @@ -52,15 +52,13 @@ local function detect_os() end -- OS light/dark theme detection -local function detect_theme() -end +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' @@ -88,11 +86,11 @@ config.tab_bar_at_bottom = true -- config.cursor_blink_rate = 650 -- Visual Bell config.visual_bell = { - fade_in_function = 'EaseIn', + fade_in_function = "EaseIn", fade_in_duration_ms = 250, - fade_out_function = 'EaseOut', + fade_out_function = "EaseOut", fade_out_duration_ms = 250, - target = 'CursorColor', + target = "CursorColor", } --#endregion @@ -100,111 +98,111 @@ config.visual_bell = { config.leader = { key = "q", mods = "CTRL" } config.keys = { { - key = 'q', - mods = 'LEADER', - action = action.SendKey { key = 'q', mods = 'CTRL' }, + 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|SHIFT", + action = action.SplitHorizontal({ domain = "CurrentPaneDomain" }), }, { - key = '-', - mods = 'LEADER', - action = action.SplitVertical { domain = "CurrentPaneDomain" } + key = "-", + mods = "LEADER", + action = action.SplitVertical({ domain = "CurrentPaneDomain" }), }, { - key = 'h', - mods = 'LEADER', - action = action.ActivatePaneDirection 'Left' + key = "h", + mods = "LEADER", + action = action.ActivatePaneDirection("Left"), }, { - key = 'n', - mods = 'LEADER', - action = action.ActivatePaneDirection 'Down' + key = "n", + mods = "LEADER", + action = action.ActivatePaneDirection("Down"), }, { - key = 'e', - mods = 'LEADER', - action = action.ActivatePaneDirection 'Up' + key = "e", + mods = "LEADER", + action = action.ActivatePaneDirection("Up"), }, { - key = 'i', - mods = 'LEADER', - action = action.ActivatePaneDirection 'Right' + key = "i", + mods = "LEADER", + action = action.ActivatePaneDirection("Right"), }, { - key = 'H', - mods = 'LEADER', - action = action.AdjustPaneSize { 'Left', 5 }, + key = "H", + mods = "LEADER", + action = action.AdjustPaneSize({ "Left", 5 }), }, { - key = 'N', - mods = 'LEADER', - action = action.AdjustPaneSize { 'Down', 5 }, + key = "N", + mods = "LEADER", + action = action.AdjustPaneSize({ "Down", 5 }), }, { - key = 'E', - mods = 'LEADER', - action = action.AdjustPaneSize { 'Up', 5 }, + key = "E", + mods = "LEADER", + action = action.AdjustPaneSize({ "Up", 5 }), }, { - key = 'I', - mods = 'LEADER', - action = action.AdjustPaneSize { 'Right', 5 }, + key = "I", + mods = "LEADER", + action = action.AdjustPaneSize({ "Right", 5 }), }, { key = "/", mods = "LEADER", - action = action.Search { Regex = "" } + action = action.Search({ Regex = "" }), }, { key = "?", mods = "LEADER|SHIFT", - action = action.Search { CaseSensitiveString = "" } + action = action.Search({ CaseSensitiveString = "" }), }, { key = ";", mods = "LEADER", - action = action.ShowLauncher + action = action.ShowLauncher, }, { key = ":", mods = "LEADER|SHIFT", - action = action.ActivateCommandPalette + action = action.ActivateCommandPalette, }, { key = "W", mods = "CTRL", - action = action.CloseCurrentPane { confirm = true } + 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', + key = "c", + mods = "CTRL", action = wezterm.action_callback(function(window, pane) - local has_selection = window:get_selection_text_for_pane(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.CopyTo("ClipboardAndPrimarySelection"), pane) window:perform_action(action.ClearSelection, pane) else - window:perform_action(action.SendKey { key = 'c', mods = 'CTRL' }, pane) + window:perform_action(action.SendKey({ key = "c", mods = "CTRL" }), pane) end end), }, } config.mouse_bindings = { { - event = { Up = { streak = 1, button = 'Left' } }, - mods = 'CTRL', + event = { Up = { streak = 1, button = "Left" } }, + mods = "CTRL", action = action.OpenLinkAtMouseCursor, }, { - event = { Up = { streak = 1, button = 'Left' } }, - mods = 'SUPER', + event = { Up = { streak = 1, button = "Left" } }, + mods = "SUPER", action = action.OpenLinkAtMouseCursor, }, } @@ -222,35 +220,35 @@ if os_type == "Windows" then config.launch_menu = { { label = "Local - PowerShell", - args = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" } + args = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }, }, { label = "Local - PowerShell Administator", - args = { "sudo.exe", "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" } + args = { "sudo.exe", "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }, }, { label = "WSL1 - Arch", - args = { "wsl.exe", "-d", "Arch" } + args = { "wsl.exe", "-d", "Arch" }, }, { label = "WSL2 - kali-linux", - args = { "wsl.exe", "-d", "kali-linux" } + args = { "wsl.exe", "-d", "kali-linux" }, }, { label = "Local - NuShell", - args = { "nu" } + args = { "nu" }, }, { label = "Local - Windows PowerShell", - args = { "powershell.exe" } + args = { "powershell.exe" }, }, { label = "Local - Command Prompt", - args = { "cmd.exe" } + args = { "cmd.exe" }, }, { label = "WSL1 - Arch Zsh", - args = { "wsl.exe", "-d", "Arch", "zsh" } + args = { "wsl.exe", "-d", "Arch", "zsh" }, }, } else @@ -258,23 +256,22 @@ else config.launch_menu = { { label = "Local - Fish", - args = { "fish", "-l" } + args = { "fish", "-l" }, }, { label = "Local - Zsh", - args = { "zsh", "-l" } + args = { "zsh", "-l" }, }, { label = "Local - PowerShell", - args = { "pwsh", "-NoLogo", "-NoProfileLoadTime", "-Login" } + args = { "pwsh", "-NoLogo", "-NoProfileLoadTime", "-Login" }, }, { label = "Local - NuShell", - args = { "nu", "-l" } + args = { "nu", "-l" }, }, } end --#endregion - return config From 073c60f07dfbe8ea870acf36a3ac07e69814dbe0 Mon Sep 17 00:00:00 2001 From: js0ny Date: Sun, 12 Jan 2025 22:36:49 +0000 Subject: [PATCH 2/4] feat(nvim): More leader mappings and text objects --- bootstrap/set_symlink_unix.bash | 5 +- common/lazygit.yaml | 115 +------------------- tools/fish/conf.d/0init.fish | 8 +- tools/nvim/init.lua | 15 ++- tools/nvim/lua/config/colorscheme.lua | 2 +- tools/nvim/lua/keymaps/basic.lua | 11 +- tools/nvim/lua/keymaps/init.lua | 1 + tools/nvim/lua/keymaps/leaders.lua | 85 ++++++++++++++- tools/nvim/lua/keymaps/nvim-tree.lua | 2 + tools/nvim/lua/keymaps/user-command.lua | 30 +++++ tools/nvim/lua/plugins/appearance.lua | 2 + tools/nvim/lua/plugins/fileutils.lua | 43 ++++++++ tools/nvim/lua/plugins/lsp.lua | 2 + tools/nvim/lua/plugins/misc.lua | 7 ++ tools/nvim/lua/plugins/mod/conform-nvim.lua | 38 +++++++ tools/nvim/lua/plugins/mod/nvim-tree.lua | 16 +++ tools/nvim/lua/plugins/mod/telescope.lua | 12 ++ 17 files changed, 264 insertions(+), 130 deletions(-) create mode 100644 tools/nvim/lua/keymaps/user-command.lua create mode 100644 tools/nvim/lua/plugins/mod/conform-nvim.lua diff --git a/bootstrap/set_symlink_unix.bash b/bootstrap/set_symlink_unix.bash index 6c7227c..3e36ff0 100644 --- a/bootstrap/set_symlink_unix.bash +++ b/bootstrap/set_symlink_unix.bash @@ -3,7 +3,7 @@ # Date: 2024-12-01 # Author: js0ny # Set symbolic links for Unix-like systems -mkdir -p $XDG_CONFIG_HOME/conda $XDG_CONFIG_HOME/git $XDG_CONFIG_HOME/ideavim $XDG_CONFIG_HOME/markdownlint $XDG_CONFIG_HOME/pip $XDG_CONFIG_HOME/neovide $XDG_CONFIG_HOME/powershell $XDG_CONFIG_HOME/vscode $XDG_CONFIG_HOME/NuGet $XDG_CONFIG_HOME/vim $XDG_CONFIG_HOME/tmux $XDG_CONFIG_HOME/npm $XDG_CONFIG_HOME/readline $XDG_CONFIG_HOME/ipython +mkdir -p $XDG_CONFIG_HOME/conda $XDG_CONFIG_HOME/git $XDG_CONFIG_HOME/ideavim $XDG_CONFIG_HOME/markdownlint $XDG_CONFIG_HOME/pip $XDG_CONFIG_HOME/neovide $XDG_CONFIG_HOME/powershell $XDG_CONFIG_HOME/vscode $XDG_CONFIG_HOME/NuGet $XDG_CONFIG_HOME/vim $XDG_CONFIG_HOME/tmux $XDG_CONFIG_HOME/npm $XDG_CONFIG_HOME/readline $XDG_CONFIG_HOME/ipython $XDG_CONFIG_HOME/lazygit # Not support XDG_CONFIG_HOME but same directory mkdir -p ~/.config/zellij ~/.config/yazi ~/.config/glow # mkdir -p $WAKATIME_HOME @@ -15,6 +15,7 @@ cp $DOTFILES/common/gitconfig.example $XDG_CONFIG_HOME/git/config ln -sf $DOTFILES/common/glow.yaml ~/.config/glow/config.yml ln -sf $DOTFILES/common/haskeline ~/.haskeline ln -sf $DOTFILES/common/ideavimrc $XDG_CONFIG_HOME/ideavim/ideavimrc +ln -sf $DOTFILES/common/lazygit.yaml $XDG_CONFIG_HOME/lazygit/config.yml ln -sf $DOTFILES/common/lesskey $XDG_CONFIG_HOME/lesskey # ln -sf $DOTFILES/common/npmrc $NPM_CONFIG_USERCONFIG ln -sf $DOTFILES/common/NuGet.Config $XDG_CONFIG_HOME/NuGet/NuGet.Config @@ -37,5 +38,5 @@ if [ $(uname) = "Darwin" ]; then ln -sf $DOTFILES/platforms/mac/sketchybarrc $XDG_CONFIG_HOME/sketchybar/sketchybarrc ln -sf $DOTFILES/platforms/mac/yabairc $XDG_CONFIG_HOME/yabai/yabairc else - ln -sf $DOTFILES/common/inputrc $XDG_CONFIG_HOME/readline/inputrc + ln -sf $DOTFILES/common/inputrc ~/.inputrc fi diff --git a/common/lazygit.yaml b/common/lazygit.yaml index c4a5cc5..6b45e2b 100644 --- a/common/lazygit.yaml +++ b/common/lazygit.yaml @@ -8,72 +8,54 @@ # Windows: %APPDATA%\lazygit\config.yml yaml-language-server: $schema=https://raw.githubusercontent.com/jesseduffield/lazygit/master/schema/config.json - # Config relating to the Lazygit UI gui: # The number of lines you scroll by when scrolling the main window scrollHeight: 2 - # If true, allow scrolling past the bottom of the content in the main window scrollPastBottom: true - # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#scroll-off-margin scrollOffMargin: 2 - # One of: 'margin' (default) | 'jump' scrollOffBehavior: margin - # If true, capture mouse events. # When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS. mouseEvents: true - # If true, do not show a warning when discarding changes in the staging view. skipDiscardChangeWarning: false - # If true, do not show warning when applying/popping the stash skipStashWarning: false - # If true, do not show a warning when attempting to commit without any staged files; instead stage all unstaged files. skipNoStagedFilesWarning: false - # If true, do not show a warning when rewording a commit via an external editor skipRewordInEditorWarning: false - # Fraction of the total screen width to use for the left side section. You may want to pick a small number (e.g. 0.2) if you're using a narrow screen, so that you can see more of the main section. # Number from 0 to 1.0. sidePanelWidth: 0.3333 - # If true, increase the height of the focused side window; creating an accordion effect. expandFocusedSidePanel: false - # The weight of the expanded side panel, relative to the other panels. 2 means # twice as tall as the other panels. Only relevant if `expandFocusedSidePanel` is true. expandedSidePanelWeight: 2 - # Sometimes the main window is split in two (e.g. when the selected file has both staged and unstaged changes). This setting controls how the two sections are split. # Options are: # - 'horizontal': split the window horizontally # - 'vertical': split the window vertically # - 'flexible': (default) split the window horizontally if the window is wide enough, otherwise split vertically mainPanelSplitMode: flexible - # How the window is split when in half screen mode (i.e. after hitting '+' once). # Possible values: # - 'left': split the window horizontally (side panel on the left, main view on the right) # - 'top': split the window vertically (side panel on top, main view below) enlargedSideViewLocation: left - # One of 'auto' (default) | 'en' | 'zh-CN' | 'zh-TW' | 'pl' | 'nl' | 'ja' | 'ko' | 'ru' language: auto - # Format used when displaying time e.g. commit time. # Uses Go's time format syntax: https://pkg.go.dev/time#Time.Format timeFormat: 02 Jan 06 - # Format used when displaying time if the time is less than 24 hours ago. # Uses Go's time format syntax: https://pkg.go.dev/time#Time.Format shortTimeFormat: 3:04PM - # Config relating to colors and styles. # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#color-attributes theme: @@ -81,134 +63,99 @@ gui: activeBorderColor: - green - bold - # Border color of non-focused windows inactiveBorderColor: - default - # Border color of focused window when searching in that window searchingActiveBorderColor: - cyan - bold - # Color of keybindings help text in the bottom line optionsTextColor: - blue - # Background color of selected line. # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#highlighting-the-selected-line selectedLineBgColor: - blue - # Background color of selected line when view doesn't have focus. inactiveViewSelectedLineBgColor: - bold - # Foreground color of copied commit cherryPickedCommitFgColor: - blue - # Background color of copied commit cherryPickedCommitBgColor: - cyan - # Foreground color of marked base commit (for rebase) markedBaseCommitFgColor: - blue - # Background color of marked base commit (for rebase) markedBaseCommitBgColor: - yellow - # Color for file with unstaged changes unstagedChangesColor: - red - # Default text color defaultFgColor: - default - # Config relating to the commit length indicator commitLength: # If true, show an indicator of commit message length show: true - # If true, show the '5 of 20' footer at the bottom of list views showListFooter: true - # If true, display the files in the file views as a tree. If false, display the files as a flat list. # This can be toggled from within Lazygit with the '~' key, but that will not change the default. showFileTree: true - # If true, show the number of lines changed per file in the Files view showNumstatInFilesView: false - # If true, show a random tip in the command log when Lazygit starts showRandomTip: true - # If true, show the command log showCommandLog: true - # If true, show the bottom line that contains keybinding info and useful buttons. If false, this line will be hidden except to display a loader for an in-progress action. showBottomLine: true - # If true, show jump-to-window keybindings in window titles. showPanelJumps: true - # Deprecated: use nerdFontsVersion instead showIcons: false - # Nerd fonts version to use. # One of: '2' | '3' | empty string (default) # If empty, do not show icons. nerdFontsVersion: "" - # If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty. showFileIcons: true - # Length of author name in (non-expanded) commits view. 2 means show initials only. commitAuthorShortLength: 2 - # Length of author name in expanded commits view. 2 means show initials only. commitAuthorLongLength: 17 - # Length of commit hash in commits view. 0 shows '*' if NF icons aren't on. commitHashLength: 8 - # If true, show commit hashes alongside branch names in the branches view. showBranchCommitHash: false - # Whether to show the divergence from the base branch in the branches view. # One of: 'none' | 'onlyArrow' | 'arrowAndNumber' showDivergenceFromBaseBranch: none - # Height of the command log view commandLogSize: 8 - # Whether to split the main window when viewing file changes. # One of: 'auto' | 'always' # If 'auto', only split the main window when a file has both staged and unstaged changes splitDiff: auto - # Default size for focused window. Window size can be changed from within Lazygit with '+' and '_' (but this won't change the default). # One of: 'normal' (default) | 'half' | 'full' - windowSize: normal - + screenMode: normal # Window border style. # One of 'rounded' (default) | 'single' | 'double' | 'hidden' border: rounded - # If true, show a seriously epic explosion animation when nuking the working tree. animateExplosion: true - # Whether to stack UI components on top of each other. # One of 'auto' (default) | 'always' | 'never' portraitMode: auto - # How things are filtered when typing '/'. # One of 'substring' (default) | 'fuzzy' filterMode: substring - # Config relating to the spinner. spinner: # The frames of the spinner animation. @@ -217,116 +164,86 @@ gui: - / - "-" - \ - # The "speed" of the spinner in milliseconds. rate: 50 - # Status panel view. # One of 'dashboard' (default) | 'allBranchesLog' statusPanelView: dashboard - # If true, jump to the Files panel after popping a stash switchToFilesAfterStashPop: true - # If true, jump to the Files panel after applying a stash switchToFilesAfterStashApply: true - # If true, when using the panel jump keys (default 1 through 5) and target panel is already active, go to next tab instead switchTabsWithPanelJumpKeys: false - # Config relating to git git: # See https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_Pagers.md paging: # Value of the --color arg in the git diff command. Some pagers want this to be set to 'always' and some want it set to 'never' colorArg: always - # e.g. # diff-so-fancy # delta --dark --paging=never # ydiff -p cat -s --wrap --width={{columnWidth}} - pager: "" - + pager: "delta --dark --paging=never" # If true, Lazygit will use whatever pager is specified in `$GIT_PAGER`, `$PAGER`, or your *git config*. If the pager ends with something like ` | less` we will strip that part out, because less doesn't play nice with our rendering approach. If the custom pager uses less under the hood, that will also break rendering (hence the `--paging=never` flag for the `delta` pager). useConfig: false - # e.g. 'difft --color=always' externalDiffCommand: "" - # Config relating to committing commit: # If true, pass '--signoff' flag when committing signOff: false - # Automatic WYSIWYG wrapping of the commit message as you type autoWrapCommitMessage: true - # If autoWrapCommitMessage is true, the width to wrap to autoWrapWidth: 72 - # Config relating to merging merging: # If true, run merges in a subprocess so that if a commit message is required, Lazygit will not hang # Only applicable to unix users. manualCommit: false - # Extra args passed to `git merge`, e.g. --no-ff args: "" - # The commit message to use for a squash merge commit. Can contain "{{selectedRef}}" and "{{currentBranch}}" placeholders. squashMergeMessage: Squash merge {{selectedRef}} into {{currentBranch}} - # list of branches that are considered 'main' branches, used when displaying commits mainBranches: - master - main - # Prefix to use when skipping hooks. E.g. if set to 'WIP', then pre-commit hooks will be skipped when the commit message starts with 'WIP' skipHookPrefix: WIP - # If true, periodically fetch from remote autoFetch: true - # If true, periodically refresh files and submodules autoRefresh: true - # If true, pass the --all arg to git fetch fetchAll: true - # If true, lazygit will automatically stage files that used to have merge # conflicts but no longer do; and it will also ask you if you want to # continue a merge or rebase if you've resolved all conflicts. If false, it # won't do either of these things. autoStageResolvedConflicts: true - # Command used when displaying the current branch git log in the main window branchLogCmd: git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} -- - # Command used to display git log of all branches in the main window. # Deprecated: Use `allBranchesLogCmds` instead. allBranchesLogCmd: git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium - # If true, do not spawn a separate process when using GPG overrideGpg: false - # If true, do not allow force pushes disableForcePushing: false - # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#predefined-commit-message-prefix commitPrefix: # pattern to match on. E.g. for 'feature/AB-123' to match on the AB-123 use "^\\w+\\/(\\w+-\\w+).*" pattern: "" - # Replace directive. E.g. for 'feature/AB-123' to start the commit message with 'AB-123 ' use "[$1] " replace: "" - # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#predefined-branch-name-prefix branchPrefix: "" - # If true, parse emoji strings in commit messages e.g. render :rocket: as 🚀 # (This should really be under 'gui', not 'git') parseEmoji: false - # Config for showing the log in the commits view log: # One of: 'date-order' | 'author-date-order' | 'topo-order' | 'default' @@ -335,110 +252,84 @@ git: # # Deprecated: Configure this with `Log menu -> Commit sort order` ( in the commits window by default). order: topo-order - # This determines whether the git graph is rendered in the commits panel # One of 'always' | 'never' | 'when-maximised' # # Deprecated: Configure this with `Log menu -> Show git graph` ( in the commits window by default). showGraph: always - # displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`) showWholeGraph: false - # When copying commit hashes to the clipboard, truncate them to this # length. Set to 40 to disable truncation. truncateCopiedCommitHashesTo: 12 - # Periodic update checks update: # One of: 'prompt' (default) | 'background' | 'never' method: prompt - # Period in days between update checks days: 14 - # Background refreshes refresher: # File/submodule refresh interval in seconds. # Auto-refresh can be disabled via option 'git.autoRefresh'. refreshInterval: 10 - # Re-fetch interval in seconds. # Auto-fetch can be disabled via option 'git.autoFetch'. fetchInterval: 60 - # If true, show a confirmation popup before quitting Lazygit confirmOnQuit: false - # If true, exit Lazygit when the user presses escape in a context where there is nothing to cancel/close quitOnTopLevelReturn: false - # Config relating to things outside of Lazygit like how files are opened, copying to clipboard, etc os: # Command for editing a file. Should contain "{{filename}}". edit: "" - # Command for editing a file at a given line number. Should contain # "{{filename}}", and may optionally contain "{{line}}". editAtLine: "" - # Same as EditAtLine, except that the command needs to wait until the # window is closed. editAtLineAndWait: "" - # For opening a directory in an editor openDirInEditor: "" - # A built-in preset that sets all of the above settings. Supported presets # are defined in the getPreset function in editor_presets.go. editPreset: "" - # Command for opening a file, as if the file is double-clicked. Should # contain "{{filename}}", but doesn't support "{{line}}". open: "" - # Command for opening a link. Should contain "{{link}}". openLink: "" - # EditCommand is the command for editing a file. # Deprecated: use Edit instead. Note that semantics are different: # EditCommand is just the command itself, whereas Edit contains a # "{{filename}}" variable. editCommand: "" - # EditCommandTemplate is the command template for editing a file # Deprecated: use EditAtLine instead. editCommandTemplate: "" - # OpenCommand is the command for opening a file # Deprecated: use Open instead. openCommand: "" - # OpenLinkCommand is the command for opening a link # Deprecated: use OpenLink instead. openLinkCommand: "" - # CopyToClipboardCmd is the command for copying to clipboard. # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-command-for-copying-to-and-pasting-from-clipboard copyToClipboardCmd: "" - # ReadFromClipboardCmd is the command for reading the clipboard. # See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-command-for-copying-to-and-pasting-from-clipboard readFromClipboardCmd: "" - # If true, don't display introductory popups upon opening Lazygit. disableStartupPopups: false - # What to do when opening Lazygit outside of a git repo. # - 'prompt': (default) ask whether to initialize a new repo or open in the most recent repo # - 'create': initialize a new repo # - 'skip': open most recent repo # - 'quit': exit Lazygit notARepository: prompt - # If true, display a confirmation when subprocess terminates. This allows you to view the output of the subprocess before returning to Lazygit. promptToReturnFromSubprocess: true - # Keybindings keybinding: universal: @@ -493,10 +384,8 @@ keybinding: scrollDownMain-alt2: executeShellCommand: ":" createRebaseOptionsMenu: m - # 'Files' appended for legacy reasons pushFiles: P - # 'Files' appended for legacy reasons pullFiles: p refresh: R diff --git a/tools/fish/conf.d/0init.fish b/tools/fish/conf.d/0init.fish index d9c9a3f..8205f12 100644 --- a/tools/fish/conf.d/0init.fish +++ b/tools/fish/conf.d/0init.fish @@ -139,7 +139,13 @@ end # Coursier: Scala dependency manager if command -v coursier > /dev/null - set -gx PATH "$PATH:/home/js0ny/.local/share/coursier/bin" + 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 diff --git a/tools/nvim/init.lua b/tools/nvim/init.lua index cdb5629..709d609 100644 --- a/tools/nvim/init.lua +++ b/tools/nvim/init.lua @@ -7,10 +7,16 @@ ]] -- 针对特定文件类型设置快捷键 vim.api.nvim_create_autocmd("FileType", { - pattern = "markdown", -- 指定文件类型 - callback = function() - vim.api.nvim_buf_set_keymap(0, "v", "`", "c`\"`", { noremap = true, silent = true, desc = "Wrap selection with backticks" }) - end, + pattern = "markdown", -- 指定文件类型 + callback = function() + vim.api.nvim_buf_set_keymap( + 0, + "v", + "`", + 'c`"`', + { noremap = true, silent = true, desc = "Wrap selection with backticks" } + ) + end, }) -- 加载配置 @@ -24,5 +30,4 @@ require("config.plugins") -- 加载主题 require("config.colorscheme") - -- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/tools/nvim/lua/config/colorscheme.lua b/tools/nvim/lua/config/colorscheme.lua index d57d784..853c9a0 100644 --- a/tools/nvim/lua/config/colorscheme.lua +++ b/tools/nvim/lua/config/colorscheme.lua @@ -1 +1 @@ -vim.cmd.colorscheme("catppuccin") +vim.cmd.colorscheme("kanagawa") diff --git a/tools/nvim/lua/keymaps/basic.lua b/tools/nvim/lua/keymaps/basic.lua index 325c6ae..0a4f4eb 100644 --- a/tools/nvim/lua/keymaps/basic.lua +++ b/tools/nvim/lua/keymaps/basic.lua @@ -1,20 +1,23 @@ local mode_arrow = { "n", "v", "o", "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" }, + { mode = mode_arrow, keys = "n", cmd = "j", desc = "Down" }, + { mode = mode_arrow, keys = "e", cmd = "k", desc = "Up" }, + { mode = mode_arrow, keys = "i", cmd = "l", desc = "Right" }, { keys = "H", cmd = ":bprevious" }, { keys = "N", cmd = "5j" }, { keys = "E", cmd = "5k" }, { keys = "I", cmd = ":bnext" }, - { keys = "l", cmd = "i" }, + -- Text object implementation + { mode = { "n", "o", "x" }, keys = "l", cmd = "i", group = "inside" }, { 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#L60 + { keys = "", cmd = "nohlsearchdiffupdate" }, } return keymaps_basic diff --git a/tools/nvim/lua/keymaps/init.lua b/tools/nvim/lua/keymaps/init.lua index ed688e2..fc1284f 100644 --- a/tools/nvim/lua/keymaps/init.lua +++ b/tools/nvim/lua/keymaps/init.lua @@ -1,4 +1,5 @@ local M = {} +local keymaps_user_command = require("keymaps.user-command") local global_default_opts = { noremap = true, silent = true } local global_default_mode = { "n" } -- local mode_arrow = { "n", "v", "o", "s", "x" } diff --git a/tools/nvim/lua/keymaps/leaders.lua b/tools/nvim/lua/keymaps/leaders.lua index e79bd3f..88afe83 100644 --- a/tools/nvim/lua/keymaps/leaders.lua +++ b/tools/nvim/lua/keymaps/leaders.lua @@ -1,5 +1,34 @@ local M = {} +local formatFx = function() + require("conform").format({ async = true }) +end + +local renameCurrentBuffer = function() + local old_name = vim.fn.expand("%:p") + local new_name = vim.fn.input("New name: ", vim.fn.expand("%:p:h") .. "/") + + if new_name == "" then + print("No new name provided") + return + elseif new_name == old_name then + return + end + + vim.cmd("write") + + local success, err = os.rename(old_name, new_name) + if not success then + print("Error renaming file: " .. err) + return + end + + vim.cmd("edit " .. new_name) + vim.cmd("bdelete " .. old_name) +end + +vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {}) + local leader_general = { { keys = "", cmd = ":Telescope find_files", desc = "Find Files" }, { keys = "/", cmd = ":Telescope live_grep", desc = "Grep Files" }, @@ -42,18 +71,28 @@ local leader_w = { -- leader w: Windows Management { keys = "I", cmd = ":resize -5", desc = "Decrease Window Width" }, } -local leader_f = { -- leader f: Files/Find +local leader_f = { -- f: +files/find { keys = "f", cmd = ":Telescope fd", desc = "Find Files" }, { keys = "s", cmd = ":Telescope live_grep", desc = "Grep Files" }, { keys = "b", cmd = ":Telescope buffers", desc = "List Buffers" }, { keys = "e", cmd = ":NvimTreeToggle", desc = "Toggle File Explorer" }, + { keys = "t", cmd = ":FloatermToggle", desc = "toggle visibility of the float terminal" }, + { keys = "T", cmd = ":FloatermNew", desc = "Spawn a float terminal" }, + { keys = "h", cmd = ":Telescope oldfiles", desc = "Search history files" }, + { keys = "c", cmd = ":Telescope find_files cwd=~/.config/nvim", desc = "Search Config" }, + { keys = "o", cmd = ":!open %", desc = "Open file in default program" }, + { keys = "R", cmd = renameCurrentBuffer, desc = "Rename current file" }, } local leader_p = { -- leader p: Project + { keys = "p", cmd = ":Telescope projects", desc = "List all Projects" }, + { keys = "g", cmd = ":Telescope projects", desc = "List all Git Projects" }, + { keys = "s", cmd = ":Telescope session-lens", desc = "List all sessions" }, } -local leader_b = { -- leader b: Buffer - { keys = "a", cmd = ":Alpha", desc = "Dashboard" }, +local leader_b = { -- b: +buffer + { keys = "a", cmd = ":Alpha", desc = "Dashboard" }, + { keys = "b", cmd = ":Telescope buffers", desc = "List Buffers" }, { keys = "d", cmd = ":bdelete", desc = "Delete Buffer" }, { keys = "h", cmd = ":bprevious", desc = "Previous Buffer" }, { keys = "i", cmd = ":bnext", desc = "Next Buffer" }, @@ -62,7 +101,25 @@ local leader_b = { -- leader b: Buffer { keys = "0", cmd = ":bfirst", desc = "First Buffer" }, { keys = "^", cmd = ":bfirst", desc = "First Buffer" }, { keys = "$", cmd = ":blast", desc = "Last Buffer" }, - { keys = "s", cmd = ":Telescope buffers", desc = "Search buffers" }, + -- { keys = "s", cmd = ":Telescope buffers", desc = "Search buffers" }, +} + +local leader_t = { -- t: +toggle/test + { keys = "f", cmd = ":NvimTreeToggle", desc = "Toggle File Explorer" }, + { keys = "F", cmd = ":FormatToggle", desc = "Toggle autoformat-on-save" }, + { keys = "t", cmd = ":FloatermToggle", desc = "toggle visibility of the float terminal" }, +} + +local leader_c = { -- c: +code/compile + { keys = "r", cmd = ":RunCode", desc = "Run code" }, + { keys = "e", cmd = ":Telescope diagnostics", desc = "Navigate errors/warnings" }, + { keys = "f", cmd = formatFx, desc = "Format buffer" }, + { keys = "s", cmd = ":Telescope treesitter", desc = "Search symbols" }, + { keys = "S", cmd = ":Telescope grep_string", desc = "Search current symbol" }, +} + +local leader_u = { -- u: +ui + { keys = "i", cmd = ":Telescope colorscheme", desc = "Change colorscheme" }, } for _, map in ipairs(leader_q) do @@ -85,4 +142,24 @@ for _, map in ipairs(leader_b) do table.insert(M, map) end +for _, map in ipairs(leader_c) do + map.keys = "c" .. map.keys + table.insert(M, map) +end + +for _, map in ipairs(leader_t) do + map.keys = "t" .. map.keys + table.insert(M, map) +end + +for _, map in ipairs(leader_u) do + map.keys = "u" .. map.keys + table.insert(M, map) +end + +for _, map in ipairs(leader_p) do + map.keys = "p" .. map.keys + table.insert(M, map) +end + return M diff --git a/tools/nvim/lua/keymaps/nvim-tree.lua b/tools/nvim/lua/keymaps/nvim-tree.lua index 262944e..b0e2736 100644 --- a/tools/nvim/lua/keymaps/nvim-tree.lua +++ b/tools/nvim/lua/keymaps/nvim-tree.lua @@ -55,6 +55,8 @@ function M.plugin(api, opts) { 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 = "set relativenumber!", opts = opts("Toggle Relative Number") }, -- Numeric 数字键 { keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") }, -- Non-Alphanumeric 非字母数字键 diff --git a/tools/nvim/lua/keymaps/user-command.lua b/tools/nvim/lua/keymaps/user-command.lua new file mode 100644 index 0000000..3395e44 --- /dev/null +++ b/tools/nvim/lua/keymaps/user-command.lua @@ -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, +}) diff --git a/tools/nvim/lua/plugins/appearance.lua b/tools/nvim/lua/plugins/appearance.lua index c6e8f88..8557752 100644 --- a/tools/nvim/lua/plugins/appearance.lua +++ b/tools/nvim/lua/plugins/appearance.lua @@ -1,5 +1,7 @@ return { { "catppuccin/nvim", name = "catppuccin" }, + { "olimorris/onedarkpro.nvim" }, + { "rebelot/kanagawa.nvim" }, { "RRethy/vim-illuminate" }, { "nvim-lualine/lualine.nvim", diff --git a/tools/nvim/lua/plugins/fileutils.lua b/tools/nvim/lua/plugins/fileutils.lua index ec30275..95f49c6 100644 --- a/tools/nvim/lua/plugins/fileutils.lua +++ b/tools/nvim/lua/plugins/fileutils.lua @@ -3,4 +3,47 @@ return { { 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", "", function() + require("hover").hover_switch("previous") + end, { desc = "hover.nvim (previous source)" }) + vim.keymap.set("n", "", function() + require("hover").hover_switch("next") + end, { desc = "hover.nvim (next source)" }) + + -- Mouse support + vim.keymap.set("n", "", require("hover").hover_mouse, { desc = "hover.nvim (mouse)" }) + vim.o.mousemoveevent = true + end, + }, } diff --git a/tools/nvim/lua/plugins/lsp.lua b/tools/nvim/lua/plugins/lsp.lua index ea0cd3a..f067dd6 100644 --- a/tools/nvim/lua/plugins/lsp.lua +++ b/tools/nvim/lua/plugins/lsp.lua @@ -61,4 +61,6 @@ return { -- }) end, }, + { import = "plugins.mod.conform-nvim" }, + { "nvim-treesitter/nvim-treesitter-context" }, } diff --git a/tools/nvim/lua/plugins/misc.lua b/tools/nvim/lua/plugins/misc.lua index ae0965e..6fecdc5 100644 --- a/tools/nvim/lua/plugins/misc.lua +++ b/tools/nvim/lua/plugins/misc.lua @@ -1,7 +1,14 @@ return { { "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 = { diff --git a/tools/nvim/lua/plugins/mod/conform-nvim.lua b/tools/nvim/lua/plugins/mod/conform-nvim.lua new file mode 100644 index 0000000..159f80a --- /dev/null +++ b/tools/nvim/lua/plugins/mod/conform-nvim.lua @@ -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, +} diff --git a/tools/nvim/lua/plugins/mod/nvim-tree.lua b/tools/nvim/lua/plugins/mod/nvim-tree.lua index 53b0bf0..66091d9 100644 --- a/tools/nvim/lua/plugins/mod/nvim-tree.lua +++ b/tools/nvim/lua/plugins/mod/nvim-tree.lua @@ -31,6 +31,22 @@ return { on_attach = my_on_attach, sync_root_with_cwd = true, respect_buf_cwd = true, + 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, } diff --git a/tools/nvim/lua/plugins/mod/telescope.lua b/tools/nvim/lua/plugins/mod/telescope.lua index 5f1f53a..108395a 100644 --- a/tools/nvim/lua/plugins/mod/telescope.lua +++ b/tools/nvim/lua/plugins/mod/telescope.lua @@ -3,6 +3,17 @@ return { 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", @@ -11,6 +22,7 @@ return { ["r"] = "preview_scrolling_down", ["a"] = "preview_scrolling_left", ["s"] = "preview_scrolling_right", + ["q"] = require("telescope.actions").close, }, }, }, From e5fb48289f569a8d57e0f21854f9abe63cc8f252 Mon Sep 17 00:00:00 2001 From: js0ny Date: Mon, 13 Jan 2025 10:21:34 +0000 Subject: [PATCH 3/4] feat(surfingkeys): Implement visual mode and ACE editor keymaps --- .gitignore | 2 + Justfile | 7 +- .../linux/{hyprland => }/hypr/hyprland.conf | 0 .../linux/{hyprland => }/hypr/hyprpaper.conf | 0 .../{hyprland => wayland}/code-flags.conf | 4 +- .../{hyprland => wayland}/electron-flags.conf | 4 +- tools/browser/surfingkeys.js | 463 ++++++++++++------ tools/nvim/lua/keymaps/nvim-tree.lua | 2 + tools/zsh/mod/prompt.zsh | 3 +- 9 files changed, 327 insertions(+), 158 deletions(-) rename platforms/linux/{hyprland => }/hypr/hyprland.conf (100%) rename platforms/linux/{hyprland => }/hypr/hyprpaper.conf (100%) rename platforms/linux/{hyprland => wayland}/code-flags.conf (86%) rename platforms/linux/{hyprland => wayland}/electron-flags.conf (87%) diff --git a/.gitignore b/.gitignore index 725742f..09a3366 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ platforms/win/komorebi/applications.json gitconfig *.exe + +spacemacs/ diff --git a/Justfile b/Justfile index 271933b..76ac4b8 100644 --- a/Justfile +++ b/Justfile @@ -1,4 +1,5 @@ -set shell := ["pwsh", "-c"] +set shell := ["fish", "-c"] +set windows-shell := ["pwsh", "-c"] pull: git pull github master @@ -7,3 +8,7 @@ pull: push: git push github master git push codeberg master + +init: + git remote add github git@github.com:js0ny/dotfiles.git + git remote add codeberg git@codeberg.org:js0ny/dotfiles.git diff --git a/platforms/linux/hyprland/hypr/hyprland.conf b/platforms/linux/hypr/hyprland.conf similarity index 100% rename from platforms/linux/hyprland/hypr/hyprland.conf rename to platforms/linux/hypr/hyprland.conf diff --git a/platforms/linux/hyprland/hypr/hyprpaper.conf b/platforms/linux/hypr/hyprpaper.conf similarity index 100% rename from platforms/linux/hyprland/hypr/hyprpaper.conf rename to platforms/linux/hypr/hyprpaper.conf diff --git a/platforms/linux/hyprland/code-flags.conf b/platforms/linux/wayland/code-flags.conf similarity index 86% rename from platforms/linux/hyprland/code-flags.conf rename to platforms/linux/wayland/code-flags.conf index 0333988..5a37672 100644 --- a/platforms/linux/hyprland/code-flags.conf +++ b/platforms/linux/wayland/code-flags.conf @@ -10,5 +10,5 @@ # --enable-features=UseOzonePlatform # --ozone-platform=wayland ---ozone-platform-hint=x11 -# --enable-wayland-ime +--ozone-platform-hint=auto +--enable-wayland-ime diff --git a/platforms/linux/hyprland/electron-flags.conf b/platforms/linux/wayland/electron-flags.conf similarity index 87% rename from platforms/linux/hyprland/electron-flags.conf rename to platforms/linux/wayland/electron-flags.conf index 020a9de..7ff2980 100644 --- a/platforms/linux/hyprland/electron-flags.conf +++ b/platforms/linux/wayland/electron-flags.conf @@ -11,5 +11,5 @@ # --enable-features=UseOzonePlatform # --ozone-platform=wayland # --enable-icd -# --enable-wayland-ime ---ozone-platform-hint=x11 +--ozone-platform-hint=auto +--enable-wayland-ime diff --git a/tools/browser/surfingkeys.js b/tools/browser/surfingkeys.js index 604a63e..e8fe28f 100644 --- a/tools/browser/surfingkeys.js +++ b/tools/browser/surfingkeys.js @@ -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 @@ -25,245 +24,405 @@ 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; 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)) - } -} - - -const vforward = { - add: function (key) { // 转发即将被 unmap 的键 - return api.vmap(`vfor${key}`, key) + api.map(colemak.use(a), forward.use(b)); }, - cancel: function (key) { // 删除转发生成的键 - api.vunmap(`vfor${key}`) - api.vunmap(key) +}; + +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}`) + return `vfor${key}`; + }, +}; +const vColemak = { + forward: function (key) { + // 转发即将被 unmap 的键 + api.vmap(key, `vcol${key}`); + api.vunmap(`vcol${key}`); }, use: function (key) { - return `vcol${key}` + return `vcol${key}`; }, map: function (a, b) { - api.vmap(vcolemak.use(a), vforward.use(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 + }, +}; +const vForwardFactory = { + push: function (mapLists) { + // forward original keys for (let key in mapLists) { - vforward.add(mapLists[key]) + vForward.add(mapLists[key]); } }, map: function (mapLists) { for (let key in mapLists) { - vcolemak.map(key, mapLists[key]) + vColemak.map(key, mapLists[key]); } }, pull: function (mapLists) { for (let key in mapLists) { - vforward.cancel(mapLists[key]) + vForward.cancel(mapLists[key]); } for (let key in mapLists) { - vcolemak.forward(key) + vColemak.forward(key); } - } -} + }, +}; const parseSearchResponse = function (response) { const res = JSON.parse(response.text); - return res.map(r => r.phrase); + return res.map((r) => r.phrase); }; -const _addSearchAlias = function (alias, name, searchUrl, searchPrefix = 's', acUrl = "https://duckduckgo.com/ac/?q=", parseResponse = parseSearchResponse) { - api.addSearchAlias(alias, name, searchUrl, searchPrefix, acUrl, parseResponse); -} +const _addSearchAlias = function ( + alias, + name, + searchUrl, + searchPrefix = "s", + acUrl = "https://duckduckgo.com/ac/?q=", + 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) +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(""); // Leader Key +forwardFactory.pull(mapLists); +vForwardFactory.pull(vMapLists); // #endregion - // #region Search Alias -api.unmap('os') // StackOverflow -api.vunmap('ss') -api.unmap('ob') // Baidu -api.vunmap('sb') -api.unmap('og') // Google -api.vunmap('sg') -api.unmap('od') // DuckDuckGo -api.vunmap('sd') +api.unmap("os"); // StackOverflow +api.vunmap("ss"); +api.unmap("ob"); // Baidu +api.vunmap("sb"); +api.unmap("og"); // Google +api.vunmap("sg"); +api.unmap("od"); // DuckDuckGo +api.vunmap("sd"); +api.unmap("ow"); // Bing +api.vunmap("sw"); /// 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("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="); /// 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("fe", "Felo", "https://felo.ai/search?q="); +_addSearchAlias("pp", "Perplexity", "https://www.perplexity.ai/?q="); +_addSearchAlias("cg", "ChatGPT", "https://chat.openai.com/?q="); /// EECS Related -_addSearchAlias('gh', 'GitHub', 'https://github.com/search?type=repositories&q=') -_addSearchAlias('so', 'StackOverflow', 'https://stackoverflow.com/search?q=') -_addSearchAlias('aw', 'ArchWiki', 'https://wiki.archlinux.org/index.php?search=') +_addSearchAlias( + "gh", + "GitHub", + "https://github.com/search?type=repositories&q=", +); +_addSearchAlias("so", "StackOverflow", "https://stackoverflow.com/search?q="); +_addSearchAlias( + "aw", + "ArchWiki", + "https://wiki.archlinux.org/index.php?search=", +); /// Software -_addSearchAlias('sc', 'Scoop', 'https://scoop.sh/#/apps?q=') -_addSearchAlias('br', 'Brew', 'https://duckduckgo.com/?q=!brew ') +_addSearchAlias("sc", "Scoop", "https://scoop.sh/#/apps?q="); +_addSearchAlias("br", "Brew", "https://duckduckgo.com/?q=!brew "); // #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.mapkey('an', 'New Chat', 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('as', 'Start/Stop Generating', function () { - var btn = document.querySelector('button.h-8:nth-child(2)'); - btn.click(); -}, { domain: /chatgpt.com/ }); -api.mapkey('as', '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('', /perplexity.ai/); - +api.unmap("", /perplexity.ai/); // allows to use perplexity web keybindings +api.map(); + +// #endregion + +// #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 }, + }, + + // Word movement + { + keys: "j", + type: "motion", + motion: "moveByWords", + motionArgs: { forward: true, wordEnd: true, inclusive: true }, + }, + { + keys: "J", + type: "motion", + motion: "moveByWords", + motionArgs: { + forward: true, + wordEnd: true, + bigWord: true, + inclusive: true, + }, + }, + + // Insert mode entries + { + keys: "l", + type: "action", + action: "enterInsertMode", + isEdit: true, + actionArgs: { insertAt: "inplace" }, + context: "normal", + }, + { + keys: "gl", + type: "action", + action: "enterInsertMode", + isEdit: true, + actionArgs: { insertAt: "lastEdit" }, + context: "normal", + }, + { + keys: "L", + type: "action", + action: "enterInsertMode", + isEdit: true, + actionArgs: { insertAt: "firstNonBlank" }, + context: "normal", + }, + { + keys: "gL", + type: "action", + action: "enterInsertMode", + isEdit: true, + actionArgs: { insertAt: "bol" }, + context: "normal", + }, + { + keys: "L", + type: "action", + action: "enterInsertMode", + isEdit: true, + actionArgs: { insertAt: "startOfSelectedArea" }, + context: "visual", + }, + { + keys: "n", + type: "motion", + motion: "moveByLines", + motionArgs: { forward: true, linewise: true }, + }, + { + keys: "e", + type: "motion", + motion: "moveByLines", + motionArgs: { forward: false, linewise: true }, + }, + { + keys: "i", + type: "motion", + motion: "moveByCharacters", + motionArgs: { forward: true }, + }, + { + keys: "H", + type: "keyToKey", + toKeys: "^", + }, + { + keys: "I", + type: "keyToKey", + toKeys: "$", + }, + { + keys: "Y", + type: "keyToKey", + toKeys: "y$", + }, +); // #endregion diff --git a/tools/nvim/lua/keymaps/nvim-tree.lua b/tools/nvim/lua/keymaps/nvim-tree.lua index b0e2736..0fa4446 100644 --- a/tools/nvim/lua/keymaps/nvim-tree.lua +++ b/tools/nvim/lua/keymaps/nvim-tree.lua @@ -2,6 +2,7 @@ local M = {} M.global = { { mode = "n", keys = "e", cmd = ":NvimTreeToggle" }, + { mode = "n", keys = "", cmd = ":NvimTreeFocus" }, } function M.plugin(api, opts) @@ -74,6 +75,7 @@ function M.plugin(api, opts) { keys = "", cmd = api.node.open.tab, opts = opts("Open: New Tab") }, { keys = "", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") }, { keys = "", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") }, + { keys = "", cmd = ":b#", 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") }, diff --git a/tools/zsh/mod/prompt.zsh b/tools/zsh/mod/prompt.zsh index 67d111b..1f4ec4e 100644 --- a/tools/zsh/mod/prompt.zsh +++ b/tools/zsh/mod/prompt.zsh @@ -3,6 +3,7 @@ # Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 -# export STARSHIP_CONFIG=$DOTFILES/tools/starship/starship_zsh.toml +export STARSHIP_CONFIG=$DOTFILES/tools/starship/starship_zsh.toml eval "$(starship init zsh)" + From 11cba4980721c6b35e8ef89d4ba9baacb412fd01 Mon Sep 17 00:00:00 2001 From: js0ny Date: Mon, 13 Jan 2025 11:38:12 +0000 Subject: [PATCH 4/4] feat(surfingkeys): Add more search aliases --- tools/browser/surfingkeys.js | 82 +++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 15 deletions(-) diff --git a/tools/browser/surfingkeys.js b/tools/browser/surfingkeys.js index e8fe28f..267c9ec 100644 --- a/tools/browser/surfingkeys.js +++ b/tools/browser/surfingkeys.js @@ -22,7 +22,6 @@ api.unmap(''); // Settings settings.language = "zh-CN"; settings.showModeStatus = false; -// Keymap, reference https://github.com/texiwustion/colemak_config_for_surfingkeys/tree/main // #region Helper const { aceVimMap, @@ -45,6 +44,7 @@ const { Visual, RUNTIME, } = api; +// Keymap, reference https://github.com/texiwustion/colemak_config_for_surfingkeys/tree/main const forward = { add: function (key) { // 转发即将被 unmap 的键 @@ -155,8 +155,8 @@ const _addSearchAlias = function ( alias, name, searchUrl, - searchPrefix = "s", acUrl = "https://duckduckgo.com/ac/?q=", + searchPrefix = "s", parseResponse = parseSearchResponse, ) { api.addSearchAlias( @@ -241,26 +241,42 @@ vForwardFactory.pull(vMapLists); // #endregion // #region Search Alias -api.unmap("os"); // StackOverflow -api.vunmap("ss"); -api.unmap("ob"); // Baidu -api.vunmap("sb"); -api.unmap("og"); // Google -api.vunmap("sg"); -api.unmap("od"); // DuckDuckGo -api.vunmap("sd"); -api.unmap("ow"); // Bing -api.vunmap("sw"); +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", @@ -268,14 +284,42 @@ _addSearchAlias( "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=", ); -/// Software +_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", "Brew", "https://duckduckgo.com/?q=!brew "); +_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 @@ -310,7 +354,11 @@ api.mapkey("as", "Start/Stop Generating", chatgptStartStop, { //}, { domain: /chatgpt.com/ }); // perplexity.ai api.unmap("", /perplexity.ai/); // allows to use perplexity web keybindings -api.map(); +api.mapkey("aB", "Add Perplexity Bookmark", function () { + // button.border:nth-child(2) + var btn = document.querySelector("button.border:nth-child(2)"); + btn.click(); +}); // #endregion @@ -426,3 +474,7 @@ addVimMapKey( ); // #endregion + +// #region Hints +Hints.setNumeric(); +// #endregion