feat: Add better yank and delete for absolute lines

This commit is contained in:
Fabio Lenherr / DashieTM 2023-04-09 18:17:49 +02:00
parent 2e972accb1
commit 08b30c2616
7 changed files with 286 additions and 14 deletions

View file

@ -22,14 +22,14 @@ local term_opts = { silent = true }
-- map("n", "<ESC>", ':set norelativenumber<CR><ESC>', opts)
-- crimes against humanity, but I don't care
map("n", "j", 'h', opts)
map("n", "l", 'k', opts)
map("n", "k", 'j', opts)
map("n", ";", 'l', opts)
map("v", "j", 'h', opts)
map("v", "k", 'j', opts)
map("v", "l", 'k', opts)
map("v", ";", 'l', opts)
map("n", "j", "h", opts)
map("n", "l", "k", opts)
map("n", "k", "j", opts)
map("n", ";", "l", opts)
map("v", "j", "h", opts)
map("v", "k", "j", opts)
map("v", "l", "k", opts)
map("v", ";", "l", opts)
-- debug
map("n", "<F5>", ':lua require("dap").toggle_breakpoint()<CR>', opts)
@ -104,6 +104,23 @@ vim.keymap.set("n", "<leader>z", ":lua require('telescope').extensions.zoxide.li
-- trouble
map("n", "<C-f>", "<cmd>TroubleToggle<CR>", term_opts)
-- better yank
function Better_yank(opts)
local current_line = unpack(vim.api.nvim_win_get_cursor(0))
vim.api.nvim_command(current_line .. "," .. (opts.count - (current_line - 1)) .. "y")
end
vim.api.nvim_create_user_command("BetterYank", Better_yank, { count = 1 }) map("n", "gy", ":BetterYank<CR>", term_opts)
map("n", "<leader>y", ":BetterYank<CR>", term_opts)
-- better delete
function Better_delete(opts)
local current_line = unpack(vim.api.nvim_win_get_cursor(0))
vim.api.nvim_command(current_line .. "," .. (opts.count - (current_line - 1)) .. "d")
end
vim.api.nvim_create_user_command("BetterDelete", Better_delete, { count = 1 })
map("n", "<leader>d", ":BetterDelete<CR>", term_opts)
-- gitui
map("n", "<leader>gg", function()
Util.float_term({ "gitui" }, { cwd = Util.get_root() })

View file

@ -2,8 +2,6 @@
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
local options = {
clipboard = "",
mouse = "n",
fileencoding = "utf-8",
number = true,
showmode = true,
@ -11,7 +9,7 @@ local options = {
spelllang = "en_us",
shell = "/usr/bin/zsh",
autochdir = true,
relativenumber = true,
relativenumber = false,
scrolloff = 5,
scrolljump = 5,
}