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/core/mappings.lua | 468 ++++++++++++++++++++++++++++++++ 1 file changed, 468 insertions(+) create mode 100644 ar/.config/NvChad/lua/core/mappings.lua (limited to 'ar/.config/NvChad/lua/core/mappings.lua') diff --git a/ar/.config/NvChad/lua/core/mappings.lua b/ar/.config/NvChad/lua/core/mappings.lua new file mode 100644 index 0000000..4154bde --- /dev/null +++ b/ar/.config/NvChad/lua/core/mappings.lua @@ -0,0 +1,468 @@ +-- n, v, i, t = mode names + +local M = {} + +M.general = { + i = { + -- go to beginning and end + [""] = { "^i", "Beginning Of Line" }, + [""] = { "", "End Of Line" }, + + -- navigate within insert mode + [""] = { "", "Move Left" }, + [""] = { "", "Move Right" }, + [""] = { "", "Move Down" }, + [""] = { "", "Move Up" }, + }, + + n = { + [""] = { " noh ", "Clear Highlights" }, + -- switch between windows + [""] = { "h", "Window Left" }, + [""] = { "l", "Window Right" }, + [""] = { "j", "Window Down" }, + [""] = { "k", "Window Up" }, + + -- save + [""] = { " w ", "Save File" }, + + -- Copy all + [""] = { " %y+ ", "Copy whole file" }, + + -- line numbers + ["n"] = { " set nu! ", "Toggle Line Number" }, + ["rn"] = { " set rnu! ", "Toggle Relative Number" }, + + -- Allow moving the cursor through wrapped lines with j, k, and + -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ + -- empty mode is same as using :map + -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour + ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move Down", opts = { expr = true } }, + ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move Up", opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move Up", opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move Down", opts = { expr = true } }, + + -- new buffer + ["b"] = { " enew ", "New Buffer" }, + ["ch"] = { " NvCheatsheet ", "Mapping Cheatsheet" }, + + ["fm"] = { + function() + vim.lsp.buf.format { async = true } + end, + "LSP Formatting", + }, + }, + + t = { + [""] = { vim.api.nvim_replace_termcodes("", true, true, true), "Escape Terminal Mode" }, + }, + + v = { + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move Up", opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move Down", opts = { expr = true } }, + ["<"] = { ""] = { ">gv", "Indent line" }, + }, + + x = { + ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move Down", opts = { expr = true } }, + ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move Up", opts = { expr = true } }, + -- Don't copy the replaced text after pasting in visual mode + -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste + ["p"] = { 'p:let @+=@0:let @"=@0', "Dont Copy Replaced Text", opts = { silent = true } }, + }, +} + +M.tabufline = { + plugin = true, + + n = { + -- cycle through buffers + [""] = { + function() + require("nvchad.tabufline").tabuflineNext() + end, + "Goto Next Buffer", + }, + + [""] = { + function() + require("nvchad.tabufline").tabuflinePrev() + end, + "Goto Prev Buffer", + }, + + -- close buffer + hide terminal buffer + ["x"] = { + function() + require("nvchad.tabufline").close_buffer() + end, + "Close Buffer", + }, + }, +} + +M.comment = { + plugin = true, + + -- toggle comment in both modes + n = { + ["/"] = { + function() + require("Comment.api").toggle.linewise.current() + end, + "Toggle Comment", + }, + }, + + v = { + ["/"] = { + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + "Toggle Comment", + }, + }, +} + +M.lspconfig = { + plugin = true, + + -- See ` :help vim.lsp.*` for documentation on any of the below functions + + n = { + ["gD"] = { + function() + vim.lsp.buf.declaration() + end, + "LSP Declaration", + }, + + ["gd"] = { + function() + vim.lsp.buf.definition() + end, + "LSP Definition", + }, + + ["K"] = { + function() + vim.lsp.buf.hover() + end, + "LSP Hover", + }, + + ["gi"] = { + function() + vim.lsp.buf.implementation() + end, + "LSP Implementation", + }, + + ["ls"] = { + function() + vim.lsp.buf.signature_help() + end, + "LSP Signature Help", + }, + + ["D"] = { + function() + vim.lsp.buf.type_definition() + end, + "LSP Definition Type", + }, + + ["ra"] = { + function() + require("nvchad.renamer").open() + end, + "LSP Rename", + }, + + ["ca"] = { + function() + vim.lsp.buf.code_action() + end, + "LSP Code Action", + }, + + ["gr"] = { + function() + vim.lsp.buf.references() + end, + "LSP References", + }, + + ["lf"] = { + function() + vim.diagnostic.open_float { border = "rounded" } + end, + "Floating Diagnostic", + }, + + ["[d"] = { + function() + vim.diagnostic.goto_prev { float = { border = "rounded" } } + end, + "Goto Prev", + }, + + ["]d"] = { + function() + vim.diagnostic.goto_next { float = { border = "rounded" } } + end, + "Goto Next", + }, + + ["q"] = { + function() + vim.diagnostic.setloclist() + end, + "Diagnostic Setloclist", + }, + + ["wa"] = { + function() + vim.lsp.buf.add_workspace_folder() + end, + "Add Workspace Folder", + }, + + ["wr"] = { + function() + vim.lsp.buf.remove_workspace_folder() + end, + "Remove Workspace Folder", + }, + + ["wl"] = { + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, + "List Workspace Folders", + }, + }, + + v = { + ["ca"] = { + function() + vim.lsp.buf.code_action() + end, + "LSP Code Action", + }, + }, +} + +M.nvimtree = { + plugin = true, + + n = { + -- toggle + [""] = { " NvimTreeToggle ", "Toggle Nvimtree" }, + + -- focus + ["e"] = { " NvimTreeFocus ", "Focus Nvimtree" }, + }, +} + +M.telescope = { + plugin = true, + + n = { + -- find + ["ff"] = { " Telescope find_files ", "Find Files" }, + ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", "Find All" }, + ["fw"] = { " Telescope live_grep ", "Live Grep" }, + ["fb"] = { " Telescope buffers ", "Find Buffers" }, + ["fh"] = { " Telescope help_tags ", "Help Page" }, + ["fo"] = { " Telescope oldfiles ", "Find Oldfiles" }, + ["fz"] = { " Telescope current_buffer_fuzzy_find ", "Find in Current Buffer" }, + + -- git + ["cm"] = { " Telescope git_commits ", "Git Commits" }, + ["gt"] = { " Telescope git_status ", "Git Status" }, + + -- pick a hidden term + ["pt"] = { " Telescope terms ", "Pick Hidden Term" }, + + -- theme switcher + ["th"] = { " Telescope themes ", "Nvchad Themes" }, + + ["ma"] = { " Telescope marks ", "Telescope Bookmarks" }, + }, +} + +M.nvterm = { + plugin = true, + + t = { + -- toggle in terminal mode + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "Toggle Floating Term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + "Toggle Horizontal Term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + "Toggle Vertical Term", + }, + }, + + n = { + -- toggle in normal mode + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "Toggle Floating Term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + "Toggle Horizontal Term", + }, + + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + "Toggle Vertical Term", + }, + + -- new + ["h"] = { + function() + require("nvterm.terminal").new "horizontal" + end, + "New Horizontal Term", + }, + + ["v"] = { + function() + require("nvterm.terminal").new "vertical" + end, + "New Vertical Term", + }, + }, +} + +M.whichkey = { + plugin = true, + + n = { + ["wK"] = { + function() + vim.cmd "WhichKey" + end, + "Which-key All Keymaps", + }, + ["wk"] = { + function() + local input = vim.fn.input "WhichKey: " + vim.cmd("WhichKey " .. input) + end, + "Which-key Query Lookup", + }, + }, +} + +M.blankline = { + plugin = true, + + n = { + ["cc"] = { + function() + local ok, start = require("indent_blankline.utils").get_current_context( + vim.g.indent_blankline_context_patterns, + vim.g.indent_blankline_use_treesitter_scope + ) + + if ok then + vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 }) + vim.cmd [[normal! _]] + end + end, + + "Jump To Current Context", + }, + }, +} + +M.gitsigns = { + plugin = true, + + n = { + -- Navigation through hunks + ["]c"] = { + function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + require("gitsigns").next_hunk() + end) + return "" + end, + "Jump To Next Hunk", + opts = { expr = true }, + }, + + ["[c"] = { + function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + require("gitsigns").prev_hunk() + end) + return "" + end, + "Jump To Prev Hunk", + opts = { expr = true }, + }, + + -- Actions + ["rh"] = { + function() + require("gitsigns").reset_hunk() + end, + "Reset Hunk", + }, + + ["ph"] = { + function() + require("gitsigns").preview_hunk() + end, + "Preview Hunk", + }, + + ["gb"] = { + function() + package.loaded.gitsigns.blame_line() + end, + "Blame Line", + }, + + ["td"] = { + function() + require("gitsigns").toggle_deleted() + end, + "Toggle Deleted", + }, + }, +} + +return M -- cgit v1.2.3