From 1b2ec94b759731c67e3e1957a60fd47b2e267fe4 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 23 Aug 2021 01:10:31 +0530 Subject: [PATCH] feat: Add copy_del and copy_cut options to config --- lua/chadrc.lua | 2 ++ lua/core/mappings.lua | 16 ++++++++++------ lua/default_config.lua | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index edadb13..490598f 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -41,6 +41,8 @@ M.ui.plugin = { M.options = { clipboard = "unnamedplus", cmdheight = 1, + copy_cut = true, -- copy cut text ( x key ), visual and normal mode + copy_del = true, -- copy deleted text ( dd key ), visual and normal mode expandtab = true, hidden = true, ignorecase = true, diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 547fe60..5fb9764 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -13,12 +13,6 @@ local M = {} -- these mappings will only be called during initialization M.misc = function() local function non_config_mappings() - -- dont copy any deleted text , this is disabled by default so uncomment the below mappings if you want them - -- map("n", "dd", [=[ "_dd ]=]) - -- map("v", "dd", [=[ "_dd ]=]) - -- map("v", "x", [=[ "_x ]=]) - -- todo: this should be configurable via chadrc - -- Don't copy the replaced text after pasting in visual mode map("v", "p", '"_dP') @@ -35,6 +29,16 @@ M.misc = function() end local function optional_mappings() + -- don't yank text on cut ( x ) + if not config.options.copy_cut then + map({ "n", "v" }, "x", '"_x') + end + + -- don't yank text on delete ( dd ) + if not config.options.copy_del then + map({ "n", "v" }, "dd", '"_dd') + end + -- navigation within insert mode if config.options.insert_nav then local inav = maps.insert_nav diff --git a/lua/default_config.lua b/lua/default_config.lua index 080254c..7f6e355 100644 --- a/lua/default_config.lua +++ b/lua/default_config.lua @@ -45,6 +45,8 @@ M.ui.plugin = { M.options = { clipboard = "unnamedplus", cmdheight = 1, + copy_cut = true, -- copy cut text ( x key ), visual and normal mode + copy_del = true, -- copy deleted text ( dd key ), visual and normal mode expandtab = true, hidden = true, ignorecase = true,