mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-03-10 09:27:25 +00:00
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>
This commit is contained in:
@@ -23,6 +23,7 @@ local enabled = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local Config = require("lazy.core.config")
|
local Config = require("lazy.core.config")
|
||||||
|
local vscode = require("vscode")
|
||||||
Config.options.checker.enabled = false
|
Config.options.checker.enabled = false
|
||||||
Config.options.change_detection.enabled = false
|
Config.options.change_detection.enabled = false
|
||||||
Config.options.defaults.cond = function(plugin)
|
Config.options.defaults.cond = function(plugin)
|
||||||
@@ -36,19 +37,30 @@ vim.api.nvim_create_autocmd("User", {
|
|||||||
callback = function()
|
callback = function()
|
||||||
-- VSCode-specific keymaps for search and navigation
|
-- VSCode-specific keymaps for search and navigation
|
||||||
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
|
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
|
||||||
vim.keymap.set("n", "<leader>/", [[<cmd>lua require('vscode').action('workbench.action.findInFiles')<cr>]])
|
vim.keymap.set("n", "<leader>/", function()
|
||||||
vim.keymap.set("n", "<leader>ss", [[<cmd>lua require('vscode').action('workbench.action.gotoSymbol')<cr>]])
|
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
|
-- Navigate VSCode tabs like lazyvim buffers
|
||||||
vim.keymap.set("n", "<S-h>", "<Cmd>call VSCodeNotify('workbench.action.previousEditor')<CR>")
|
vim.keymap.set("n", "<S-h>", function()
|
||||||
vim.keymap.set("n", "<S-l>", "<Cmd>call VSCodeNotify('workbench.action.nextEditor')<CR>")
|
vscode.call("workbench.action.previousEditor")
|
||||||
|
end)
|
||||||
|
vim.keymap.set("n", "<S-l>", function()
|
||||||
|
vscode.call("workbench.action.nextEditor")
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
function LazyVim.terminal()
|
|
||||||
require("vscode").action("workbench.action.terminal.toggleTerminal")
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"snacks.nvim",
|
"snacks.nvim",
|
||||||
|
|||||||
Reference in New Issue
Block a user