From 9ad1c49b67a5c4330e366cde41ab11b156de03f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?deniz=20g=C3=B6k=C3=A7in?= <33603535+dgokcin@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:13:01 +0100 Subject: [PATCH] feat(vscode): add vscode-specific keymaps and sync undo/redo with vscode (#4983) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This pull request introduces several new keymaps specifically for VSCode when using LazyVim. These changes aim to enhance the integration between VSCode and LazyVim by adding keymaps for, tab navigation, and syncing nvim undo/redo actions with vscode undo/redo. ## Changes - Synced undo/redo lists with VSCode using `VSCodeNotify`: (check https://github.com/vscode-neovim/vscode-neovim/issues/1139 for more details) - `u` for undo - `` for redo - Enabled navigation of VSCode tabs similar to LazyVim buffers: - `` to go to the previous editor - `` to go to the next editor ## Additional Notes These changes are intended to improve the user experience for those who use LazyVim within VSCode by providing more intuitive and consistent keybindings. Please test these keymaps to ensure they work as expected in your VSCode setup. Co-authored-by: Deniz Gökçin --- lua/lazyvim/plugins/extras/vscode.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/extras/vscode.lua b/lua/lazyvim/plugins/extras/vscode.lua index e941d91c..e32069c7 100644 --- a/lua/lazyvim/plugins/extras/vscode.lua +++ b/lua/lazyvim/plugins/extras/vscode.lua @@ -33,9 +33,18 @@ end vim.api.nvim_create_autocmd("User", { pattern = "LazyVimKeymapsDefaults", callback = function() + -- VSCode-specific keymaps for search and navigation vim.keymap.set("n", "", "Find") vim.keymap.set("n", "/", [[lua require('vscode').action('workbench.action.findInFiles')]]) vim.keymap.set("n", "ss", [[lua require('vscode').action('workbench.action.gotoSymbol')]]) + + -- Keep undo/redo lists in sync with VsCode + vim.keymap.set("n", "u", "call VSCodeNotify('undo')") + vim.keymap.set("n", "", "call VSCodeNotify('redo')") + + -- Navigate VSCode tabs like lazyvim buffers + vim.keymap.set("n", "", "call VSCodeNotify('workbench.action.previousEditor')") + vim.keymap.set("n", "", "call VSCodeNotify('workbench.action.nextEditor')") end, })