2021-06-24 18:19:42 +01:00
|
|
|
local function map(mode, lhs, rhs, opts)
|
2021-06-27 16:29:39 +01:00
|
|
|
local options = {noremap = true, silent = true}
|
2021-03-13 01:23:02 +00:00
|
|
|
if opts then
|
|
|
|
options = vim.tbl_extend("force", options, opts)
|
|
|
|
end
|
|
|
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
2021-03-07 14:22:30 +00:00
|
|
|
end
|
|
|
|
|
2021-04-21 08:16:24 +01:00
|
|
|
local opt = {}
|
|
|
|
|
2021-06-24 18:19:42 +01:00
|
|
|
-- dont copy any deleted text , this is disabled by default so uncomment the below mappings if you want them
|
2021-05-09 09:22:38 +01:00
|
|
|
--[[ remove this line
|
2021-04-21 08:16:24 +01:00
|
|
|
|
|
|
|
map("n", "dd", [=[ "_dd ]=], opt)
|
|
|
|
map("v", "dd", [=[ "_dd ]=], opt)
|
|
|
|
map("v", "x", [=[ "_x ]=], opt)
|
|
|
|
|
2021-05-09 09:22:38 +01:00
|
|
|
this line too ]]
|
2021-06-24 18:19:42 +01:00
|
|
|
--
|
|
|
|
|
2021-07-18 06:42:54 +01:00
|
|
|
-- escape with 'jk' mapping
|
2021-07-17 11:43:42 +01:00
|
|
|
vim.api.nvim_set_keymap("i", "jk", "<esc>", {})
|
2021-07-18 06:42:54 +01:00
|
|
|
vim.api.nvim_set_keymap("v", "jk", "<esc>", {})
|
|
|
|
vim.api.nvim_set_keymap("t", "jk", "<esc>", {})
|
2021-07-17 11:43:42 +01:00
|
|
|
|
2021-07-17 12:18:41 +01:00
|
|
|
-- Don't copy the replaced text after pasting in visual mode
|
|
|
|
map("v", "p", '"_dP', opt)
|
|
|
|
|
2021-04-02 06:36:20 +01:00
|
|
|
-- OPEN TERMINALS --
|
2021-06-01 19:26:37 +01:00
|
|
|
map("n", "<C-l>", [[<Cmd>vnew term://bash <CR>]], opt) -- term over right
|
|
|
|
map("n", "<C-x>", [[<Cmd> split term://bash | resize 10 <CR>]], opt) -- term bottom
|
|
|
|
map("n", "<C-t>t", [[<Cmd> tabnew | term <CR>]], opt) -- term newtab
|
2021-04-01 19:53:12 +01:00
|
|
|
|
2021-06-24 18:19:42 +01:00
|
|
|
-- copy whole file content
|
2021-04-02 06:36:20 +01:00
|
|
|
map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt)
|
2021-04-20 05:15:14 +01:00
|
|
|
|
2021-06-24 18:19:42 +01:00
|
|
|
-- toggle numbers
|
2021-04-20 05:15:14 +01:00
|
|
|
map("n", "<leader>n", [[ <Cmd> set nu!<CR>]], opt)
|
|
|
|
|
2021-06-24 18:19:42 +01:00
|
|
|
-- Truezen.nvim
|
2021-07-05 12:49:12 +01: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 09:22:38 +01:00
|
|
|
|
2021-06-27 13:45:58 +01:00
|
|
|
map("n", "<C-s>", ":w <CR>", opt)
|
2021-06-15 11:27:55 +01:00
|
|
|
|
|
|
|
-- Commenter Keybinding
|
2021-06-27 16:29:39 +01:00
|
|
|
map("n", "<leader>/", ":CommentToggle<CR>", opt)
|
|
|
|
map("v", "<leader>/", ":CommentToggle<CR>", opt)
|
2021-06-24 18:19:42 +01: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 16:47:47 +01:00
|
|
|
local npairs
|
|
|
|
if
|
|
|
|
not pcall(
|
|
|
|
function()
|
|
|
|
npairs = require "nvim-autopairs"
|
|
|
|
end
|
|
|
|
)
|
|
|
|
then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-06-24 18:19:42 +01: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 18:36:17 +01:00
|
|
|
|
2021-06-27 16:29:39 +01:00
|
|
|
-- nvimtree
|
|
|
|
map("n", "<C-n>", ":NvimTreeToggle<CR>", opt)
|
2021-06-26 03:01:15 +01:00
|
|
|
|
2021-06-27 16:29:39 +01:00
|
|
|
-- format code
|
2021-06-26 03:01:15 +01:00
|
|
|
map("n", "<Leader>fm", [[<Cmd> Neoformat<CR>]], opt)
|
2021-06-26 03:10:23 +01:00
|
|
|
|
|
|
|
-- dashboard stuff
|
|
|
|
map("n", "<Leader>fw", [[<Cmd> Telescope live_grep<CR>]], opt)
|
2021-06-26 03:41:39 +01:00
|
|
|
map("n", "<Leader>db", [[<Cmd> Dashboard<CR>]], opt)
|
2021-06-26 03:10:23 +01:00
|
|
|
map("n", "<Leader>fn", [[<Cmd> DashboardNewFile<CR>]], opt)
|
|
|
|
map("n", "<Leader>bm", [[<Cmd> DashboardJumpMarks<CR>]], opt)
|
2021-06-27 17:38:47 +01:00
|
|
|
map("n", "<C-s>l", [[<Cmd> SessionLoad<CR>]], opt)
|
|
|
|
map("n", "<C-s>s", [[<Cmd> SessionSave<CR>]], opt)
|
2021-06-26 03:41:39 +01:00
|
|
|
|
|
|
|
-- Telescope
|
|
|
|
map("n", "<Leader>gt", [[<Cmd> Telescope git_status <CR>]], opt)
|
|
|
|
map("n", "<Leader>cm", [[<Cmd> Telescope git_commits <CR>]], opt)
|
|
|
|
map("n", "<Leader>ff", [[<Cmd> Telescope find_files <CR>]], opt)
|
|
|
|
map("n", "<Leader>fp", [[<Cmd>lua require('telescope').extensions.media_files.media_files()<CR>]], opt)
|
2021-07-01 01:56:51 +01:00
|
|
|
map("n", "<Leader>fb", [[<Cmd>Telescope buffers<CR>]], opt)
|
2021-06-26 03:41:39 +01:00
|
|
|
map("n", "<Leader>fh", [[<Cmd>Telescope help_tags<CR>]], opt)
|
|
|
|
map("n", "<Leader>fo", [[<Cmd>Telescope oldfiles<CR>]], opt)
|
2021-06-27 13:45:58 +01:00
|
|
|
|
|
|
|
-- bufferline tab stuff
|
2021-06-27 16:29:39 +01:00
|
|
|
map("n", "<S-t>", ":tabnew<CR>", opt) -- new tab
|
|
|
|
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
|
2021-06-27 13:45:58 +01:00
|
|
|
|
|
|
|
-- move between tabs
|
|
|
|
map("n", "<TAB>", [[<Cmd>BufferLineCycleNext<CR>]], opt)
|
|
|
|
map("n", "<S-TAB>", [[<Cmd>BufferLineCyclePrev<CR>]], opt)
|
2021-07-17 04:38:45 +01:00
|
|
|
|
|
|
|
-- use ESC to turn off search highlighting
|
|
|
|
map("n", "<Esc>", ":noh<CR>", opts)
|
|
|
|
|
|
|
|
-- get out of terminal with ESC
|
|
|
|
map("t", "<Esc>", "<C-\\><C-n>", opts)
|