From eed2d2684245835e513fa0fd5410871707580984 Mon Sep 17 00:00:00 2001 From: sadan <117494111+sadan4@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:25:50 -0500 Subject: [PATCH] add vscode split maps and home + end on home row --- lua/generateVscodeJson.mjs | 15 ++++++++ lua/keymap.lua | 6 +++ lua/vscSetup.lua | 79 +++++++++++++++++++++++++++++++++----- 3 files changed, 91 insertions(+), 9 deletions(-) create mode 100755 lua/generateVscodeJson.mjs diff --git a/lua/generateVscodeJson.mjs b/lua/generateVscodeJson.mjs new file mode 100755 index 0000000..725b27b --- /dev/null +++ b/lua/generateVscodeJson.mjs @@ -0,0 +1,15 @@ +#!/usr/bin/env node +const keys = "lkjhcq34erpo095\\fud"; + +/** + * @param key {string} +*/ +const makeKeymapping = (key) => { + return { + key: `ctrl+shift+alt+${key.toLowerCase()}`, + command: "vscode-neovim.send", + when: "editorTextFocus && neovim.mode !== insert", + args: `` + } +} +console.log(JSON.stringify(keys.split("").map(makeKeymapping))) diff --git a/lua/keymap.lua b/lua/keymap.lua index baac403..d5f6998 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -4,6 +4,12 @@ vim.g.mapleader = " " vim.keymap.set("n", "", ""); vim.keymap.set("n", "", ""); +-- is mapped to hover +-- unmap +vim.keymap.set({"v", "n"}, "J", "") +-- use for home and for end +vim.keymap.set({"n", "v", "o"}, "H", "g^") +vim.keymap.set({"n", "v", "o"}, "L", "g_") -- find Files vim.keymap.set("n", "f", tb.find_files, {}) -- find Text diff --git a/lua/vscSetup.lua b/lua/vscSetup.lua index f79966b..fdc688e 100644 --- a/lua/vscSetup.lua +++ b/lua/vscSetup.lua @@ -19,13 +19,13 @@ end) vim.keymap.set("n", "`", function() vsc.action("workbench.action.terminal.toggleTerminal") end) -vim.keymap.set("v", "se", function () - vsc.action("editor.emmet.action.wrapWithAbbreviation") +vim.keymap.set("v", "se", function() + vsc.action("editor.emmet.action.wrapWithAbbreviation") end) -vim.keymap.set("n", "lg", function () - vsc.action("lazygit.openLazygit") +vim.keymap.set("n", "lg", function() + vsc.action("lazygit.openLazygit") end) -vim.keymap.set({"n", "i", "v"}, "", "echoe \"Use Caps\"") +vim.keymap.set({ "n", "i", "v" }, "", 'echoe "Use Caps"') -- for some reason, this plugin does not work with keymaps that start with -- they are done through vsc -- @@ -39,12 +39,12 @@ vim.keymap.set({"n", "i", "v"}, "", "echoe \"Use Caps\"") -- vsc.action("workbench.action.quickTextSearch") -- end) vim.keymap.set("n", "e", function() - -- print((":e " .. string.gsub(vim.fn.expand("%"), '(.*/)(.*)', '%1'))); + -- print((":e " .. string.gsub(vim.fn.expand("%"), '(.*/)(.*)', '%1'))); vim.api.nvim_feedkeys((":e " .. string.gsub(vim.fn.expand("%"), "(.*/)(.*)", "%1")), "L", false) end) -vim.keymap.set("n", "c", ":let @+=@\"") -vim.keymap.set("n", "z", function () - vsc.action("workbench.action.toggleZenMode") +vim.keymap.set("n", "c", ':let @+=@"') +vim.keymap.set("n", "z", function() + vsc.action("workbench.action.toggleZenMode") end) vim.keymap.set("v", "h", ":S/", { noremap = true, @@ -52,3 +52,64 @@ vim.keymap.set("v", "h", ":S/", { vim.keymap.set("n", "h", ":%S/", { noremap = true, }) +-- unmap +vim.keymap.set({ "v", "n" }, "J", "") +-- use for home and for end +vim.keymap.set({ "n", "v", "o" }, "H", "g^") +vim.keymap.set({ "n", "v", "o" }, "L", "g_") +-- make #, closer to the cursor, fw search and * bw +vim.keymap.set("n", "#", "*", { + noremap = true, +}) +vim.keymap.set("n", "*", "#", { + noremap = true, +}) +local function stupid(mode, lhs, rhs, args) + vim.keymap.set(mode, lhs, function() + vsc.action("vscode-neovim.send", { + args = { + rhs, + }, + }) + end, args) +end +-- moving bewteen splits +vim.cmd("nmap l") +vim.cmd("nmap k") +vim.cmd("nmap j") +vim.cmd("nmap h") +-- close +vim.cmd("nmap c") +-- quit +vim.cmd("nmap q") +-- resizing +-- 3 lower width, 4 increace width +vim.cmd("nmap <") +vim.cmd("nmap >") +-- e lower height, r increase height +vim.cmd("nmap >") +vim.cmd("nmap >") + +-- movement: +-- o move left, p move right +vim.cmd("nmap L") +vim.cmd("nmap H") + +-- 9 move down, 0 move up +vim.cmd("nmap K") +vim.cmd("nmap J") +-- ./init.lua +vim.cmd("nmap v") +vim.cmd("nmap s") +vim.cmd("imap v") +vim.cmd("imap s") +-- go to file under cursor +vim.cmd("nmap F") +-- only +-- makes more sense to use O for moving splits +vim.cmd("nmap ") +-- open Definition in split view +vim.cmd("nmap }") +-- move over folds +vim.cmd("nmap j gj") +vim.cmd("nmap k gk")