diff --git a/lua/mappings.lua b/lua/mappings.lua index dcfb96d..8df7fbd 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -3,15 +3,7 @@ local map = vim.keymap.set map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") -map("n", "", ":Telescope resume ", { desc = "Telescope resume" }) -map("n", "", ":Telescope keymaps ", { desc = "Show (and search) all [k]eymaps" }) - -map("n", "", ":Telescope find_files ", { desc = "Find files" }) -map("n", "", ":Telescope find_files follow=true no_ignore=true hidden=true ", { desc = "Find all files" }) -map("n", "", ":Telescope live_grep ", { desc = "Live grep" }) -map("n", "", ":Telescope buffers ", { desc = "Find buffers" }) -map("n", "/", ":Telescope search_history ", { desc = "Search history" }) -map("n", "//", ":noh", { desc = "Clear highlights" }) +map("n", ";", " Telescope ", { desc = "Open Telescope" }) -- go to beginning and end map("i", "", "^i", { desc = "Beginning of line" }) @@ -79,21 +71,24 @@ map("n", "tL", ":Trouble loclist toggle", { desc = "[T]rouble [L]ocl map("n", "tQ", ":Trouble qflist toggle", { desc = "[T]rouble [Q]uickfix" }) -- DAP -map("n", "dgg", ":lua require('dap').continue() ", { desc = "Continue debu[g]ging" }) -map("n", "dg", ":lua require('dapui').toggle() ", { desc = "Toggle DAP ui" }) -map("n", "dgw", ":lua require('dapui').eval() ", { desc = "Open floating windows about current [w]ord" }) -map("n", "dgb", ":lua require('dap').toggle_breakpoint() ", { desc = "Toggle [b]reakpoint" }) -map("n", "dgf", ":lua require('dap-python').test_method() ", { desc = "Debug [f]unction" }) -map("n", "dgo", ":lua require('dap').step_over() ", { desc = "DAP step [o]ver method" }) -map("n", "dgt", ":lua require('dap').step_into() ", { desc = "DAP step in[t]o method" }) -map("n", "dgp", ":lua require('dap').step_back() ", { desc = "DAP step back ([p]revious)" }) +local dap = require "dap" +local dapui = require "dapui" +local dappython = require "dap-python" + +map("n", "dgg", dap.continue, { desc = "Continue debu[g]ging" }) +map("n", "dg", dapui.toggle, { desc = "Toggle DAP ui" }) +map("n", "dgw", dapui.eval, { desc = "Open floating windows about current [w]ord" }) +map("n", "dgb", dap.toggle_breakpoint, { desc = "Toggle [b]reakpoint" }) +map("n", "dgf", dappython.test_method, { desc = "Debug [f]unction" }) +map("v", "dgd", dappython.debug_selection, { desc = "DAP debug selection" }) +map("n", "dgo", dap.step_over, { desc = "DAP step [o]ver method" }) +map("n", "dgt", dap.step_into, { desc = "DAP step in[t]o method" }) +map("n", "dgp", dap.step_back, { desc = "DAP step back ([p]revious)" }) map("n", "dgs", function() local widgets = require "dap.ui.widgets" local sidebar = widgets.sidebar(widgets.scopes) sidebar.open { widgth = "50%" } end, { desc = "DAP Show debugged [s]copes" }) -map("v", "dgd", ":lua require('dap-python').debug_selection()", { desc = "DAP debug selection" }) -map("v", "dgw", ":lua require('dap-python').eval()", { desc = "DAP eval selection" }) -- LSP map("n", "fm", function() @@ -160,19 +155,24 @@ map("n", "}", "}zz", { desc = "Previous + auto center" }) map("n", "[[", "[[zz", { desc = "Previous + auto center" }) map("n", "]]", "]]zz", { desc = "Previous + auto center" }) -map("n", "ww", ":lua require('nvim-window').pick()", { desc = "Pick window to goto" }) +map("n", "ww", require("nvim-window").pick, { desc = "Pick window to goto" }) map("n", "wm", ":WinShift", { desc = "Enter move window mode" }) map("n", "ws", ":WinShift swap", { desc = "Swap window, with selection" }) map("n", "gg", ":LazyGit", { desc = "Open lazygit" }) + +-- Go to - uppercase map("n", "gf", ":call search('[A-Z]', 'W')", { desc = "Go to next uppercase" }) map("n", "fg", ":call search('[A-Z]', 'bW')", { desc = "Go to last uppercase" }) -map("n", "glb", ":lua require('gitlab').choose_merge_request()", { desc = "Gitlab: Choose merge request" }) -map("n", "glr", ":lua require('gitlab').review()", { desc = "Gitlab: review" }) -map("n", "gls", ":lua require('gitlab').summary()", { desc = "Gitlab: summary" }) -map("n", "glo", ":lua require('gitlab').open_in_browser()", { desc = "Gitlab: open in browser" }) -map("n", "glu", ":lua require('gitlab').copy_mr_url()", { desc = "Gitlab: open in browser" }) -map("n", "glO", ":lua require('gitlab').create_mr()", { desc = "Gitlab: create MR" }) -map("n", "glaa", ":lua require('gitlab').add_assignee()", { desc = "Gitlab: add_assignee" }) + +-- Gitlab +-- local gitlab = require "gitlab" +-- map("n", "glb", gitlab.choose_merge_request, { desc = "Gitlab: Choose merge request" }) +-- map("n", "glr", gitlab.review, { desc = "Gitlab: review" }) +-- map("n", "gls", gitlab.summary, { desc = "Gitlab: summary" }) +-- map("n", "glo", gitlab.open_in_browser, { desc = "Gitlab: open in browser" }) +-- map("n", "glu", gitlab.copy_mr_url, { desc = "Gitlab: open in browser" }) +-- map("n", "glO", gitlab.create_mr, { desc = "Gitlab: create MR" }) +-- map("n", "glaa", gitlab.add_assignee, { desc = "Gitlab: add_assignee" }) -- map("n", "glb", gitlab.choose_merge_request) -- map("n", "glr", gitlab.review) @@ -205,30 +205,29 @@ map( -- Tabufline -- cycle through buffers +local tabufline = require "nvchad.tabufline" map("n", "", function() - require("nvchad.tabufline").next() + tabufline.next() end, { desc = "Goto next buffer" }) map("n", "", function() - require("nvchad.tabufline").prev() + tabufline.prev() end, { desc = "Goto prev buffer" }) -- close buffer + hide terminal buffer -- map("n", "x", function() --- require("nvchad.tabufline").close_buffer() +-- tabufline.close_buffer() -- end, { desc = "Close buffer" }) -- Comment +local comment = require "Comment.api" map("n", "ci", function() - require("Comment.api").toggle.linewise.current() + comment.toggle.linewise.current() end, { desc = "Toggle comment" }) -map( - "v", - "ci", - "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", - { desc = "Toggle comment" } -) +map("v", "ci", function() + comment.toggle.linewise(vim.fin.visualmode()) +end, { desc = "Toggle comment" }) -- LSP map("n", "gD", vim.lsp.buf.declaration, { desc = "LSP declaration" }) @@ -237,7 +236,6 @@ map("n", "K", vim.lsp.buf.hover, { desc = "LSP hover" }) map("n", "gi", vim.lsp.buf.implementation, { desc = "LSP implementation" }) map("n", "ls", vim.lsp.buf.signature_help, { desc = "LSP signature help" }) map("n", "D", vim.lsp.buf.type_definition, { desc = "LSP definition type" }) ---map("n", "ra", require("nvchad.renamer").open, { desc = "LSP rename" }) map("n", "ca", vim.lsp.buf.code_action, { desc = "LSP code action" }) map("n", "gr", vim.lsp.buf.references, { desc = "LSP references" }) map("n", "lf", function() @@ -256,7 +254,7 @@ end, { desc = "Diagnostic previous" }) -- LSP Workspace map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "Add workspace folder" }) map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "Add workspace folder" }) -map("n", "]d", function() +map("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, { desc = "List workspace folders" }) @@ -267,41 +265,44 @@ map("n", "", " NvimTreeToggle ", { desc = "Toggle nvimtree" }) map("n", "e", " NvimTreeFocus ", { desc = "Focus nvimtree" }) -- Telescope -map("n", "", " Telescope resume ", { desc = "Resume" }) -map("n", "", " Telescope keymaps ", { desc = "Show (and search) all [k]eymaps" }) -map("n", "", " Telescope find_files ", { desc = "Find files" }) -map("n", "", " Telescope find_files follow=true no_ignore=true hidden=true ", { desc = "Find all" }) -map("n", "", " Telescope live_grep ", { desc = "Live grep" }) -map("n", "", " Telescope buffers ", { desc = "Find buffers" }) +local telescope = require "telescope.builtin" +map("n", "", telescope.resume, { desc = "Resume" }) +map("n", "", telescope.keymaps, { desc = "Show (and search) all [k]eymaps" }) +map("n", "", telescope.find_files, { desc = "Find files" }) +map("n", "", function() + telescope.find_files { follow = true, no_ignore = true, hidden = true } +end, { desc = "Find all" }) +map("n", "", telescope.live_grep, { desc = "Live grep" }) +map("n", "", telescope.buffers, { desc = "Find buffers" }) map("n", "ff", function() - require("telescope.builtin").live_grep { default_text = "<<<<<<< HEAD" } + telescope.live_grep { default_text = "<<<<<<< HEAD" } end, { desc = "Search for git conflicts" }) -- Live grep map("n", "fg", function() - require("telescope.builtin").live_grep {} + telescope.live_grep {} end, { desc = "Live grep" }) map("n", "fg/", function() - require("telescope.builtin").live_grep { default_text = vim.fn.getreg "/" } + telescope.live_grep { default_text = vim.fn.getreg "/" } end, { desc = "Live grep with search term" }) map("n", "fgw", function() - require("telescope.builtin").live_grep { default_text = vim.fn.expand "" } + telescope.live_grep { default_text = vim.fn.expand "" } end, { desc = "Live grep with current word" }) -- Find files map("n", "gf", function() - require("telescope.builtin").find_files {} + telescope.find_files {} end, { desc = "Find files" }) map("n", "gf/", function() - require("telescope.builtin").find_files { default_text = vim.fn.getreg "/" } + telescope.find_files { default_text = vim.fn.getreg "/" } end, { desc = "Find files with search term" }) map("n", "gfw", function() - require("telescope.builtin").find_files { default_text = vim.fn.expand "" } + telescope.find_files { default_text = vim.fn.expand "" } end, { desc = "Find files with current word" }) -- Buffer replace @@ -361,15 +362,15 @@ map("n", "lc", ":call setloclist([]) | lclose", { desc = "Clear locl map("n", "fh", " Telescope help_tags ", { desc = "Help page" }) map("n", "fo", " Telescope oldfiles ", { desc = "Find oldfiles" }) map("n", "fx", function() - require("telescope.builtin").current_buffer_fuzzy_find {} + telescope.current_buffer_fuzzy_find {} end, { desc = "Fuzzy find in current buffer" }) map("n", "fx/", function() - require("telescope.builtin").current_buffer_fuzzy_find { default_text = vim.fn.getreg "/" } + telescope.current_buffer_fuzzy_find { default_text = vim.fn.getreg "/" } end, { desc = "Fuzzy find in current buffer with search term" }) map("n", "fxw", function() - require("telescope.builtin").current_buffer_fuzzy_find { default_text = vim.fn.expand "" } + telescope.current_buffer_fuzzy_find { default_text = vim.fn.expand "" } end, { desc = "Fuzzy find in current buffer with current work" }) map("n", "wl", " Telescope workspaces ", { desc = "Find workspaces" }) @@ -400,37 +401,15 @@ map("n", "ch", " Telescope command_history ", { desc = "telesco map("n", "/", " Telescope search_history ", { desc = "telescope search history" }) -- Diaglist: LSP diagnostics in quick/loc list +local diaglist = require "diaglist" map("n", "dw", function() - require("diaglist").open_all_diagnostics() + diaglist.open_all_diagnostics() end, { desc = "Open all open buffers diagnostics in qflist" }) map("n", "d0", function() - require("diaglist").open_buffer_diagnostics() + diaglist.open_buffer_diagnostics() end, { desc = "Open current buffer diagnostics in qflist" }) -map("n", ";", " Telescope ", { desc = "Open Telescope" }) - --- Terminal -map({ "n", "t" }, "", function() - require("nvterm.terminal").toggle "float" -end, { desc = "Toggle floating term" }) - -map({ "n", "t" }, "", function() - require("nvterm.terminal").toggle "horizontal" -end, { desc = "Toggle horizontal term" }) - -map({ "n", "t" }, "", function() - require("nvterm.terminal").toggle "vertical" -end, { desc = "Toggle vertical term" }) - -map("n", "h", function() - require("nvterm.terminal").new "horizontal" -end, { desc = "New horizontal term" }) - -map("n", "v", function() - require("nvterm.terminal").new "vertical" -end, { desc = "New vertical term" }) - -- WhichKey map("n", "wK", function() vim.cmd "WhichKey" @@ -443,12 +422,13 @@ map("n", "wk", function() end, { desc = "Which-key query lookup" }) -- Git hunk +local gitsigns = require "gitsigns" map("n", "]c", function() if vim.wo.diff then return "]c" end vim.schedule(function() - require("gitsigns").next_hunk() + gitsigns.next_hunk() end) return "" end, { desc = "Jump to next hunk" }) @@ -458,15 +438,28 @@ map("n", "[c", function() return "[c" end vim.schedule(function() - require("gitsigns").prev_hunk() + gitsigns.prev_hunk() end) return "" end, { desc = "Jump to prev hunk" }) -map("n", "rh", require("gitsigns").reset_hunk, { desc = "Git Reset hunk" }) -map("n", "ph", require("gitsigns").preview_hunk, { desc = "Git Preview hunk" }) -map("n", "bb", require("gitsigns").blame_line, { desc = "Git Blame line" }) -map("n", "bd", require("gitsigns").toggle_deleted, { desc = "Git Toggle deleted" }) +map("n", "rh", gitsigns.reset_hunk, { desc = "Git Reset hunk" }) +map("n", "ph", gitsigns.preview_hunk, { desc = "Git Preview hunk" }) +map("n", "bb", gitsigns.blame_line, { desc = "Git Blame line" }) +map("n", "bd", gitsigns.toggle_deleted, { desc = "Git Toggle deleted" }) + +-- Macrothis +local macrothis = require "macrothis" +map("n", "kkd", macrothis.delete, { desc = "Macro: [d]elete" }) +map("n", "kke", macrothis.edit, { desc = "Macro: [e]dit" }) +map("n", "kkl", macrothis.load, { desc = "Macro: [l]oad" }) +map("n", "kkn", macrothis.rename, { desc = "Macro: re[n]ame" }) +map("n", "kkq", macrothis.quickfix, { desc = "Macro: [q]uickfix" }) +map("n", "kkr", macrothis.run, { desc = "Macro: [r]un" }) +map("n", "kks", macrothis.save, { desc = "Macro: [s]ave" }) +map("n", "kkx", macrothis.register, { desc = "Macro: edit register" }) +map("n", "kkpr", macrothis.copy_register_printable, { desc = "Macro: as [p]rintable [r]egister" }) +map("n", "kkpm", macrothis.copy_macro_printable, { desc = "Macro: as [p]rintable [m]acro" }) -- Override all delete/yank/paste to use the registers M by default map({ "n", "v" }, "y", '"my', { desc = "Yank", remap = false })