2021-08-12 07:58:03 -04:00
|
|
|
local user_map = require("chadrc").mappings
|
|
|
|
local miscMap = user_map.misc
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
local cmd = vim.cmd
|
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
local function map(mode, lhs, rhs, opts)
|
2021-08-16 03:49:09 -04:00
|
|
|
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)
|
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
|
2021-08-16 03:49:09 -04:00
|
|
|
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-07-26 05:02:29 -04:00
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
-- copy whole file content
|
2021-08-12 07:58:03 -04:00
|
|
|
map("n", miscMap.copywhole_file, ":%y+<CR>", opt)
|
2021-04-20 00:15:14 -04:00
|
|
|
|
2021-06-24 13:19:42 -04:00
|
|
|
-- toggle numbers
|
2021-08-12 07:58:03 -04:00
|
|
|
map("n", miscMap.toggle_linenr, ":set nu!<CR>", opt)
|
|
|
|
|
2021-08-13 11:59:17 -04:00
|
|
|
|
2021-08-18 06:13:35 -04:00
|
|
|
-- terminals
|
|
|
|
local function terms()
|
|
|
|
local m = user_map.terms
|
2021-08-17 13:51:10 -04:00
|
|
|
|
2021-08-18 06:13:35 -04:00
|
|
|
-- get out of terminal mode
|
|
|
|
map("t", m.esc_termmode, "<C-\\><C-n>", opt)
|
|
|
|
-- hide a term from within terminal mode
|
|
|
|
map("t", m.esc_hide_termmode, "<C-\\><C-n> :lua require('utils').close_buffer() <CR>", opt)
|
|
|
|
-- pick a hidden term
|
|
|
|
map("n", m.pick_term, ":Telescope terms <CR>", opt)
|
2021-08-13 11:59:17 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
-- Open terminals
|
2021-08-18 06:13:35 -04:00
|
|
|
-- TODO this opens on top of an existing vert/hori term, fixme
|
|
|
|
map("n", m.new_wind, ":execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>", opt)
|
|
|
|
map("n", m.new_vert, ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert <CR>", opt)
|
|
|
|
map("n", m.new_hori, ":execute 15 .. 'new +terminal' | let b:term_type = 'hori' | startinsert <CR>", opt)
|
2021-08-13 11:59:17 -04:00
|
|
|
end
|
|
|
|
|
2021-08-18 06:13:35 -04:00
|
|
|
terms()
|
|
|
|
|
2021-08-12 07:58:03 -04:00
|
|
|
M.truezen = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.truezen
|
2021-04-20 00:15:14 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m.ataraxisMode, ":TZAtaraxis<CR>", opt)
|
|
|
|
map("n", m.minimalisticmode, ":TZMinimalist<CR>", opt)
|
|
|
|
map("n", m.focusmode, ":TZFocus<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
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
|
|
|
|
2021-08-12 07:58:03 -04:00
|
|
|
M.comment_nvim = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.comment_nvim.comment_toggle
|
|
|
|
map("n", m, ":CommentToggle<CR>", opt)
|
|
|
|
map("v", m, ":CommentToggle<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
2021-06-24 13:19:42 -04:00
|
|
|
|
2021-08-12 07:58:03 -04:00
|
|
|
M.nvimtree = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.nvimtree.treetoggle
|
2021-08-12 07:58:03 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m, ":NvimTreeToggle<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
M.neoformat = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.neoformat.format
|
|
|
|
map("n", m, ":Neoformat<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
M.dashboard = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.dashboard
|
2021-08-12 07:58:03 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m.open, ":Dashboard<CR>", opt)
|
|
|
|
map("n", m.newfile, ":DashboardNewFile<CR>", opt)
|
|
|
|
map("n", m.bookmarks, ":DashboardJumpMarks<CR>", opt)
|
|
|
|
map("n", m.sessionload, ":SessionLoad<CR>", opt)
|
|
|
|
map("n", m.sessionsave, ":SessionSave<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
M.telescope = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.telescope
|
|
|
|
|
|
|
|
map("n", m.live_grep, ":Telescope live_grep<CR>", opt)
|
|
|
|
map("n", m.git_status, ":Telescope git_status <CR>", opt)
|
|
|
|
map("n", m.git_commits, ":Telescope git_commits <CR>", opt)
|
|
|
|
map("n", m.find_files, ":Telescope find_files <CR>", opt)
|
|
|
|
map("n", m.buffers, ":Telescope buffers<CR>", opt)
|
|
|
|
map("n", m.help_tags, ":Telescope help_tags<CR>", opt)
|
|
|
|
map("n", m.oldfiles, ":Telescope oldfiles<CR>", opt)
|
|
|
|
map("n", m.themes, ":Telescope themes<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
|
|
|
|
2021-08-14 03:30:01 -04:00
|
|
|
M.telescope_media = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.telescope_media
|
|
|
|
map("n", m.media_files, ":Telescope media_files <CR>", opt)
|
2021-08-14 03:30:01 -04:00
|
|
|
end
|
|
|
|
|
2021-08-16 12:48:08 -04:00
|
|
|
M.chadsheet = function()
|
|
|
|
local m = user_map.chadsheet
|
|
|
|
|
|
|
|
map("n", m.default_keys, ":lua require('cheatsheet').show_cheatsheet_telescope()<CR>", opt)
|
|
|
|
map(
|
|
|
|
"n",
|
|
|
|
m.user_keys,
|
|
|
|
":lua require('cheatsheet').show_cheatsheet_telescope{bundled_cheatsheets = false, bundled_plugin_cheatsheets = false }<CR>",
|
|
|
|
opt
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-08-12 07:58:03 -04:00
|
|
|
M.bufferline = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.bufferline
|
2021-08-12 07:58:03 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m.new_buffer, ":enew<CR>", opt) -- new buffer
|
|
|
|
map("n", m.newtab, ":tabnew<CR>", opt) -- new tab
|
2021-08-18 06:13:35 -04:00
|
|
|
map("n", m.close, ":lua require('utils').close_buffer() <CR>", opt) -- close buffer
|
2021-08-12 07:58:03 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
-- move between tabs
|
2021-08-12 07:58:03 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m.cycleNext, ":BufferLineCycleNext<CR>", opt)
|
|
|
|
map("n", m.cyclePrev, ":BufferLineCyclePrev<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
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-23 11:11:09 -04:00
|
|
|
-- Packer commands till because we are not loading it at startup
|
2021-08-16 03:49:09 -04:00
|
|
|
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()"
|
2021-08-12 07:58:03 -04:00
|
|
|
|
|
|
|
M.fugitive = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.fugitive
|
2021-08-12 07:58:03 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m.Git, ":Git<CR>", opt)
|
|
|
|
map("n", m.diffget_2, ":diffget //2<CR>", opt)
|
|
|
|
map("n", m.diffget_3, ":diffget //3<CR>", opt)
|
|
|
|
map("n", m.git_blame, ":Git blame<CR>", opt)
|
2021-08-12 07:58:03 -04:00
|
|
|
end
|
|
|
|
|
2021-08-14 04:14:28 -04:00
|
|
|
-- navigation within insert mode
|
|
|
|
local check_insertNav = require("chadrc").options.enable_insertNav
|
|
|
|
|
|
|
|
if check_insertNav == true then
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.insert_nav
|
|
|
|
|
|
|
|
map("i", m.forward, "<Right>", opt)
|
|
|
|
map("i", m.backward, "<Left>", opt)
|
|
|
|
map("i", m.top_of_line, "<ESC>^i", opt)
|
|
|
|
map("i", m.end_of_line, "<End>", opt)
|
|
|
|
map("i", m.next_line, "<Up>", opt)
|
|
|
|
map("i", m.prev_line, "<Down>", opt)
|
2021-08-14 04:14:28 -04:00
|
|
|
end
|
|
|
|
|
2021-08-14 15:14:55 -04:00
|
|
|
local theme_toggler = require("chadrc").ui.theme_toggler
|
|
|
|
|
|
|
|
if theme_toggler == true then
|
2021-08-16 03:49:09 -04:00
|
|
|
local m = user_map.misc.theme_toggle
|
2021-08-14 15:14:55 -04:00
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
map("n", m, ":lua require('utils').toggle_theme(require('chadrc').ui.fav_themes)<CR>", opt)
|
2021-08-14 15:14:55 -04:00
|
|
|
end
|
2021-08-12 07:58:03 -04:00
|
|
|
return M
|