local user_map = require("chadrc").mappings local miscMap = user_map.misc local M = {} local cmd = vim.cmd local function map(mode, lhs, rhs, opts) local options = { noremap = true, silent = true } if opts then options = vim.tbl_extend("force", options, opts) end vim.api.nvim_set_keymap(mode, lhs, rhs, options) end local opt = {} -- dont copy any deleted text , this is disabled by default so uncomment the below mappings if you want them --[[ remove this line map("n", "dd", [=[ "_dd ]=], opt) map("v", "dd", [=[ "_dd ]=], opt) map("v", "x", [=[ "_x ]=], opt) this line too ]] -- -- Don't copy the replaced text after pasting in visual mode map("v", "p", '"_dP', opt) -- 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 map("", "j", 'v:count ? "j" : "gj"', { expr = true }) map("", "k", 'v:count ? "k" : "gk"', { expr = true }) map("", "", 'v:count ? "j" : "gj"', { expr = true }) map("", "", 'v:count ? "k" : "gk"', { expr = true }) -- copy whole file content map("n", miscMap.copywhole_file, ":%y+", opt) -- toggle numbers map("n", miscMap.toggle_linenr, ":set nu!", opt) -- open a new buffer as a Terminal -- get out of terminal with jk map("t", miscMap.esc_Termmode, "", opt) -- close current focused buffer, terminal or normal -- todo: don't close if non-terminal buffer is saved map("n", miscMap.close_buffer, ":bd!", opt) M.toggleterm = function() local m = user_map.toggleterm -- Open terminals map("n", m.toggle_window, ":lua termW:toggle() ", opt) map("n", m.toggle_vert, ":lua termV:toggle() ", opt) map("n", m.toggle_hori, ":lua termH:toggle() ", opt) -- toggle(HIDE) a term from within terminal edit mode map("t", m.hide_term, " :ToggleTerm ", opt) map("t", m.hide_term, " :ToggleTerm ", opt) map("t", m.hide_term, " :ToggleTerm ", opt) end M.truezen = function() local m = user_map.truezen map("n", m.ataraxisMode, ":TZAtaraxis", opt) map("n", m.minimalisticmode, ":TZMinimalist", opt) map("n", m.focusmode, ":TZFocus", opt) end map("n", "", ":w ", opt) M.comment_nvim = function() local m = user_map.comment_nvim.comment_toggle map("n", m, ":CommentToggle", opt) map("v", m, ":CommentToggle", opt) end M.nvimtree = function() local m = user_map.nvimtree.treetoggle map("n", m, ":NvimTreeToggle", opt) end M.neoformat = function() local m = user_map.neoformat.format map("n", m, ":Neoformat", opt) end M.dashboard = function() local m = user_map.dashboard map("n", m.open, ":Dashboard", opt) map("n", m.newfile, ":DashboardNewFile", opt) map("n", m.bookmarks, ":DashboardJumpMarks", opt) map("n", m.sessionload, ":SessionLoad", opt) map("n", m.sessionsave, ":SessionSave", opt) end M.telescope = function() local m = user_map.telescope map("n", m.live_grep, ":Telescope live_grep", opt) map("n", m.git_status, ":Telescope git_status ", opt) map("n", m.git_commits, ":Telescope git_commits ", opt) map("n", m.find_files, ":Telescope find_files ", opt) map("n", m.buffers, ":Telescope buffers", opt) map("n", m.help_tags, ":Telescope help_tags", opt) map("n", m.oldfiles, ":Telescope oldfiles", opt) map("n", m.themes, ":Telescope themes", opt) end M.telescope_media = function() local m = user_map.telescope_media map("n", m.media_files, ":Telescope media_files ", opt) end M.chadsheet = function() local m = user_map.chadsheet map("n", m.default_keys, ":lua require('cheatsheet').show_cheatsheet_telescope()", opt) map( "n", m.user_keys, ":lua require('cheatsheet').show_cheatsheet_telescope{bundled_cheatsheets = false, bundled_plugin_cheatsheets = false }", opt ) end M.bufferline = function() local m = user_map.bufferline map("n", m.new_buffer, ":enew", opt) -- new buffer map("n", m.newtab, ":tabnew", opt) -- new tab -- move between tabs map("n", m.cycleNext, ":BufferLineCycleNext", opt) map("n", m.cyclePrev, ":BufferLineCyclePrev", opt) end -- use ESC to turn off search highlighting map("n", "", ":noh", opt) -- Packer commands till because we are not loading it at startup cmd "silent! command PackerCompile lua require 'pluginList' require('packer').compile()" cmd "silent! command PackerInstall lua require 'pluginList' require('packer').install()" cmd "silent! command PackerStatus lua require 'pluginList' require('packer').status()" cmd "silent! command PackerSync lua require 'pluginList' require('packer').sync()" cmd "silent! command PackerUpdate lua require 'pluginList' require('packer').update()" M.fugitive = function() local m = user_map.fugitive map("n", m.Git, ":Git", opt) map("n", m.diffget_2, ":diffget //2", opt) map("n", m.diffget_3, ":diffget //3", opt) map("n", m.git_blame, ":Git blame", opt) end -- navigation within insert mode local check_insertNav = require("chadrc").options.enable_insertNav if check_insertNav == true then local m = user_map.insert_nav map("i", m.forward, "", opt) map("i", m.backward, "", opt) map("i", m.top_of_line, "^i", opt) map("i", m.end_of_line, "", opt) map("i", m.next_line, "", opt) map("i", m.prev_line, "", opt) end local theme_toggler = require("chadrc").ui.theme_toggler if theme_toggler == true then local m = user_map.misc.theme_toggle map("n", m, ":lua require('utils').toggle_theme(require('chadrc').ui.fav_themes)", opt) end return M