Files
LazyVim-mirror/lua/lazyvim/plugins/extras/vscode.lua
XTY 0dc41dfe9a refactor(vscode): reimplement terminal integration and unify calls to extension API (#6076)
## Description

This PR proposes the following changes to the VS Code extra:
- Re-implement the VS Code terminal integration (broken since
[`2f46974`](2f4697443c (diff-f878104b5415a79ed4bb9036974722cad911327fdd46994e04f5065ff90e9a55)),
see comment referenced below)
- Unify calls to the [extension
API](https://github.com/vscode-neovim/vscode-neovim/tree/v1.18.21?tab=readme-ov-file#%EF%B8%8F-api)
- Fully adopt the Lua API in favour of the deprecated Vim script
functions (see [deprecation
notice](https://github.com/vscode-neovim/vscode-neovim/tree/v1.18.21?tab=readme-ov-file#vimscript))
  - Centralise `require("vscode")` calls

## Related Issue(s)

- Fixes
https://github.com/LazyVim/LazyVim/pull/4392#issuecomment-2881395017

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-20 07:36:15 +02:00

93 lines
2.3 KiB
Lua

if not vim.g.vscode then
return {}
end
local enabled = {
"LazyVim",
"dial.nvim",
"flit.nvim",
"lazy.nvim",
"leap.nvim",
"mini.ai",
"mini.comment",
"mini.move",
"mini.pairs",
"mini.surround",
"nvim-treesitter",
"nvim-treesitter-textobjects",
"nvim-ts-context-commentstring",
"snacks.nvim",
"ts-comments.nvim",
"vim-repeat",
"yanky.nvim",
}
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)
return vim.tbl_contains(enabled, plugin.name) or plugin.vscode
end
vim.g.snacks_animate = false
-- Add some vscode specific keymaps
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimKeymapsDefaults",
callback = function()
-- VSCode-specific keymaps for search and navigation
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
vim.keymap.set("n", "<leader>/", function()
vscode.call("workbench.action.findInFiles")
end)
vim.keymap.set("n", "<leader>ss", function()
vscode.call("workbench.action.gotoSymbol")
end)
-- Toggle VS Code integrated terminal
for _, lhs in ipairs({ "<leader>ft", "<leader>fT", "<c-/>" }) do
vim.keymap.set("n", lhs, function()
vscode.call("workbench.action.terminal.toggleTerminal")
end)
end
-- Navigate VSCode tabs like lazyvim buffers
vim.keymap.set("n", "<S-h>", function()
vscode.call("workbench.action.previousEditor")
end)
vim.keymap.set("n", "<S-l>", function()
vscode.call("workbench.action.nextEditor")
end)
end,
})
return {
{
"snacks.nvim",
opts = {
bigfile = { enabled = false },
dashboard = { enabled = false },
indent = { enabled = false },
input = { enabled = false },
notifier = { enabled = false },
picker = { enabled = false },
quickfile = { enabled = false },
scroll = { enabled = false },
statuscolumn = { enabled = false },
},
},
{
"LazyVim/LazyVim",
config = function(_, opts)
opts = opts or {}
-- disable the colorscheme
opts.colorscheme = function() end
require("lazyvim").setup(opts)
end,
},
{
"nvim-treesitter/nvim-treesitter",
opts = { highlight = { enable = false } },
},
}