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 ]] -- -- OPEN TERMINALS -- -- map("n", "", [[vnew term://zsh ]], opt) -- term over right -- map("n", "", [[ split term://zsh | resize 10 ]], opt) -- term bottom -- map("n", "t", [[ tabnew | term ]], opt) -- term newtab -- swap ` and ' map("n", "`", "'", opt) map("n", "'", '`', opt) -- copy whole file content map("n", "", [[ %y+]], opt) -- toggle relative number map("n", "", ":set invrelativenumber", opt) map("n", "", ":w ", opt) -- map("n", "", ":bpspbnbd! ", opt) map("i", "kj", "`^", opt) map("i", "jk", "`^", opt) -- copy till end of line map("n", "Y", "y$", opt) -- select previously changed or yanked text map("n", "gm", "`[v`]", opt) -- go to the next matching parenthesis map("n", "gp", "%", 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 = require("nvim-autopairs") 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) -- map("n", "fn", [[ DashboardNewFile]], opt) -- map("n", "bm", [[ DashboardJumpMarks]], opt) -- map("n", "l", [[ SessionLoad]], opt) -- map("n", "s", [[ SessionSave]], opt) -- Telescope -- map("n", "gt", [[ Telescope git_status ]], opt) -- map("n", "cm", [[ Telescope git_commits ]], opt) -- map("n", "fp", [[lua require('telescope').extensions.media_files.media_files()]], opt) -- map("n", "fb", [[Telescope buffers]], opt) -- map("n", "fh", [[Telescope help_tags]], opt) -- map("n", "fo", [[Telescope oldfiles]], opt) -- bufferline tab stuff map("n", "", ":tabnew", opt) -- new tab map("n", "", ":bd!", opt) -- close tab -- indent with tabs map("n", "", '>>', opt) map("n", "", '<<', opt) map("v", "", '>>', opt) map("v", "", '<<', opt) map("n", "", ":set invhlsearch", opt) -- move around *visually* map("n", "j", "gj", opt) map("n", "k", "gk", opt)