aboutsummaryrefslogtreecommitdiff
path: root/core/mappings.lua
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2022-10-05 22:40:57 +0800
committerjdhao <jdhao@hotmail.com>2022-10-05 22:42:02 +0800
commit7a5be43600c37f786d97a46cb2dad615b19a8638 (patch)
tree9ffd867ef02abe3c43663f2172643213f6fa68b2 /core/mappings.lua
parent3b390670973c647bbdd45a09e9fd13d5cad8d45d (diff)
use lua func in rhs instead of callback
Diffstat (limited to 'core/mappings.lua')
-rw-r--r--core/mappings.lua33
1 files changed, 15 insertions, 18 deletions
diff --git a/core/mappings.lua b/core/mappings.lua
index e49fbba..3f5a7b7 100644
--- a/core/mappings.lua
+++ b/core/mappings.lua
@@ -85,16 +85,15 @@ keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
desc = "open init.lua",
})
-keymap.set("n", "<leader>sv", "", {
- silent = true,
- desc = "reload init.lua",
- callback = function()
- vim.cmd([[
+keymap.set("n", "<leader>sv", function()
+ vim.cmd([[
update $MYVIMRC
source $MYVIMRC
]])
- vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
- end,
+ vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
+end, {
+ silent = true,
+ desc = "reload init.lua",
})
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
@@ -173,25 +172,23 @@ keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL tex
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
-- Do not move my cursor when joining lines.
-keymap.set("n", "J", "", {
- desc = "join line",
- callback = function()
- vim.cmd([[
+keymap.set("n", "J", function()
+ vim.cmd([[
normal! mzJ`z
delmarks z
]])
- end,
+end, {
+ desc = "join line",
})
-keymap.set("n", "gJ", "mzgJ`z", {
- desc = "join visual lines",
- callback = function()
- -- we must use `normal!`, otherwise it will trigger recursive mapping
- vim.cmd([[
+keymap.set("n", "gJ", function()
+ -- we must use `normal!`, otherwise it will trigger recursive mapping
+ vim.cmd([[
normal! zmgJ`z
delmarks z
]])
- end,
+end, {
+ desc = "join visual lines",
})
-- Break inserted text into smaller undo units when we insert some punctuation chars.