From a3a79d9e4d9e108299a7048fe539b3089e498f45 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Mon, 9 Jan 2023 09:34:46 +1030 Subject: [PATCH] more updates <3 --- .config/nvim/lua/lazyvim/config/keymaps.lua | 29 ++- .config/nvim/lua/lazyvim/plugins/utility.lua | 18 +- .config/nvim/lua/lazyvim/plugins/whichkey.lua | 203 +++++++++++++----- 3 files changed, 192 insertions(+), 58 deletions(-) diff --git a/.config/nvim/lua/lazyvim/config/keymaps.lua b/.config/nvim/lua/lazyvim/config/keymaps.lua index 7e82d6b..8bd173c 100644 --- a/.config/nvim/lua/lazyvim/config/keymaps.lua +++ b/.config/nvim/lua/lazyvim/config/keymaps.lua @@ -4,14 +4,37 @@ local map = vim.api.nvim_set_keymap map("n", "", "", opts) --- NORMAL +-- better up/down +map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + -- Move text up and down map("n", "", ":m .-2==", opts) map("n", "", ":m .+1==", opts) +-- Move Lines +map("n", "", ":m .+1==", { desc = "Move down" }) +map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) +map("i", "", ":m .+1==gi", { desc = "Move down" }) +map("n", "", ":m .-2==", { desc = "Move up" }) +map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) +map("i", "", ":m .-2==gi", { desc = "Move up" }) + +-- Clear search with +map("n", "", "noh", opts) +map("i", "", "noh", opts) + +-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n +map("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) +map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) +map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) +map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) +map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) +map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) + -- Copy/Paste map("n", "", '"+y', opts) -map("n", "", '"+y', opts) +map("n", "", '"+p', opts) -- Save map("n", "", ":w", opts) @@ -24,7 +47,6 @@ map("n", "", ":CybuPrev", opts) map("n", "", "zz", opts) map("n", "", "zz", opts) --- INSERT -- Easy exit insert mode map("i", "jk", "", opts) @@ -34,7 +56,6 @@ map("i", "", '"+y', opts) -- Save map("i", "", ":wa", opts) --- VISUAL -- Indenting map("v", "<", "", ">gv", opts) diff --git a/.config/nvim/lua/lazyvim/plugins/utility.lua b/.config/nvim/lua/lazyvim/plugins/utility.lua index 99b890c..6be8cee 100644 --- a/.config/nvim/lua/lazyvim/plugins/utility.lua +++ b/.config/nvim/lua/lazyvim/plugins/utility.lua @@ -28,12 +28,6 @@ return { -- Animation style (see below for details) stages = "fade_in_slide_out", - -- Function called when a new window is opened, use for changing win settings/config - on_open = nil, - - -- Function called when a window is closed - on_close = nil, - -- Render function for notifications. See notify-render() render = "default", @@ -283,5 +277,17 @@ return { }, { "ThePrimeagen/harpoon", + keys = { + { "mm", 'lua require("harpoon.mark").add_file()', desc = "Harpoon" }, + { "ml", 'lua require("harpoon.ui").nav_next()', desc = "Harpoon Next" }, + { "mh", 'lua require("harpoon.ui").nav_prev()', desc = "Harpoon Prev" }, + { "ms", "Telescope harpoon marks", desc = "Search Files" }, + { "mu", 'lua require("harpoon.ui").toggle_quick_menu()', desc = "Harpoon UI" }, + + { "m1", ' lua require("harpoon.ui").nav_file(1)', desc = "Goto 1" }, + { "m2", ' lua require("harpoon.ui").nav_file(2)', desc = "Goto 2" }, + { "m3", ' lua require("harpoon.ui").nav_file(3)', desc = "Goto 3" }, + { "m4", ' lua require("harpoon.ui").nav_file(4)', desc = "Goto 4" }, + }, }, } diff --git a/.config/nvim/lua/lazyvim/plugins/whichkey.lua b/.config/nvim/lua/lazyvim/plugins/whichkey.lua index 247c340..538f140 100644 --- a/.config/nvim/lua/lazyvim/plugins/whichkey.lua +++ b/.config/nvim/lua/lazyvim/plugins/whichkey.lua @@ -62,15 +62,6 @@ return { }, }) - local opts = { - mode = "n", -- NORMAL mode - buffer = nil, -- Global mappings - prefix = "", - silent = true, -- use 'silent' - noremap = true, -- use 'noremap' - nowait = true, -- use 'nowait' - } - local leader_opts = { mode = "n", -- NORMAL mode buffer = nil, -- Global mappings @@ -80,49 +71,165 @@ return { nowait = true, -- use 'nowait' } - local m_opts = { - mode = "n", -- NORMAL mode - buffer = nil, -- Global mappings - prefix = "m", - silent = true, -- use 'silent' - noremap = true, -- use 'noremap' - nowait = true, -- use 'nowait' - } - - local m_mappings = { - m = { 'lua require("harpoon.mark").add_file()', "Harpoon" }, - l = { 'lua require("harpoon.ui").nav_next()', "Harpoon Next" }, - h = { 'lua require("harpoon.ui").nav_prev()', "Harpoon Prev" }, - s = { "Telescope harpoon marks", "Search Files" }, - u = { 'lua require("harpoon.ui").toggle_quick_menu()', "Harpoon UI" }, - - ["1"] = { ' lua require("harpoon.ui").nav_file(1)', "Goto 1" }, - ["2"] = { ' lua require("harpoon.ui").nav_file(2)', "Goto 2" }, - ["3"] = { ' lua require("harpoon.ui").nav_file(3)', "Goto 3" }, - ["4"] = { ' lua require("harpoon.ui").nav_file(4)', "Goto 4" }, - } - - whichkey.register(m_mappings, m_opts) - whichkey.register({ mode = { "n", "v" }, ["g"] = { name = "+goto" }, - ["]"] = { name = "+next" }, - ["["] = { name = "+prev" }, - ["b"] = { name = "+buffer" }, - ["c"] = { name = "+code" }, - ["f"] = { name = "+file" }, - ["g"] = { name = "+git" }, - ["h"] = { name = "+help" }, - ["n"] = { name = "+noice" }, - ["o"] = { name = "+open" }, - ["q"] = { name = "+quit/session" }, - ["s"] = { name = "+search" }, - ["t"] = { name = "+toggle" }, - ["x"] = { name = "+diagnostics/quickfix" }, - ["w"] = { name = "+windows" }, - [""] = { name = "+tabs" }, + ["m"] = { name = "+harpoon" }, }) + + local leader_mappings = { + a = { "Lspsaga code_action", "Action" }, + c = { "Bdelete", "Close Buffer" }, + H = { "split", "split" }, + h = { "lua vim.lsp.buf.hover()", "Hover" }, + n = { "NvimTreeToggle", "Explorer" }, + O = { "setlocal spell! spelllang=en_us", "Toggle Spelling" }, + P = { "!opout %", "Preview Document" }, + q = { 'lua require("lazyvim.functions").smart_quit()', "Quit" }, + V = { "vsplit", "vsplit" }, + w = { "w", "Write" }, + z = { "ZenMode", "Zen" }, + ["/"] = { 'lua require("Comment.api").toggle.linewise.current()', "Comment" }, + ["'"] = { "close", "Close split" }, + u = { "UndoTreeToggle", "Undo Tree" }, + + C = { + name = "Compiler", + c = { "w! | !compiler %", "Compile File" }, + b = { "w! | !pandoc % -t beamer -o presentation.pdf", "Beamer Presentation" }, + }, + + b = { + name = "Buffer", + b = { "Telescope buffers", "Telescope" }, + c = { "Bdelete!", "Close Buffer" }, + h = { "BufferLineCyclePrev", "Cycle Previous" }, + l = { "BufferLineCycleNext", "Cycle Next" }, + p = { "BufferLinePickClose", "Pick Close" }, + }, + + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + + o = { + name = "Options", + c = { "lua vim.g.cmp_active=false", "Completion off" }, + C = { "lua vim.g.cmp_active=true", "Completion on" }, + w = { 'lua require("user.functions").toggle_option("wrap")', "Wrap" }, + r = { 'lua require("user.functions").toggle_option("relativenumber")', "Relative" }, + l = { 'lua require("user.functions").toggle_option("cursorline")', "Cursorline" }, + s = { 'lua require("user.functions").toggle_option("spell")', "Spell" }, + t = { 'lua require("user.functions").toggle_tabline()', "Tabline" }, + }, + + r = { + name = "Replace", + r = { "lua require('spectre').open()", "Replace" }, + w = { "lua require('spectre').open_visual({select_word=true})", "Replace Word" }, + f = { "lua require('spectre').open_file_search()", "Replace Buffer" }, + }, + + d = { + name = "Debug", + b = { "lua require'dap'.toggle_breakpoint()", "Breakpoint" }, + c = { "lua require'dap'.continue()", "Continue" }, + i = { "lua require'dap'.step_into()", "Into" }, + o = { "lua require'dap'.step_over()", "Over" }, + O = { "lua require'dap'.step_out()", "Out" }, + r = { "lua require'dap'.repl.toggle()", "Repl" }, + l = { "lua require'dap'.run_last()", "Last" }, + u = { "lua require'dapui'.toggle()", "UI" }, + x = { "lua require'dap'.terminate()", "Exit" }, + }, + + f = { + name = "Find", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope colorscheme", "Colorscheme" }, + f = { "Telescope find_files", "Find files" }, + t = { "Telescope live_grep", "Find Text" }, + s = { "Telescope grep_string", "Find String" }, + h = { "Telescope help_tags", "Help" }, + H = { "Telescope highlights", "Highlights" }, + l = { "Telescope resume", "Last Search" }, + M = { "Telescope man_pages", "Man Pages" }, + r = { "Telescope oldfiles", "Recent File" }, + R = { "Telescope registers", "Registers" }, + k = { "Telescope keymaps", "Keymaps" }, + C = { "Telescope commands", "Commands" }, + }, + + g = { + name = "Git", + g = { "Git", "Git" }, + j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, + k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, + l = { "GitBlameToggle", "Blame" }, + p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, + r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, + R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, + s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, + u = { + "lua require 'gitsigns'.undo_stage_hunk()", + "Undo Stage Hunk", + }, + o = { "Telescope git_status", "Open changed file" }, + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + d = { + "Gitsigns diffthis HEAD", + "Diff", + }, + }, + + l = { + name = "LSP", + a = { "Lspsaga code_action", "Code Action" }, + t = { "TroubleToggle document_diagnostics", "Diagnostics" }, + d = { "lua vim.lsp.buf.definition()", "Definition" }, + w = { + "TroubleToggle workspace_diagnostics", + "Workspace Diagnostics", + }, + f = { "lua vim.lsp.buf.format({ async = true })", "Format" }, + F = { "LspToggleAutoFormat", "Toggle Autoformat" }, + h = { "lua vim.lsp.buf.hover()", "Hover" }, + i = { "lua vim.lsp.buf.implementation()", "Implementation" }, + I = { "LspInfo", "Info" }, + j = { + "lua vim.diagnostic.goto_next({buffer=0})", + "Next Diagnostic", + }, + k = { + "lua vim.diagnostic.goto_prev({buffer=0})", + "Prev Diagnostic", + }, + v = { "lua require('lsp_lines').toggle()", "Virtual Text" }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, + o = { "SymbolsOutline", "Outline" }, + r = { "lua vim.lsp.buf.rename()", "Rename" }, + R = { "TroubleToggle lsp_references", "References" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { + "Telescope lsp_dynamic_workspace_symbols", + "Workspace Symbols", + }, + T = { 'lua require("user.functions").toggle_diagnostics()', "Toggle Diagnostics" }, + u = { "LuaSnipUnlinkCurrent", "Unlink Snippet" }, + M = { "Mason", "Open Mason UI" }, + }, + } + + -- whichkey.register(m_mappings, m_opts) + + whichkey.register(mappings, opts) + whichkey.register(leader_mappings, leader_opts) end, }, }