vim-settings/neovim/lua/_bindings.lua

69 lines
2.2 KiB
Lua
Raw Permalink Normal View History

2021-09-16 01:13:17 +00:00
local utils = require("utils")
2021-08-24 17:38:14 +00:00
local map = vim.api.nvim_set_keymap
2021-12-15 17:37:51 +00:00
local opt_silent = { silent = true }
local opt_default = { silent = true, noremap = true }
2021-08-24 17:38:14 +00:00
map("n", "<C-L><C-L>", ":set wrap!<CR>", opt_silent)
map("n", "<leader>lw", ":set wrap!<CR>", opt_silent)
map("n", "<C-N><C-N>", ":set invnumber<CR>", opt_silent)
map("n", "<leader>ln", ":set invnumber<CR>", opt_silent)
map("n", "<leader>/", ":set hlsearch! hlsearch?<CR>", opt_silent)
map("n", "<leader>cs", ":nohlsearch<CR>", opt_silent)
map("n", "<leader>ws", ":set list!<CR>", opt_silent)
2021-08-24 17:38:14 +00:00
-- Save and quit typos
map("c", "WQ<CR>", "wq<CR>", opt_silent)
map("c", "Wq<CR>", "wq<CR>", opt_silent)
map("c", "W<CR>", "w<CR>", opt_silent)
map("c", "Q<CR>", "q<CR>", opt_silent)
map("c", "Q!<CR>", "q!<CR>", opt_silent)
map("c", "Qa<CR>", "qa<CR>", opt_silent)
map("c", "Qa!<CR>", "qa!<CR>", opt_silent)
map("c", "QA<CR>", "qa<CR>", opt_silent)
map("c", "QA!<CR>", "qa!<CR>", opt_silent)
map("c", "w;", "w", opt_default)
map("c", "W;", "w", opt_default)
map("c", "q;", "q", opt_default)
map("c", "Q;", "q", opt_default)
-- Paste over
map("v", "pp", "p", opt_default)
map("v", "po", '"_dP', opt_default)
-- Buffer nav
map("n", "gb", ":bnext<CR>", {})
map("n", "gB", ":bprevious<CR>", {})
-- Easy redo
map("n", "U", ":redo<CR>", opt_default)
-- Make escape easier
map("i", "jk", "<esc>", opt_default)
map("i", "``", "<esc>", opt_default)
map("v", "``", "<esc>", opt_default)
-- C-Space completion
2021-09-16 01:13:17 +00:00
function _G.complete_space()
if vim.fn.pumvisible() == 1 then
2021-09-16 01:13:17 +00:00
return utils.t("<C-n>")
elseif utils.is_plugin_loaded("completion-nvim") then
2021-09-16 01:13:17 +00:00
return utils.t("<Plug>(completion_trigger)")
elseif utils.is_plugin_loaded("nvim-compe") then
return vim.fn["compe#complete"]()
2021-09-30 17:58:22 +00:00
elseif utils.is_plugin_loaded("nvim-cmp") then
return utils.t("<Plug>(cmp_complete)")
else
2021-09-16 01:13:17 +00:00
return utils.t("<C-x><C-o>")
end
end
2021-12-15 17:37:51 +00:00
map("i", "<C-Space>", "v:lua.complete_space()", { expr = true })
2021-09-09 23:05:45 +00:00
-- Easily toggle spelling
2021-12-15 17:37:51 +00:00
vim.cmd("command Spell setlocal spell! spelllang=en_us")
2021-09-09 23:05:45 +00:00
-- Pop spelling completion for word under cursor
map("n", "<leader>s", "viw<esc>a<c-x>s", {})
2021-09-18 23:39:56 +00:00
-- Build on F5
map("n", "<F5>", ":make<CR>", {})