vim-settings/neovim/lua/_bindings.lua

67 lines
3.1 KiB
Lua
Raw Normal View History

2021-09-16 01:13:17 +00:00
local utils = require("utils")
utils.keymap_set("n", "<C-L><C-L>", ":set wrap!<CR>", { desc = "Toggle line wrapping" })
utils.keymap_set("n", "<leader>lw", ":set wrap!<CR>", { desc = "Toggle line wrapping" })
utils.keymap_set("n", "<C-N><C-N>", ":set invnumber<CR>", { desc = "Toggle line numbers" })
utils.keymap_set("n", "<leader>ln", ":set invnumber<CR>", { desc = "Toggle line numbers" })
utils.keymap_set("n", "<leader>/", ":set hlsearch! hlsearch?<CR>", { desc = "Toggle search highlighting" })
utils.keymap_set("n", "<leader>cs", ":nohlsearch<CR>", { desc = "Clear search highlighting" })
utils.keymap_set("n", "<leader>ws", ":set list!<CR>", { desc = "Toggle whitespace characters" })
2021-08-24 17:38:14 +00:00
-- Save and quit typos
utils.keymap_set("c", "WQ<CR>", "wq<CR>", { desc = "Write and quit" })
utils.keymap_set("c", "Wq<CR>", "wq<CR>", { desc = "Write and quit" })
utils.keymap_set("c", "W<CR>", "w<CR>", { desc = "Write" })
utils.keymap_set("c", "Q<CR>", "q<CR>", { desc = "Quit" })
utils.keymap_set("c", "Q!<CR>", "q!<CR>", { desc = "Force quit" })
utils.keymap_set("c", "Qa<CR>", "qa<CR>", { desc = "Quit all" })
utils.keymap_set("c", "Qa!<CR>", "qa!<CR>", { desc = "Force quit all" })
utils.keymap_set("c", "QA<CR>", "qa<CR>", { desc = "Quit all" })
utils.keymap_set("c", "QA!<CR>", "qa!<CR>", { desc = "Force quit all" })
utils.keymap_set("c", "w;", "w", { desc = "Write" })
utils.keymap_set("c", "W;", "w", { desc = "Write" })
utils.keymap_set("c", "q;", "q", { desc = "Quit" })
utils.keymap_set("c", "Q;", "q", { desc = "Quit" })
2021-08-24 17:38:14 +00:00
-- Paste over
utils.keymap_set("v", "pp", "p", { desc = "Paste" })
utils.keymap_set("v", "po", '"_dP', { desc = "Paste over and keep clipboard" })
2021-08-24 17:38:14 +00:00
-- Buffer nav
utils.keymap_set("n", "gb", ":bnext<CR>", { desc = "Next buffer" })
utils.keymap_set("n", "gB", ":bprevious<CR>", { desc = "Previous buffer" })
2021-08-24 17:38:14 +00:00
-- Easy redo
utils.keymap_set("n", "U", ":redo<CR>", { desc = "Redo" })
2021-08-24 17:38:14 +00:00
-- Make escape easier
utils.keymap_set("i", "jk", "<esc>", { desc = "Escape insert" })
utils.keymap_set("i", "``", "<esc>", { desc = "Escape insert" })
utils.keymap_set("v", "``", "<esc>", { desc = "Escape visual" })
-- 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
utils.keymap_set("i", "<C-Space>", "v:lua.complete_space()", { expr = true })
2024-05-29 20:16:28 +00:00
vim.api.nvim_create_user_command("TagsUpdate", "!ctags -R .", { desc = "Update ctags" })
vim.api.nvim_create_user_command("Todo", "grep TODO", { desc = "Search for TODO tags" })
vim.api.nvim_create_user_command("Spell", "setlocal spell! spelllang=en_us", { desc = "Toggle spelling" })
2021-09-09 23:05:45 +00:00
-- Pop spelling completion for word under cursor
utils.keymap_set("n", "<leader>s", "viw<esc>a<c-x>s", { desc = "Show spelling suggestions" })
2021-09-18 23:39:56 +00:00
-- Build on F5
utils.keymap_set("n", "<F5>", ":make<CR>", { desc = "Run make" })