-- setup keymap function local wk = require("which-key") local lazygit = require("FTerm"):new({ cmd = "lazygit" }) wk.add({ -- setup keymap groups {mode = "n", "g", desc = "LSP: goto"}, {mode = "n", "gp", desc = "LSP: preview"}, {mode = "c", "w", desc = "Write"}, {mode = "c", "w!", desc = "Write: overwrite"}, {mode = "n", "g", desc = "Git"}, {mode = "n", "f", desc = "Telescope: find"}, {mode = "n", "gd", desc = "Git: diff"}, {mode = "n", "s", desc = "Substitute"}, {mode = "n", "t", desc = "Terminal"}, {mode = "n", "", desc = "Navigation"}, -- unmap unwanted commands {mode = "n", "Zt", "", noremap = true}, {mode = "n", "ZT", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, {mode = "n", "", "", noremap = true}, -- spell {mode = "n", "s", "z=", desc = "Spell: display suggestions"}, -- shortcuts for quitting {mode = "n", "ZA", ":xa", desc = "Exit: write and quit all buffers", noremap = true}, {mode = "n", "ZQ", ":conf q", desc = "Exit: quit current buffer", noremap = true}, {mode = "n", "ZZ", ":x", desc = "Exit: write and quit current buffer", noremap = true}, -- shortcut for split navigation {mode = "n", "", "h", desc = "Navigation: go to left window", noremap = true}, {mode = "n", "", "j", desc = "Navigation: go to lower window", noremap = true}, {mode = "n", "", "k", desc = "Navigation: go to upper window", noremap = true}, {mode = "n", "", "l", desc = "Navigation: go to right window", noremap = true}, -- remap for dealing with word wrap {mode = "n", "j", "gj", desc = "Navigation: go down in wrapped lines", silent = true}, {mode = "n", "k", "gk", desc = "Navigation: go up in wrapped lines", silent = true}, -- compiler for languages {mode = "n", "c", ":w! | !compiler %", desc = "Compile: current file", noremap = true}, {mode = "n", "w!!", 'execute "silent! write !sudo tee % >/dev/null" edit!', desc = "Write: overwrite file over with sudo", noremap = true}, -- tpope/vim-abolish {mode = "n", "sa", ":%S//g", desc = "Substitute: free form", noremap = true}, {mode = "n", "ss", ":%S/\\<\\>//g", desc = "Substitute: word under cursor", noremap = true}, -- simrat39/symbols-outline.nvim {mode = "n", "", ":SymbolsOutline", desc = "CTags: toggle"}, -- nvim-tree/nvim-tree.lua {mode = "n", "", ":NvimTreeToggle toggle", desc = "File tree: toggle"}, -- mbbill/undotree {mode = "n", "", ":UndotreeToggle", desc = "Undo tree: toggle"}, -- amrbashir/nvim-docs-view {mode = "n", "go", ":DocsViewToggle", desc = "LSP: toggle documentation window", noremap = true}, -- numtostr/fterm.nvim {mode = "n", "tt", require("FTerm").toggle, desc = "Terminal: open", noremap = true}, {mode = "n", "gt", function() lazygit:toggle() end, desc = "Git: open lazygit", noremap = true}, {mode = "n", "tg", function() lazygit:toggle() end, desc = "Terminal: open lazygit", noremap = true}, {mode = "n", "tg", function() lazygit:toggle() end, desc = "Terminal: open lazygit", noremap = true}, -- sindrets/diffview.nvim {mode = "n", "gdo", ":DiffviewOpen", desc = "Git: open diff"}, {mode = "n", "gdc", ":DiffviewClose", desc = "Git: close diff"}, -- folke/trouble.nvim {mode = "n", "x", ":TroubleToggle", desc = "LSP: toggle error list"}, -- hrsh7th/nvim-cmp {mode = "n", "gd", vim.lsp.buf.definition(), desc = "LSP: goto definition", noremap = true}, {mode = "n", "gD", vim.lsp.buf.declaration(), desc = "LSP: goto declaration", noremap = true}, {mode = "n", "gi", vim.lsp.buf.implementation(), desc = "LSP: list implementation", noremap = true}, {mode = "n", "gr", function() vim.lsp.buf.references() end, desc = "LSP: list references", noremap = true}, {mode = "n", "K", vim.lsp.buf.hover(), desc = "LSP: show documentation", noremap = true}, {mode = "n", "", function() require("conform").format({ async = true, lsp_fallback = true }) end, desc = "LSP: format", noremap = true}, -- rmagatti/goto-preview {mode = "n", "gpd", function() require("goto-preview").goto_preview_definition() end, desc = "LSP: preview definition", noremap = true}, {mode = "n", "gpy", function() require("goto-preview").goto_preview_type_definition() end, desc = "LSP: preview type definition", noremap = true}, {mode = "n", "gpi", function() require("goto-preview").goto_preview_implementation() end, desc = "LSP: list preview implementation", noremap = true}, {mode = "n", "gpD", function() require("goto-preview").goto_preview_declaration() end, desc = "LSP: preview declaration", noremap = true}, {mode = "n", "gpr", function() require("goto-preview").goto_preview_references() end, desc = "LSP: list preview references", noremap = true}, {mode = "n", "gpc", function() require("goto-preview").close_all_win() end, desc = "LSP: close all preview windows", noremap = true}, -- filipdutescu/renamer.nvim {mode = "n", "", function() require("renamer").rename() end, desc = "LSP: rename", noremap = true}, -- nvim-telescope/telescope.nvim {mode = "n", "", ":Telescope find_files", desc = "Telescope: find files", noremap = true}, {mode = "n", "ff", ":Telescope find_files", desc = "Telescope: find files", noremap = true}, -- kamykn/spelunker.vim {mode = "n", "t", ":call spelunker#toggle()", desc = "Spelunker: toggle spell check", noremap = true}, {mode = "n", "l", function() if vim.opt.spelllang._value == "de_de" then vim.opt.spelllang = "en_us" print("Spell language set to en_us") else vim.opt.spelllang = "de_de" print("Spell language set to de_de") end vim.opt.spell = false end, desc = "Spell: toggle spell language", noremap = true}, -- kevinhwang91/nvim-ufo {mode = "n", "K", function() local winid = require("ufo").peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end, desc = "LSP: peek folded section", noremap = true}, -- kevinhwang91/nvim-hlslens {mode = "n", "n", [[execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()]], desc = "Search: search forward", noremap = true, silent = true}, {mode = "n", "N", [[execute('normal! ' . v:count1 . 'N')lua require('hlslens').start()]], desc = "Search: search backwards", noremap = true, silent = true}, -- sindrets/winshift.nvim {mode = "n", "m", ":WinShift", desc = "Navigation: enter window shift mode", noremap = true}, -- ggandor/leap.nvim {mode = "n", "f", "(leap-forward)", desc = "Navigation: enter leap mode for forward movement", noremap = true}, {mode = "n", "F", "(leap-backward)", desc = "Navigation: enter leap mode for backwards movement", noremap = true}, {mode = "n", "gf", "(leap-from-window)", desc = "Navigation: enter leap mode for other windows", noremap = true}, -- gnikdroy/projections.nvim {mode = "n", "fp", function() vim.cmd("Telescope projections") end, desc = "Telescope: find projects", noremap = true}, })