From 80f78294260e39f200e5640bef88fde42b2ef4d5 Mon Sep 17 00:00:00 2001 From: XTY Date: Thu, 15 May 2025 06:04:38 +0800 Subject: [PATCH 1/2] fix(vscode): reimplement terminal integration --- lua/lazyvim/plugins/extras/vscode.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/vscode.lua b/lua/lazyvim/plugins/extras/vscode.lua index 5115a2b4..3bbd9182 100644 --- a/lua/lazyvim/plugins/extras/vscode.lua +++ b/lua/lazyvim/plugins/extras/vscode.lua @@ -23,6 +23,7 @@ local enabled = { } local Config = require("lazy.core.config") +local vscode = require("vscode") Config.options.checker.enabled = false Config.options.change_detection.enabled = false Config.options.defaults.cond = function(plugin) @@ -39,6 +40,13 @@ vim.api.nvim_create_autocmd("User", { vim.keymap.set("n", "/", [[lua require('vscode').action('workbench.action.findInFiles')]]) vim.keymap.set("n", "ss", [[lua require('vscode').action('workbench.action.gotoSymbol')]]) + -- Toggle VS Code integrated terminal + for _, lhs in ipairs({ "ft", "fT", "" }) do + vim.keymap.set("n", lhs, function() + vscode.call("workbench.action.terminal.toggleTerminal") + end) + end + -- Keep undo/redo lists in sync with VsCode vim.keymap.set("n", "u", "call VSCodeNotify('undo')") vim.keymap.set("n", "", "call VSCodeNotify('redo')") @@ -49,10 +57,6 @@ vim.api.nvim_create_autocmd("User", { end, }) -function LazyVim.terminal() - require("vscode").action("workbench.action.terminal.toggleTerminal") -end - return { { "snacks.nvim", From d6cc9d727623b0728a0d70d09eee6d7a79a6941a Mon Sep 17 00:00:00 2001 From: XTY Date: Thu, 15 May 2025 06:46:23 +0800 Subject: [PATCH 2/2] refactor(vscode): unify calls to extension API --- lua/lazyvim/plugins/extras/vscode.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lua/lazyvim/plugins/extras/vscode.lua b/lua/lazyvim/plugins/extras/vscode.lua index 3bbd9182..913ce1ca 100644 --- a/lua/lazyvim/plugins/extras/vscode.lua +++ b/lua/lazyvim/plugins/extras/vscode.lua @@ -37,8 +37,12 @@ vim.api.nvim_create_autocmd("User", { 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')]]) + vim.keymap.set("n", "/", function() + vscode.call("workbench.action.findInFiles") + end) + vim.keymap.set("n", "ss", function() + vscode.call("workbench.action.gotoSymbol") + end) -- Toggle VS Code integrated terminal for _, lhs in ipairs({ "ft", "fT", "" }) do @@ -48,12 +52,20 @@ vim.api.nvim_create_autocmd("User", { end -- Keep undo/redo lists in sync with VsCode - vim.keymap.set("n", "u", "call VSCodeNotify('undo')") - vim.keymap.set("n", "", "call VSCodeNotify('redo')") + vim.keymap.set("n", "u", function() + vscode.call("undo") + end) + vim.keymap.set("n", "", function() + vscode.call("redo") + end) -- Navigate VSCode tabs like lazyvim buffers - vim.keymap.set("n", "", "call VSCodeNotify('workbench.action.previousEditor')") - vim.keymap.set("n", "", "call VSCodeNotify('workbench.action.nextEditor')") + vim.keymap.set("n", "", function() + vscode.call("workbench.action.previousEditor") + end) + vim.keymap.set("n", "", function() + vscode.call("workbench.action.nextEditor") + end) end, })