summaryrefslogtreecommitdiffstats
path: root/lua/conf/binds.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/conf/binds.lua')
-rw-r--r--lua/conf/binds.lua48
1 files changed, 25 insertions, 23 deletions
diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua
index 8f3c05e..9a9a7d6 100644
--- a/lua/conf/binds.lua
+++ b/lua/conf/binds.lua
@@ -1,23 +1,25 @@
-local misc = require('core.misc')
+local misc = require("core.misc")
local map = misc.map
-- vim binds
-vim.g.mapleader = ' ' -- set leader key
+vim.g.mapleader = " " -- set leader key
-map('x', '<leader>p', [["_dP]], { desc = 'Greatest remap of all time.' })
-map('n', '<esc>', ':nohlsearch<Bar>:echo<CR>', { desc = 'Clear search.' })
+map("x", "<leader>p", [["_dP]], { desc = "Greatest remap of all time." })
+map("n", "<esc>", ":nohlsearch<Bar>:echo<CR>", { desc = "Clear search." })
-- move selected text up/down
-map('v', '<S-k>', ":m '<-2<CR>gv=gv", { desc = 'Move selected text up.' })
-map('v', '<S-j>', ":m '>+1<CR>gv=gv", { desc = 'Move selected text down.' })
+map("v", "<S-k>", ":m '<-2<CR>gv=gv", { desc = "Move selected text up." })
+map("v", "<S-j>", ":m '>+1<CR>gv=gv", { desc = "Move selected text down." })
-- the cursor STAYS IN THE MIDDLE
-map('n', '<S-j>', 'mzJ`z<cmd>delm z<CR>') -- when combining lines
-map('n', 'n', 'nzzzv') -- when searching
-map('n', 'N', 'Nzzzv')
-map('n', '<C-d>', '<C-d>zzzv') -- half page jumping
-map('n', '<C-u>', '<C-u>zzzv')
+map("n", "<S-j>", "mzJ`z<cmd>delm z<CR>") -- when combining lines
+map("n", "n", "nzzzv") -- when searching
+map("n", "N", "Nzzzv")
+map("n", "<C-d>", "<C-d>zzzv") -- half page jumping
+map("n", "<C-u>", "<C-u>zzzv")
-map('n', '<leader>x', function() -- execute order 111
+map({ "n", "i" }, "<C-c>", "<Esc>")
+
+map("n", "<leader>x", function() -- execute order 111
local fn = vim.fn.expand("%:p")
if vim.fn.getftype(fn) == "file" then
local perm = vim.fn.getfperm(fn)
@@ -31,14 +33,14 @@ map('n', '<leader>x', function() -- execute order 111
else
vim.notify("File doesn't exist", vim.log.levels.INFO, { title = misc.appid })
end
-end, { desc = 'toggle executable flag of the file' })
+end, { desc = "toggle executable flag of the file" })
-- good spell suggestion ui
-- (stolen from https://github.com/neovim/neovim/pull/25833)
-vim.keymap.set('n', 'z=', function()
+vim.keymap.set("n", "z=", function()
local spell_on_choice = vim.schedule_wrap(function(_, idx)
- if type(idx) == 'number' then
- vim.cmd('normal! '..idx..'z=')
+ if type(idx) == "number" then
+ vim.cmd("normal! "..idx.."z=")
end
end)
@@ -46,15 +48,15 @@ vim.keymap.set('n', 'z=', function()
spell_on_choice(nil, vim.v.count)
return
end
- local cword = vim.fn.expand('<cword>')
- local prompt = 'Change '..vim.inspect(cword)..' to:'
+ local cword = vim.fn.expand("<cword>")
+ local prompt = "Change "..vim.inspect(cword).." to:"
vim.ui.select(vim.fn.spellsuggest(cword, vim.o.lines), { prompt = prompt }, spell_on_choice)
-end, { desc = 'Shows spelling suggestions' })
+end, { desc = "Shows spelling suggestions" })
-- quickfix
-map('n', '<M-j>', '<cmd>cnext<CR>')
-map('n', '<M-k>', '<cmd>cprev<CR>')
-map('n', '<M-c>', '<cmd>cclose<CR>')
+map("n", "<M-j>", "<cmd>cnext<CR>")
+map("n", "<M-k>", "<cmd>cprev<CR>")
+map("n", "<M-c>", "<cmd>cclose<CR>")
-- man pages
-map('n', '<C-k>', '<cmd>Man<CR>')
+map("n", "<C-k>", "<cmd>Man<CR>")