From 0c2c6ec90cc9f811bf0f53c9fb264f6fb885ffdd Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Fri, 1 Nov 2024 15:33:20 -0600 Subject: [PATCH] vscode neovim --- .bashrc | 1 + .config/nvim/init.lua | 7 ++- .config/nvim/lua/user/vscode_keymaps.lua | 67 ++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .config/nvim/lua/user/vscode_keymaps.lua diff --git a/.bashrc b/.bashrc index 63e7b1d..88bcd72 100644 --- a/.bashrc +++ b/.bashrc @@ -15,4 +15,5 @@ alias config='EDITOR=vim /usr/bin/git --git-dir=/home/piwalker/.cfg/ --work-tree EDITOR=nvim export PATH=$PATH:~/go/bin fastfetch +set -o vi diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 1e28f01..6965232 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -74,8 +74,11 @@ vim.keymap.set('n', '', [[+]]) vim.keymap.set('n', '', [[-]]) vim.keymap.set('n', '', [[<]]) vim.keymap.set('n', '', [[>]]) -vim.keymap.set('n', '', "Tabnext") -vim.keymap.set('n', '', "Tabprev") +if vim.g.vscode then + require "user.vscode_keymaps" +else + +end -- Other: -- :BarbarEnable - enables barbar (enabled by default) -- :BarbarDisable - very bad command, should never be used diff --git a/.config/nvim/lua/user/vscode_keymaps.lua b/.config/nvim/lua/user/vscode_keymaps.lua new file mode 100644 index 0000000..a552360 --- /dev/null +++ b/.config/nvim/lua/user/vscode_keymaps.lua @@ -0,0 +1,67 @@ +local keymap = vim.keymap.set +local opts = { noremap = true, silent = true } + +-- remap leader key +keymap("n", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- yank to system clipboard +keymap({"n", "v"}, "y", '"+y', opts) + +-- paste from system clipboard +keymap({"n", "v"}, "p", '"+p', opts) + +-- better indent handling +keymap("v", "<", "", ">gv", opts) + +-- move text up and down +keymap("v", "J", ":m .+1==", opts) +keymap("v", "K", ":m .-2==", opts) +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) + +-- paste preserves primal yanked piece +keymap("v", "p", '"_dP', opts) + +-- removes highlighting after escaping vim search +keymap("n", "", ":noh", opts) + +-- call vscode commands from neovim + +-- general keymaps +keymap({"n", "v"}, "t", "lua require('vscode').action('workbench.action.terminal.toggleTerminal')") +keymap({"n", "v"}, "b", "lua require('vscode').action('editor.debug.action.toggleBreakpoint')") +keymap({"n", "v"}, "d", "lua require('vscode').action('editor.action.showHover')") +keymap({"n", "v"}, "a", "lua require('vscode').action('editor.action.quickFix')") +keymap({"n", "v"}, "sp", "lua require('vscode').action('workbench.actions.view.problems')") +keymap({"n", "v"}, "cn", "lua require('vscode').action('notifications.clearAll')") +keymap({"n", "v"}, "ff", "lua require('vscode').action('workbench.action.quickOpen')") +keymap({"n", "v"}, "cp", "lua require('vscode').action('workbench.action.showCommands')") +keymap({"n", "v"}, "pr", "lua require('vscode').action('code-runner.run')") +keymap({"n", "v"}, "fd", "lua require('vscode').action('editor.action.formatDocument')") + +-- harpoon keymaps +keymap({"n", "v"}, "ha", "lua require('vscode').action('vscode-harpoon.addEditor')") +keymap({"n", "v"}, "ho", "lua require('vscode').action('vscode-harpoon.editorQuickPick')") +keymap({"n", "v"}, "he", "lua require('vscode').action('vscode-harpoon.editEditors')") +keymap({"n", "v"}, "h1", "lua require('vscode').action('vscode-harpoon.gotoEditor1')") +keymap({"n", "v"}, "h2", "lua require('vscode').action('vscode-harpoon.gotoEditor2')") +keymap({"n", "v"}, "h3", "lua require('vscode').action('vscode-harpoon.gotoEditor3')") +keymap({"n", "v"}, "h4", "lua require('vscode').action('vscode-harpoon.gotoEditor4')") +keymap({"n", "v"}, "h5", "lua require('vscode').action('vscode-harpoon.gotoEditor5')") +keymap({"n", "v"}, "h6", "lua require('vscode').action('vscode-harpoon.gotoEditor6')") +keymap({"n", "v"}, "h7", "lua require('vscode').action('vscode-harpoon.gotoEditor7')") +keymap({"n", "v"}, "h8", "lua require('vscode').action('vscode-harpoon.gotoEditor8')") +keymap({"n", "v"}, "h9", "lua require('vscode').action('vscode-harpoon.gotoEditor9')") + +-- project manager keymaps +keymap({"n", "v"}, "pa", "lua require('vscode').action('projectManager.saveProject')") +keymap({"n", "v"}, "po", "lua require('vscode').action('projectManager.listProjectsNewWindow')") +keymap({"n", "v"}, "pe", "lua require('vscode').action('projectManager.editProjects')") + + + +vim.keymap.set('n', '', "Tabnext") +vim.keymap.set('n', '', "Tabprev") \ No newline at end of file