1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

use lua func in rhs instead of callback

This commit is contained in:
jdhao 2022-10-05 22:40:57 +08:00
parent 3b39067097
commit 7a5be43600

View File

@ -85,16 +85,15 @@ keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
desc = "open init.lua", desc = "open init.lua",
}) })
keymap.set("n", "<leader>sv", "", { keymap.set("n", "<leader>sv", function()
silent = true,
desc = "reload init.lua",
callback = function()
vim.cmd([[ vim.cmd([[
update $MYVIMRC update $MYVIMRC
source $MYVIMRC source $MYVIMRC
]]) ]])
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" }) vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
end, end, {
silent = true,
desc = "reload init.lua",
}) })
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. -- 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" }) keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
-- Do not move my cursor when joining lines. -- Do not move my cursor when joining lines.
keymap.set("n", "J", "", { keymap.set("n", "J", function()
desc = "join line",
callback = function()
vim.cmd([[ vim.cmd([[
normal! mzJ`z normal! mzJ`z
delmarks z delmarks z
]]) ]])
end, end, {
desc = "join line",
}) })
keymap.set("n", "gJ", "mzgJ`z", { keymap.set("n", "gJ", function()
desc = "join visual lines",
callback = function()
-- we must use `normal!`, otherwise it will trigger recursive mapping -- we must use `normal!`, otherwise it will trigger recursive mapping
vim.cmd([[ vim.cmd([[
normal! zmgJ`z normal! zmgJ`z
delmarks z delmarks z
]]) ]])
end, end, {
desc = "join visual lines",
}) })
-- Break inserted text into smaller undo units when we insert some punctuation chars. -- Break inserted text into smaller undo units when we insert some punctuation chars.