89 lines
2.5 KiB
Lua
89 lines
2.5 KiB
Lua
local opts = { noremap = true, silent = true }
|
|
local term_opts = { silent = true }
|
|
|
|
-- Shorten function name
|
|
local keymap = vim.api.nvim_set_keymap
|
|
|
|
--Remap space as leader key
|
|
keymap("n", "<Space>", "", opts)
|
|
vim.g.mapleader = " "
|
|
vim.g.maplocalleader = " "
|
|
|
|
-- Modes
|
|
-- normal_mode = 'n',
|
|
-- insert_mode = 'i',
|
|
-- visual_mode = 'v',
|
|
-- visual_block_mode = 'x',
|
|
-- term_mode = 't',
|
|
-- command_mode = 'c',
|
|
|
|
keymap("n", "c", '"_c', opts)
|
|
|
|
-- Normal --
|
|
-- Resize with arrows
|
|
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
|
|
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
|
|
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
|
|
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
|
|
|
|
-- Naviagate buffers
|
|
keymap("n", "<S-l>", ":BufferLineCycleNext<CR>", opts)
|
|
keymap("n", "<S-h>", ":BufferLineCyclePrev<CR>", opts)
|
|
|
|
-- Move text up and down
|
|
keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
|
|
keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
|
|
|
|
-- Insert --
|
|
-- Press jk fast to enter
|
|
keymap("i", "jk", "<ESC>", opts)
|
|
keymap("i", "zzz", "<ESC> zz a", opts)
|
|
|
|
-- Visual --
|
|
-- Stay in indent mode
|
|
keymap("v", "<", "<gv", opts)
|
|
keymap("v", ">", ">gv", opts)
|
|
|
|
-- Move text up and down
|
|
keymap("v", "<A-j>", ":m .+1<CR>==", opts)
|
|
keymap("v", "<A-k>", ":m .-2<CR>==", opts)
|
|
keymap("v", "p", '"_dP', opts)
|
|
keymap("v", "P", '"_dP', opts)
|
|
|
|
-- My bit's an pieces currently unsorted
|
|
-- Spellcheck
|
|
keymap("n", "<leader>o", ":setlocal spell! spelllang=en_us<CR>", opts)
|
|
|
|
-- Tree
|
|
keymap("n", "<leader>n", ":NvimTreeToggle<CR>", opts)
|
|
|
|
-- Telescope
|
|
keymap("n", "<leader>ff", ":Telescope find_files<CR>", opts)
|
|
keymap("n", "<leader>ft", ":Telescope live_grep<CR>", opts)
|
|
keymap("n", "<leader>fp", ":Telescope projects<CR>", opts)
|
|
keymap("n", "<leader>fb", ":Telescope buffers<CR>", opts)
|
|
keymap("n", "<leader>fr", ":Telescope oldfiles<CR>", opts)
|
|
|
|
-- Goyo
|
|
keymap("n", "<leader>f", ":Goyo<CR>", opts)
|
|
|
|
-- Copy and Paste
|
|
keymap("n", "<C-c>", '"+y', opts)
|
|
keymap("n", "<C-p", '"+p', opts)
|
|
|
|
-- Replace All is S
|
|
vim.cmd([[nnoremap S :%s//g<Left><Left>]])
|
|
-- keymap('n', '<S-s>', ':%s//g<Left><Left>', opts)
|
|
|
|
-- Compile the document with default compiler script
|
|
vim.cmd([[map <leader>c :w! \| !compiler "<c-r>%"<CR>]])
|
|
-- keymap('n', '<leader>c', ':w! | !compiler <c-r>%<CR>', opts)
|
|
|
|
-- Open compiled document
|
|
keymap("n", "<leader>p", ":!opout <c-r>%<CR><CR>", opts)
|
|
|
|
-- Attempt sudo for files that require it
|
|
keymap("n", "w!!", 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!', opts)
|
|
|
|
keymap("n", "<C-z>", "<cmd>ZenMode<cr>", opts)
|