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}) -- OPEN TERMINALS -- map("n", "", ":vnew +terminal | setlocal nobuflisted ", opt) -- term over right map("n", "", ":10new +terminal | setlocal nobuflisted ", opt) -- term bottom map("n", "t", ":terminal ", opt) -- term buffer -- copy whole file content map("n", "", ":%y+", opt) -- toggle numbers map("n", "n", ":set nu!", opt) -- Truezen.nvim map("n", "zz", ":TZAtaraxis", opt) map("n", "zm", ":TZMinimalist", opt) map("n", "zf", ":TZFocus", opt) map("n", "", ":w ", opt) -- Commenter Keybinding map("n", "/", ":CommentToggle", opt) map("v", "/", ":CommentToggle", opt) -- compe stuff local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end local check_back_space = function() local col = vim.fn.col(".") - 1 if col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then return true else return false end end _G.tab_complete = function() if vim.fn.pumvisible() == 1 then return t "" elseif check_back_space() then return t "" else return vim.fn["compe#complete"]() end end _G.s_tab_complete = function() if vim.fn.pumvisible() == 1 then return t "" elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then return t "(vsnip-jump-prev)" else return t "" end end function _G.completions() local npairs if not pcall( function() npairs = require "nvim-autopairs" end ) then return end if vim.fn.pumvisible() == 1 then if vim.fn.complete_info()["selected"] ~= -1 then return vim.fn["compe#confirm"]("") end end return npairs.check_break_line_char() end -- compe mappings map("i", "", "v:lua.tab_complete()", {expr = true}) map("s", "", "v:lua.tab_complete()", {expr = true}) map("i", "", "v:lua.s_tab_complete()", {expr = true}) map("s", "", "v:lua.s_tab_complete()", {expr = true}) map("i", "", "v:lua.completions()", {expr = true}) -- nvimtree map("n", "", ":NvimTreeToggle", opt) -- format code map("n", "fm", ":Neoformat", opt) -- dashboard stuff map("n", "db", ":Dashboard", opt) map("n", "fn", ":DashboardNewFile", opt) map("n", "bm", ":DashboardJumpMarks", opt) map("n", "l", ":SessionLoad", opt) map("n", "s", ":SessionSave", opt) -- Telescope map("n", "fw", ":Telescope live_grep", opt) map("n", "gt", ":Telescope git_status ", opt) map("n", "cm", ":Telescope git_commits ", opt) map("n", "ff", ":Telescope find_files ", opt) map("n", "fp", ":Telescope media_files ", opt) map("n", "fb", ":Telescope buffers", opt) map("n", "fh", ":Telescope help_tags", opt) map("n", "fo", ":Telescope oldfiles", opt) map("n", "th", ":Telescope themes", opt) -- bufferline tab stuff map("n", "", ":enew", opt) -- new buffer map("n", "b", ":tabnew", opt) -- new tab map("n", "", ":bd!", opt) -- close tab -- move between tabs map("n", "", ":BufferLineCycleNext", opt) map("n", "", ":BufferLineCyclePrev", opt) -- use ESC to turn off search highlighting map("n", "", ":noh", opt) -- get out of terminal with jk map("t", "jk", "", opt) -- Packer commands till because we are not loading it at startup vim.cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()") vim.cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()") vim.cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()") vim.cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()") vim.cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()") -- Vim Fugitive map("n", "gs", ":Git", opt) map("n", "gh", ":diffget //2", opt) map("n", "gl", ":diffget //3", opt) map("n", "gb", ":Git blame", opt)