Skip to content

Commit

Permalink
feat(recipes): add recipe for enabling integration with VS Code
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Feb 28, 2024
1 parent 955b2f8 commit 9503f2c
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/content/docs/recipes/vscode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
id: vscode
title: VS Code Integration
---

:::tip

This is available in the [AstroCommunity](https://github.com/AstroNvim/astrocommunity/tree/v4/lua/astrocommunity/recipes/vscode)

```lua title="lua/community.lua" ins={3}
return {
"AstroNvim/astrocommunity",
{ import = "astrocommunity.recipes.vscode" },
}
```

:::

Many users may want to use the [`vscode-neovim`](https://github.com/vscode-neovim/vscode-neovim) extension in VS Code. You can easily configure AstroNvim to play nicely with this instance and disable plugins that do not interact well with VS Code when in an active VS Code instance.

## Plugin Specification

```lua title="lua/plugins/vscode.lua"
-- don't do anything in non-vscode instances
if not vim.g.vscode then
return {}
end

-- a list of known working plugins with vscode-neovim, update with your own plugins
local plugins = {
"lazy.nvim",
"AstroNvim",
"astrocore",
"astroui",
"Comment.nvim",
"nvim-autopairs",
"nvim-treesitter",
"nvim-ts-autotag",
"nvim-treesitter-textobjects",
"nvim-ts-context-commentstring",
}

local Config = require("lazy.core.config")
-- disable plugin update checking
Config.options.checker.enabled = false
Config.options.change_detection.enabled = false
-- replace the default `cond`
Config.options.defaults.cond = function(plugin)
return vim.tbl_contains(plugins, plugin.name)
end

---@type LazySpec
return {
-- add a few keybindings
{
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
mappings = {
n = {
["<Leader>ff"] = "<CMD>Find<CR>",
["<Leader>fw"] = "<CMD>call VSCodeNotify('workbench.action.findInFiles')<CR>",
["<Leader>ls"] = "<CMD>call VSCodeNotify('workbench.action.gotoSymbol')<CR>",
},
},
},
},
-- disable colorscheme setting
{ "AstroNvim/astroui", opts = { colorscheme = false } },
-- disable treesitter highlighting
{
"nvim-treesitter/nvim-treesitter",
opts = { highlight = { enable = false } },
},
}
```

0 comments on commit 9503f2c

Please sign in to comment.