Skip to content

Issues loading nvim plugins conditionally when using VSCode #2

@kshenoy

Description

@kshenoy

I use vscode-neovim which uses neovim as a backend so it uses the regular nvim config as well. However, I don't want some plugins (eg. the catppuccin colorscheme) to be loaded when running VSCode. I'm using packer for plugin management so I use the cond attribute to load them conditionally eg. here:

cond = 'vim.fn.empty(vim.g.vscode) == 1',

This works well when a plugin is stand-alone and has no dependencies. However, when a plugin has dependencies it gets trickier. Dependencies are specified using the requires attribute eg. telescope depends on plenary.nvim so specifying it in the requires block of Telescope automatically installs it when Telescope is installed without requiring a separate use spec. However, while Telescope itself has a cond attribute which loads it only when running neovim, since plenary doesn't have its own use spec, there's nothing which makes it load conditionally and thus it gets loaded even when running VSCode. Plenary itself is benign and it wouldn't be too bad to let it load even when running VSCode. However, other plugins eg. lsp, cmp etc. have dependencies which throw errors when running VSCode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions