Efficiently source different plugin profiles

Hello guys.

The title of the topic is probably a bit weird so let me explain.

At work I need to use VSCode, so I would like to have a way to efficiently source the only plugins I need for my “VSCode” session, while preserving all the plugins I need for the “native” session.

Right now I’m using packer, but making it to default plugins installation to opt instead of start doesn’t seem to do the trick.

What I would like to achieve is to be able to use nvim -u .lua to load only specific plugins.

AFAIK by reading NeoVim’s doc, using opt plugins should allow me to achieve this by loading the needed plugins on demand by running vim.cmd(‘packadd ’), but this approach needs some kind of dependency solving.

Any suggestions?

I wonder if this solution fills in your needs:

  • Create this directory structure in where you want
another-nvim
|__data
|__home
     |__nvim
        |__init.lua
  • Run following commands in a new terminal
$ export XDG_DATA_HOME="/Absolute/Path/To/another-nvim/data/"
$ export XDG_CONFIG_HOME="/Absolute/Path/To/another-nvim/home/"
$ nvim

Settings above makes nvim source files from another-nvim directory so that you are able to configure your own plungins for VScode in it.

If you want to run nvim for VScode, write a function in your kind of “sh” script like this (in my case):

#  .zshrc
nvimForVSC(){
    export XDG_DATA_HOME="/Absolute/Path/To/another-nvim/data/"
    export XDG_CONFIG_HOME="/Absolute/Path/To/another-nvim/home/"
    nvim $1
}
1 Like

Thanks for your reply!
What I don’t like about this setup is that I would have duplicated plugins… but IMO it could be the easiest way to achieve that.

Thanks again anyway!

1 Like

if you are using vscode-neovim, you should just be able to check for if exists('g:vscode')