-- Set up all my favorite keybindings and list them in my cheatsheet. -- This module assumes a lot of pre configured state, i.e. already installed and enabled plugins. -- The benefit of assembling all keybinds here is, that they are easy to find. -- But unfortunataly, by collecting them here, they are placed "far" from their logical place, i.e. the plugins configuration. return function(cheatsheet) -- Let the key be vim.g.mapleader = " " cheatsheet("") cheatsheet("The LEADER key is SPACE! Press it to show all bindings.") cheatsheet("") local keys = require("which-key") --Open up a URL under the cursor local opener_program = "" if vim.fn.has("mac") == 1 then opener_program = "open" elseif vim.fn.has("unix") == 1 then opener_program = "xdg-open" elseif vim.fn.has("win32") == 1 then opener_program = "explorer" else -- What should we do on unknown platforms? We guess... opener_program = "firefox" end -- bundle all mappings under LEADER here keys.register({ [""] = { [[tabnew $MYVIMRC]], "Open Nvim Configuration" }, [""] = { [[PluginsSync]], "Sync Plugins" }, [""] = { [[PluginsCompile]], "Compile Plugins" }, f = { name = "File Operations", f = { [[Telescope find_files]], "Find File" }, b = { [[Telescope buffers]], "Open a Buffer" }, r = { [[Telescope oldfiles]], "Open Recent File" }, e = { [[NvimTreeToggle]], "Toggle File Explorer" }, }, g = { name = "Goto Navigation", T = { [[TroubleToggle]], "Toggle Trouble Window" }, x = { "lua require'spawn'('" .. opener_program .. "',{vim.fn.expand('')})", "Open Url Under Cursor", }, }, a = { name = "Code Operations", O = { [[SymbolsOutline]], "Toggle Outline" }, }, }, { prefix = "", }) cheatsheet("") cheatsheet("ALT + j => Move line(s) down") cheatsheet("ALT + k => Move line(s) up") keys.register({ [""] = { [[move .+1==]], "Move Current Line(s) Up" }, [""] = { [[move .-2==]], "Move Current Line(s) Down" }, }) keys.register({ [""] = { [[move .+1==gi]], "Move Current Line(s) Up" }, [""] = { [[move .-2==gi]], "Move Current Line(s) Down" }, }, { mode = "i", }) keys.register({ [""] = { [['<,'>move'>+1gv=gv]], "Move Current Line(s) Up" }, [""] = { [['<,'>move'<-2gv=gv]], "Move Current Line(s) Down" }, }, { mode = "x", }) -- Change behaviour of :terminal to be less like a vim buffer and more what I am used to -- Not sure why some bindings have to be escaped with which-key but not when using nvim api directly... local escape = function(string) return vim.api.nvim_replace_termcodes(string, true, true, true) end keys.register({ [""] = { escape([[]]), "Escape terminal mode" }, [""] = { [[]], "Delete Word" }, [""] = { [[lua require'FTerm'.toggle()]], "Toggle the Terminal" }, }, { mode = "t", }) cheatsheet("") cheatsheet("ALT + 1 => Toggle the Terminal") cheatsheet("") keys.register({ [""] = { [[lua require'FTerm'.toggle()]], "Toggle the Terminal" }, }) -- Clear highlighted search results whenever ESC is hit keys.register({ [""] = { [[nohlsearch]], "Clear Highlighted Text" } }) end