2021-06-24 13:19:42 -04:00
|
|
|
local function map(mode, lhs, rhs, opts)
|
2021-06-27 11:29:39 -04:00
|
|
|
local options = {noremap = true, silent = true}
|
2021-03-12 20:23:02 -05:00
|
|
|
if opts then
|
|
|
|
options = vim.tbl_extend("force", options, opts)
|
|
|
|
end
|
|
|
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
2021-03-07 09:22:30 -05:00
|
|
|
end
|
|
|
|
|
2021-04-21 03:16:24 -04:00
|
|
|
local opt = {}
|
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
-- dont copy any deleted text , this is disabled by default so uncomment the below mappings if you want them
|
2021-05-09 04:22:38 -04:00
|
|
|
--[[ remove this line
|
2021-04-21 03:16:24 -04:00
|
|
|
|
|
|
|
map("n", "dd", [=[ "_dd ]=], opt)
|
|
|
|
map("v", "dd", [=[ "_dd ]=], opt)
|
|
|
|
map("v", "x", [=[ "_x ]=], opt)
|
|
|
|
|
2021-05-09 04:22:38 -04:00
|
|
|
this line too ]]
|
2021-06-24 13:19:42 -04:00
|
|
|
--
|
|
|
|
|
2021-07-17 07:18:41 -04:00
|
|
|
-- Don't copy the replaced text after pasting in visual mode
|
|
|
|
map("v", "p", '"_dP', opt)
|
|
|
|
|
2021-07-26 05:02:29 -04:00
|
|
|
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
|
|
|
|
-- 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("", "<Down>", 'v:count ? "j" : "gj"', {expr = true})
|
|
|
|
map("", "<Up>", 'v:count ? "k" : "gk"', {expr = true})
|
|
|
|
|
2021-04-02 01:36:20 -04:00
|
|
|
-- OPEN TERMINALS --
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<C-l>", ":vnew +terminal | setlocal nobuflisted <CR>", opt) -- term over right
|
|
|
|
map("n", "<C-x>", ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom
|
2021-07-28 10:23:19 -04:00
|
|
|
map("n", "<C-t>t", ":terminal <CR>", opt) -- term buffer
|
2021-04-01 14:53:12 -04:00
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
-- copy whole file content
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<C-a>", ":%y+<CR>", opt)
|
2021-04-20 00:15:14 -04:00
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
-- toggle numbers
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<leader>n", ":set nu!<CR>", opt)
|
2021-04-20 00:15:14 -04:00
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
-- Truezen.nvim
|
2021-07-05 07:49:12 -04:00
|
|
|
map("n", "<leader>zz", ":TZAtaraxis<CR>", opt)
|
|
|
|
map("n", "<leader>zm", ":TZMinimalist<CR>", opt)
|
|
|
|
map("n", "<leader>zf", ":TZFocus<CR>", opt)
|
2021-05-09 04:22:38 -04:00
|
|
|
|
2021-06-27 08:45:58 -04:00
|
|
|
map("n", "<C-s>", ":w <CR>", opt)
|
2021-06-15 06:27:55 -04:00
|
|
|
|
|
|
|
-- Commenter Keybinding
|
2021-06-27 11:29:39 -04:00
|
|
|
map("n", "<leader>/", ":CommentToggle<CR>", opt)
|
|
|
|
map("v", "<leader>/", ":CommentToggle<CR>", opt)
|
2021-06-24 13:19:42 -04:00
|
|
|
|
|
|
|
-- 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 "<C-n>"
|
|
|
|
elseif check_back_space() then
|
|
|
|
return t "<Tab>"
|
|
|
|
else
|
|
|
|
return vim.fn["compe#complete"]()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
_G.s_tab_complete = function()
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
return t "<C-p>"
|
|
|
|
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
|
|
|
|
return t "<Plug>(vsnip-jump-prev)"
|
|
|
|
else
|
|
|
|
return t "<S-Tab>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function _G.completions()
|
2021-07-15 11:47:47 -04:00
|
|
|
local npairs
|
|
|
|
if
|
|
|
|
not pcall(
|
|
|
|
function()
|
|
|
|
npairs = require "nvim-autopairs"
|
|
|
|
end
|
|
|
|
)
|
|
|
|
then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
if vim.fn.complete_info()["selected"] ~= -1 then
|
|
|
|
return vim.fn["compe#confirm"]("<CR>")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return npairs.check_break_line_char()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- compe mappings
|
|
|
|
map("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
|
|
|
map("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
|
|
|
map("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
|
|
map("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
|
|
map("i", "<CR>", "v:lua.completions()", {expr = true})
|
2021-06-25 13:36:17 -04:00
|
|
|
|
2021-06-27 11:29:39 -04:00
|
|
|
-- nvimtree
|
|
|
|
map("n", "<C-n>", ":NvimTreeToggle<CR>", opt)
|
2021-06-25 22:01:15 -04:00
|
|
|
|
2021-06-27 11:29:39 -04:00
|
|
|
-- format code
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<Leader>fm", ":Neoformat<CR>", opt)
|
2021-06-25 22:10:23 -04:00
|
|
|
|
|
|
|
-- dashboard stuff
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<Leader>db", ":Dashboard<CR>", opt)
|
|
|
|
map("n", "<Leader>fn", ":DashboardNewFile<CR>", opt)
|
|
|
|
map("n", "<Leader>bm", ":DashboardJumpMarks<CR>", opt)
|
|
|
|
map("n", "<C-s>l", ":SessionLoad<CR>", opt)
|
|
|
|
map("n", "<C-s>s", ":SessionSave<CR>", opt)
|
2021-06-25 22:41:39 -04:00
|
|
|
|
|
|
|
-- Telescope
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<Leader>fw", ":Telescope live_grep<CR>", opt)
|
|
|
|
map("n", "<Leader>gt", ":Telescope git_status <CR>", opt)
|
|
|
|
map("n", "<Leader>cm", ":Telescope git_commits <CR>", opt)
|
|
|
|
map("n", "<Leader>ff", ":Telescope find_files <CR>", opt)
|
2021-07-24 00:41:21 -04:00
|
|
|
map("n", "<Leader>fp", ":Telescope media_files <CR>", opt)
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<Leader>fb", ":Telescope buffers<CR>", opt)
|
|
|
|
map("n", "<Leader>fh", ":Telescope help_tags<CR>", opt)
|
|
|
|
map("n", "<Leader>fo", ":Telescope oldfiles<CR>", opt)
|
2021-06-27 08:45:58 -04:00
|
|
|
|
|
|
|
-- bufferline tab stuff
|
2021-07-21 01:56:25 -04:00
|
|
|
map("n", "<S-t>", ":enew<CR>", opt) -- new buffer
|
|
|
|
map("n", "<C-t>b", ":tabnew<CR>", opt) -- new tab
|
2021-06-27 11:29:39 -04:00
|
|
|
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
|
2021-06-27 08:45:58 -04:00
|
|
|
|
|
|
|
-- move between tabs
|
2021-07-23 03:52:53 -04:00
|
|
|
map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt)
|
|
|
|
map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
|
2021-07-16 23:38:45 -04:00
|
|
|
|
|
|
|
-- use ESC to turn off search highlighting
|
2021-07-18 06:40:23 -04:00
|
|
|
map("n", "<Esc>", ":noh<CR>", opt)
|
2021-07-16 23:38:45 -04:00
|
|
|
|
2021-07-18 06:40:23 -04:00
|
|
|
-- get out of terminal with jk
|
|
|
|
map("t", "jk", "<C-\\><C-n>", opt)
|
2021-07-23 13:22:09 -04:00
|
|
|
|
2021-07-23 11:11:09 -04:00
|
|
|
-- 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()")
|
2021-07-23 13:57:32 -04:00
|
|
|
|
2021-07-23 13:22:09 -04:00
|
|
|
-- Vim Fugitive
|
|
|
|
map("n", "<Leader>gs", ":Git<CR>", opt)
|
|
|
|
map("n", "<Leader>gh", ":diffget //2<CR>", opt)
|
|
|
|
map("n", "<Leader>gl", ":diffget //3<CR>", opt)
|
|
|
|
map("n", "<Leader>gb", ":Git blame<CR>", opt)
|