From 268c37e52f6ca99e248d5f1653fbffc1d1696b7d Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 26 Jul 2021 14:32:29 +0530 Subject: [PATCH 1/2] mappings: Allow moving the cursor through wrapped lines normally This doesn't affect any other stuff like 10j or 10k --- lua/mappings.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/mappings.lua b/lua/mappings.lua index 815bf4d..17848db 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -26,6 +26,14 @@ vim.api.nvim_set_keymap("t", "jk", "", {}) -- Don't copy the replaced text after pasting in visual mode map("v", "p", '"_dP', opt) +-- Allow moving the cursor through wrapped lines with j, k, and +-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ +-- empty mode is same as using :map +map("", "j", 'v:count ? "j" : "gj"', {expr = true}) +map("", "k", 'v:count ? "k" : "gk"', {expr = true}) +map("", "", 'v:count ? "j" : "gj"', {expr = true}) +map("", "", 'v:count ? "k" : "gk"', {expr = true}) + -- OPEN TERMINALS -- map("n", "", ":vnew +terminal | setlocal nobuflisted ", opt) -- term over right map("n", "", ":10new +terminal | setlocal nobuflisted ", opt) -- term bottom From 3b05354337cfb026792b5e7f548ffc7d55e5dea5 Mon Sep 17 00:00:00 2001 From: G-Rowell Date: Mon, 26 Jul 2021 15:06:32 +0530 Subject: [PATCH 2/2] Use jdhao/better-escape.vim to handle jk as escape mappings only for insert mode ( so also works on terminal too ) remove visual mode key binding, till we find a proper solution, because it is super annoying right now Original pr here: https://github.com/siduck76/NvChad/pull/160 --- lua/mappings.lua | 5 ----- lua/pluginList.lua | 10 +++++++++- lua/plugins/others.lua | 5 +++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/mappings.lua b/lua/mappings.lua index 17848db..364a021 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -18,11 +18,6 @@ map("v", "x", [=[ "_x ]=], opt) this line too ]] -- --- escape with 'jk' mapping -vim.api.nvim_set_keymap("i", "jk", "", {}) -vim.api.nvim_set_keymap("v", "jk", "", {}) -vim.api.nvim_set_keymap("t", "jk", "", {}) - -- Don't copy the replaced text after pasting in visual mode map("v", "p", '"_dP', opt) diff --git a/lua/pluginList.lua b/lua/pluginList.lua index 6d476af..b7b79d8 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -16,6 +16,14 @@ return packer.startup( event = "VimEnter" } + use { + "jdhao/better-escape.vim", + event = "InsertEnter", + config = function() + require "plugins.others".escape() + end + } + use { "akinsho/nvim-bufferline.lua", after = "nvim-base16.lua", @@ -247,7 +255,7 @@ return packer.startup( use { "tpope/vim-fugitive", cmd = { - "Git" + "Git" } } end diff --git a/lua/plugins/others.lua b/lua/plugins/others.lua index 2278d09..0a060a6 100644 --- a/lua/plugins/others.lua +++ b/lua/plugins/others.lua @@ -15,6 +15,11 @@ M.comment = function() end end +M.escape = function() + vim.g.better_escape_interval = 300 + vim.g.better_escape_shortcut = {"jk"} +end + M.lspkind = function() local present, lspkind = pcall(require, "lspkind") if present then