From c80a54e42b52ce297f0f2f71af23c562832025c7 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:35:27 +0900 Subject: init --- ar/.config/NvChad/lua/custom/mappings.lua | 740 ++++++++++++++++++++++++++++++ 1 file changed, 740 insertions(+) create mode 100644 ar/.config/NvChad/lua/custom/mappings.lua (limited to 'ar/.config/NvChad/lua/custom/mappings.lua') diff --git a/ar/.config/NvChad/lua/custom/mappings.lua b/ar/.config/NvChad/lua/custom/mappings.lua new file mode 100644 index 0000000..6ae8646 --- /dev/null +++ b/ar/.config/NvChad/lua/custom/mappings.lua @@ -0,0 +1,740 @@ +---@type MappingsTable +local M = {} +local opts = { noremap = false, expr = true, buffer = true } + +M.disabled = { + n = { + [""] = "", + [""] = "", + [""] = "", + [""] = "", + ["b"] = "", + ["ca"] = "", + ["fm"] = "", + ["n"] = "", + ["rn"] = "", + ["td"] = "", + [""] = "", + [""] = "", + }, + + t = { + [""] = "", + }, +} + +M.general = { + i = { + -- ESC + ["jk"] = { "", "Exit Insert Mode" }, + + -- Navigation + [""] = { "^i", "Beginning Of Line" }, + + -- Lines + [""] = { "o", "Next Line", opts = { nowait = true } }, + [""] = { "O", "Previous Line", opts = { nowait = true } }, + ["ln"] = { " set nu! ", "Toggle Line Number" }, + ["lrn"] = { " set rnu! ", "Toggle Relative Number" }, + }, + + n = { + -- General + [""] = { ":", "Enter Command Mode", opts = { nowait = true } }, + -- ["x"] = { "_x", "No Register x" }, + ["Q"] = { "", "Nothing" }, + + -- Copy & Paste + ["cpa"] = { " %y+ ", "Copy Whole File" }, + ["y"] = { '"+y', "yank in Vim" }, + ["Y"] = { '"+Y', "Yank in Clipboard" }, + -- ["s"] = { [[:%s/\<\>//gI]], "Replace char on cursor" }, + + -- Formatting + ["lfm"] = { + function() + vim.lsp.buf.format { async = true } + end, + "LSP Formatting", + }, + + -- Line + -- [""] = { "o", "Blank line after", opts = { nowait = true } }, + -- [""] = { "O", "Blank line before", opts = { nowait = true } }, + + -- Navigation + ["J"] = { "mzJ`z", "Join A Line To Pre-line" }, + ["n"] = { "nzzzv", "Down Search with Mid Cursor" }, + ["N"] = { "Nzzzv", "Up Search with Mid Cursor" }, + [""] = { "zz", "Jump 1/2 Page with Mid Cursor" }, + [""] = { "zz", "Up 1/2 Page with Mid Cursor" }, + [""] = { "zz", "Page Down with Mid Cursor" }, + [""] = { "zz", "Page Up with Mid Cursor" }, + -- [""] = { "cnextzz", "reset cursor" }, + -- [""] = { "cprevzz", "reset cursor" }, + [""] = { " TmuxNavigateLeft ", "Window Left" }, + [""] = { " TmuxNavigateRight ", "Window Right" }, + [""] = { " TmuxNavigateDown ", "Window Down" }, + [""] = { " TmuxNavigateUp ", "Window Up" }, + ["tg"] = { + function() + require("base46").toggle_theme() + end, + "Theme Toggle", + }, + + -- New Buffer + ["bf"] = { " enew ", "New Buffer" }, + + -- Split + ["sv"] = { "v", "Split Vertically" }, + ["sh"] = { "h", "Split Horizontally" }, + ["se"] = { "=", "Equal Width" }, + ["sx"] = { " close ", "Close Split Window" }, + }, + v = { + [";"] = { ":", "Enter Command Mode", opts = { nowait = true } }, + [">"] = { ">gv", "Indent" }, + [""] = { " ", "Exit Visual Mode" }, + ["J"] = { ":m '>+1gv=gv", "Move A Line To Bottom" }, + ["K"] = { ":m '<-2gv=gv", "Move A Line To Up" }, + ["y"] = { '"+y', "yank in Vim" }, + }, +} + +-- more keybinds! +M.browse = { + n = { + ["bs"] = { + function() + require("browse").input_search() + end, + "Search Bookmarks", + }, + + ["bm"] = { + function() + require("browse").open_bookmarks() + end, + "Browse Bookmarks", + }, + + ["bb"] = { + function() + require("browse").browse() + end, + "Browse Bookmarks", + }, + + ["bd"] = { + function() + require("browse.devdocs").search() + end, + "Search Devdocs", + }, + + ["bn"] = { + function() + require("browse.mdn").search() + end, + "Search MDN", + }, + }, +} + +M.chatgpt = { + n = { + ["cg"] = { " ChatGPT ", "ChatGPT" }, + ["cgc"] = { " ChatGPTCompleteCode ", "ChatGPT Complete Code" }, + ["cgt"] = { " ChatGPTRun add_tests ", "ChatGPT Add Test" }, + ["cgf"] = { " ChatGPTRun fix_bugs ", "ChatGPT Fix Bugs" }, + ["cga"] = { " ChatGPTActAs ", "ChatGPT Act As" }, + ["cgi"] = { " ChatGPTEditWithInstructions ", "ChatGPT Edit" }, + }, + + v = { + ["cge"] = { " ChatGPTRun explain_code ", "ChatGPT Explain Code" }, + }, +} + +M.dadbod = { + n = { + ["db"] = { " DBUI ", "DB UI" }, + ["du"] = { " DBUIToggle ", "Toggle UI" }, + ["da"] = { " DBUIAddConnection ", "Add Connection" }, + ["df"] = { " DBUIFindBuffer ", "Find buffer" }, + ["dr"] = { " DBUIRenameBuffer ", "Rename buffer" }, + ["dl"] = { " DBUILastQueryInfo ", "Last query info" }, + }, +} + +M.gitsigns = { + n = { + ["gd"] = { + function() + require("gitsigns").toggle_deleted() + end, + "Toggle Deleted", + }, + }, +} + +M.harpoon = { + n = { + ["a"] = { + function() + require("harpoon.mark").add_file() + end, + "Harpoon Add File", + }, + ["ta"] = { " Telescope harpoon marks ", "Toggle Quick Menu" }, + [""] = { + function() + require("harpoon.ui").toggle_quick_menu() + end, + "Harpoon Menu", + }, + ["1"] = { + function() + require("harpoon.ui").nav_file(1) + end, + "Navigate to File 1", + }, + ["2"] = { + function() + require("harpoon.ui").nav_file(2) + end, + "Navigate to File 2", + }, + ["3"] = { + function() + require("harpoon.ui").nav_file(3) + end, + "Navigate to File 3", + }, + ["4"] = { + function() + require("harpoon.ui").nav_file(4) + end, + "Navigate to File 4", + }, + }, +} + +M.iron = { + n = { + ["ir"] = { " IronRepl ", "REPL" }, + ["iS"] = { " IronRestart ", "Restart" }, + ["iF"] = { " IronFocus ", "Focus" }, + ["iH"] = { " IronHide ", "Hide" }, + ["ism"] = { + function() + require("iron.core").run_motion "send_motion" + end, + "Send Motion", + }, + ["isl"] = { + function() + require("iron.core").send_line() + end, + "Send Line", + }, + ["ist"] = { + function() + require("iron.core").send_until_cursor() + end, + "Send Until Cursor", + }, + ["isf"] = { + function() + require("iron.core").send_file() + end, + "Send File", + }, + ["i"] = { + function() + require("iron.core").send(nil, string.char(13)) + end, + "ENTER", + }, + ["ii"] = { + function() + require("iron.core").send(nil, string.char(03)) + end, + "Interrupt", + }, + ["id"] = { + function() + require("iron.core").close_repl() + end, + "Close REPL", + }, + ["ic"] = { + function() + require("iron.core").send(nil, string.char(12)) + end, + "Clear", + }, + ["ims"] = { + function() + require("iron.core").send_mark() + end, + "Send Mark", + }, + ["imm"] = { + function() + require("iron.core").run_motion "mark_motion" + end, + "Mark Motion", + }, + ["imr"] = { + function() + require("iron.marks").drop_last() + end, + "Remove Mark", + }, + -- ["iar"] = { + -- function() end, + -- "+ REPL", + -- }, + -- ["iam"] = { + -- function() end, + -- "+ Mark", + -- }, + + -- cell + ["ca"] = { + function() + require("custom.configs.cell_marker").insert_cell_after() + end, + "Insert Cell After", + }, + ["cb"] = { + function() + require("custom.configs.cell_marker").insert_cell_before() + end, + "Insert Cell Before", + }, + ["cm"] = { + function() + require("custom.configs.cell_marker").insert_markdown_cell() + end, + "Insert Markdown Cell", + }, + ["cd"] = { + function() + require("custom.configs.cell_marker").delete_cell() + end, + "Delete Cell", + }, + ["cj"] = { + function() + require("custom.configs.cell_marker").navigate_cell() + end, + "Next Cell", + }, + ["ck"] = { + function() + require("custom.configs.cell_marker").navigate_cell(true) + end, + "Previous Cell", + }, + ["cr"] = { + function() + require("custom.configs.cell_marker").execute_cell() + end, + "Cell Run", + }, + }, + + v = { + ["ihc"] = { + function() + require("iron.marks").clear_hl() + end, + "Clear Highlight", + }, + ["imv"] = { + function() + require("iron.core").mark_visual() + end, + "Mark Visual", + }, + ["is"] = { + function() + require("iron.core").visual_send() + end, + "Send", + }, + }, +} + +M.lspconfig = { + v = { + ["ca"] = { + function() + vim.lsp.buf.code_action() + end, + "LSP code action", + }, + }, +} + +M.markdown = { + n = { + ["mp"] = { " MarkdownPreview ", "Markdown Preview" }, + ["ms"] = { " MarkdownPreviewStop ", "Markdown Stop" }, + ["mt"] = { " MarkdownPreviewToggle ", "Markdown Toggle" }, + }, +} + +M.media = { + n = { + ["fm"] = { " Telescope media_files ", "Media Files" }, + }, +} + +M.nvterm = { + t = { + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "Toggle Floating Term", + }, + }, +} + +M.playground = { + n = { + ["pg"] = { " TSPlaygroundToggle ", "Toggle Playground" }, + ["pc"] = { " TSHighlightCapturesUnderCurso ", "Highlight Captures" }, + ["pn"] = { " TSNodeUnderCursor ", "Node Under Cursor" }, + }, +} + +M.portal = { + n = { + ["pj"] = { " Portal jumplist backward ", "Portal Jumplist" }, + ["ph"] = { + function() + require("portal.builtin").harpoon.tunnel() + end, + "Portal Harpoon", + }, + }, +} + +M.project = { + n = { + ["fp"] = { " Telescope projects ", "Find Project" }, + }, +} + +M.refactoring = { + n = { + -- refactoring + ["ri"] = { " Refactor inline_var ", "Refactor Inline Var" }, + ["rI"] = { " Refactor inline_func ", "Refactor Inline Function" }, + + ["rb"] = { " Refactor extract_block ", "Refactor Extract Block" }, + ["rbf"] = { " Refactor extract_block_to_file ", "Refactor Extrack Block To File" }, + }, + + x = { + -- copy & paste + -- ["p"] = { '"_dp', "preserve cut" }, + + -- refactoring + ["re"] = { " Refactor extract ", "Refactor Extract" }, + ["rf"] = { " Refactor extract_to_file ", "Refactor Extract To File" }, + ["rv"] = { " Refactor extract_var ", "Refactor Extract Var" }, + ["ri"] = { " Refactor inline_var ", "Refactor Inline Var" }, + }, +} + +M.sniprun = { + n = { + ["sr"] = { + "lua require('sniprun').run()", + "Run Code", + }, + + ["ss"] = { + "lua require('sniprun').reset()", + "Reset Code", + }, + + ["sc"] = { + "lua require('sniprun').clear_repl()", + "Clean Repl Meomory", + }, + + ["sd"] = { + "lua require('sniprun.display').close_all()", + "Close Display", + }, + }, + + v = { + [""] = { + "lua require('sniprun').run('v')", + "Run Code", + }, + }, +} + +M.tagbar = { + n = { + ["tb"] = { " TagbarToggle ", "Toggle Tagbar" }, + }, +} + +M.telescope = { + n = { + ["u"] = { + function() + require("telescope").extensions.undo.undo() + end, + "Undo Tree", + }, + + ["fc"] = { " Telescope frecency ", "Frequent Files" }, + }, +} + +M.todo = { + n = { + ["tdo"] = { " Todo ", "Todo" }, + ["tds"] = { " TodoTelescope ", "Todo Telescope" }, + ["tdt"] = { " TodoTrouble ", "Todo Trouble" }, + ["tdl"] = { " TodoLocList ", "Todo Loclist" }, + ["tdf"] = { " TodoQuickFix ", "Todo Fix" }, + }, +} + +M.treesitter = { + n = { + -- ["tc"] = { " TSContextEnable ", "Toggle treesitter context" }, + ["gc"] = { + function() + require("treesitter-context").go_to_context() + end, + "Go To Context", + }, + }, +} + +M.trouble = { + n = { + ["trb"] = { + function() + require("trouble").toggle() + end, + "Trouble", + }, + ["trw"] = { + function() + require("trouble").toggle "workspace_diagnostics" + end, + "Trouble Workspace Diagnostics", + }, + ["trd"] = { + function() + require("trouble").toggle "document_diagnostics" + end, + "Trouble Document Diagnostics", + }, + ["trq"] = { + function() + require("trouble").toggle "quickfix" + end, + "Trouble Quickfix", + }, + ["trl"] = { + function() + require("trouble").toggle "loclist" + end, + "Trouble Loclist", + }, + ["gR"] = { + function() + require("trouble").toggle "lsp_references" + end, + "Trouble Lsp References", + }, + ["trc"] = { + function() + require("trouble").close() + end, + "Trouble Close", + }, + ["tro"] = { + function() + require("trouble").next { skip_groups = true, jump = true } + end, + "Trouble Next", + }, + ["tri"] = { + function() + require("trouble").previous { skip_groups = true, jump = true } + end, + "Trouble Previous", + }, + ["trf"] = { + function() + require("trouble").first { skip_groups = true, jump = true } + end, + "Trouble First", + }, + ["tre"] = { + function() + require("trouble").last { skip_groups = true, jump = true } + end, + "Trouble Last", + }, + -- ["trt"] = { + -- function() + -- require("trouble.providers.telescope").open_with_trouble() + -- end, + -- "Trouble Telescope", + -- }, + }, +} + +M.obsidian = { + i = { + ["gf"] = { + function() + require("obsidian").util.gf_passthrough() + end, + "gf", + opts, + }, + }, + + n = { + ["gf"] = { + function() + require("obsidian").util.gf_passthrough() + end, + "gf", + opts, + }, + ["op"] = { + function() + local query = vim.fn.input "Enter query: " + if query and #query > 0 then + vim.cmd("ObsidianOpen " .. query) + end + end, + "Open Notes", + }, + ["on"] = { + function() + local title = vim.fn.input "Enter title: " + if title and #title > 0 then + vim.cmd("ObsidianNew " .. title) + end + end, + "New Notes", + }, + ["ot"] = { + function() + local offset = vim.fn.input "Enter offset: " + if offset and #offset > 0 then + vim.cmd("ObsidianToday " .. offset) + else + vim.cmd "ObsidianToday" + end + end, + "Today Note", + }, + ["of"] = { + function() + local note = vim.fn.input "Enter note: " + if note and #note > 0 then + vim.cmd("ObsidianSearch " .. note) + end + end, + "Search Note", + }, + ["ow"] = { + function() + local name = vim.fn.input "Enter name: " + if name and #name > 0 then + vim.cmd("ObsidianWorkspace " .. name) + end + end, + "Workspace Name", + }, + ["oi"] = { + function() + local image = vim.fn.input "Enter image: " + if image and #image > 0 then + vim.cmd("ObsidianPasteImg " .. image) + end + end, + "Paste Image", + }, + ["or"] = { + function() + local name = vim.fn.input "Enter name: " + if name and #name > 0 then + vim.cmd("ObsidianRename " .. name) + end + end, + "Rename", + }, + ["o["] = { " ObsidianBacklinks ", "Back Link" }, + ["o]"] = { " ObsidianFollowLink ", "Follow Link" }, + ["os"] = { " ObsidianQuickSwitch ", "Quick Switch" }, + ["ol"] = { " ObsidianTomorrow ", "Tomorrow Note" }, + ["oh"] = { " ObsidianYesterday ", "Yesterday Note" }, + }, + + v = { + ["ol"] = { + function() + local query = vim.fn.input "Enter query: " + if query and #query > 0 then + vim.cmd("ObsidianLink " .. query) + else + vim.cmd "ObsidianLink" + end + end, + "Link Query", + }, + ["on"] = { + function() + local note = vim.fn.input "Enter note: " + if note and #note > 0 then + vim.cmd("ObsidianLinkNew " .. note) + else + vim.cmd "ObsidianLinkNew" + end + end, + "New Link Note", + }, + }, +} + +M.tabufline = { + n = { + ["L"] = { + function() + require("nvchad.tabufline").tabuflineNext() + end, + "Goto next buffer", + }, + + ["H"] = { + function() + require("nvchad.tabufline").tabuflinePrev() + end, + "Goto prev buffer", + }, + }, +} + +return M -- cgit v1.2.3