chore(nvim): Converted normal command shortcut to Lua

This commit is contained in:
Ahmad Ansori Palembani 2024-04-17 10:54:02 +07:00
parent b9c32dfd52
commit 0261c07d0a
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 24 additions and 15 deletions

View file

@ -1,23 +1,32 @@
-- Loaded by `null.config` -- Loaded by `null.config`
local remap = function(mode, key, target, opts) local map = function(modes, key, target, opts)
vim.api.nvim_set_keymap(mode, key, target, opts or { local mt = {}
noremap = true,
silent = true, for mode in modes:gmatch"." do
}) table.insert(mt, mode)
end
vim.keymap.set(mt, key, target, opts or {
noremap = true,
silent = true,
})
end end
-- Map Ctrl+U as U so it can be used as redo -- Map Ctrl+U as U so it can be used as redo
remap("n", "<C-u>", "U") map("n", "<C-u>", "U")
-- Map U as redo -- Map U as redo
remap("n", "U", "<C-r>") map("n", "U", "<C-r>")
-- Yank and Put -- Yank and Put
remap("n", "<C-y>", '"+y') map("n", "<C-y>", '"+y')
remap("n", "<C-p>", '"+p') map("n", "<C-p>", '"+p')
remap("n", "<C-Y>", '"+y') map("n", "<C-Y>", '"+y')
remap("n", "<C-P>", '"+p') map("n", "<C-P>", '"+p')
-- Comment a line like how it is on VSC (using vim-commentary) -- Comment a line like how it is on VSC (using vim-commentary)
remap("n", "<C-/>", "gcc", { noremap = false }) map("n", "<C-/>", "gcc", { remap = true })
remap("v", "<C-/>", "gc", { noremap = false }) map("v", "<C-/>", "gc", { remap = true })
remap("i", "<C-/>", "<esc>gcc", { noremap = false }) map("i", "<C-/>", "<esc>gcc", { remap = true })
-- Normal command shortcut for VISUAL mode
map("v", ".", ":normal .<CR>")

View file

@ -37,7 +37,7 @@ set foldlevel=1
autocmd FileType python setlocal foldmethod=indent autocmd FileType python setlocal foldmethod=indent
" ----- Mapping " ----- Mapping
" Norm but in shortcut " Norm but in shortcut -- converted
vnoremap . :normal .<CR> vnoremap . :normal .<CR>
" Map ctrl + u as U -- converted " Map ctrl + u as U -- converted