packer.nvim icon indicating copy to clipboard operation
packer.nvim copied to clipboard

how to disable autoload packer_compiled.lua on vscode neovim

Open scc02 opened this issue 3 years ago • 9 comments

Describe the feature

disable load packer_compiled.lua on vscode when useing Vscode-Neovim

scc02 avatar Jun 12 '22 03:06 scc02

I have the same problem with neovim-vscode

JuanZoran avatar Dec 13 '22 16:12 JuanZoran

not sure how vscode-neovim works internally but couldn't this be changed by changing the compile_path?

max397574 avatar Dec 13 '22 17:12 max397574

Instead of having packer compile to a plugin folder using the lua folder so it can be required manually.

local packer = require("packer")
packer.init({ compile_path = vim.fn.stdpath("data") .. "/lua/packer_compiled.lua"  })

At the end of your init file

if not vim.g.vscode then
  require("packer_compiled")
end

EdenEast avatar Dec 13 '22 18:12 EdenEast

I found that you can do this to fix these problems:

  • change the default Packer compiled file path: example:
packer.init({
    display = {
        open_fn = function()
            return require("packer.util").float({ border = "rounded" })
        end,
    },
    compile_path = vim.fn.stdpath('config') .. '/lua/plugins/' .. 'packer_compiled.lua',

    profile = {
        enable = true,
        threshold = 0, -- the amount in ms that a plugins load time must be over for it to be included in the profile
    },
})

this is my config for packer.init()

  • require the packer compiled file in somewhere you want:

I just require it in my lua/plugins/init.lua

require('plugins.packer_compiled')

then it works well.... hope this can help someone

JuanZoran avatar Dec 15 '22 13:12 JuanZoran

@JuanZoran can you confirm if my understanding is correct. This is what I have currently:

require('packer').startup(function(use)
  -- Package manager
  use 'wbthomason/packer.nvim'

  -- rest of the plugins go here --

I should change this to:

packer = require('packer')
packer.init({
    compile_path = vim.fn.stdpath('config') .. '/lua/plugins/' .. 'packer_compiled.lua',
})

How do I specify the plugins? If possible, could you please point me to a complete solution?

kshenoy avatar Dec 23 '22 15:12 kshenoy

What you should do is just set up the packer, if you don't mind. then you load your plugin like this:

packer = require('packer')    
packer.init(    -- this function like a configure function
-- todo set up packer
)
-- load your plugins here
local use = require('packer').use   
-- then use some plugin you like 

I hope this can help you understand what is packer doing

JuanZoran avatar Dec 24 '22 01:12 JuanZoran

@JuanZoran thanks for the explanation; that worked!

kshenoy avatar Dec 28 '22 15:12 kshenoy

Another solution for disabling plugins in vscode-neovim is to use the cond attribute for plugins and passing a function that checks for g.vscode.

However, today lazyvim with the vscode spec is the best solution.

theol0403 avatar Jul 05 '23 20:07 theol0403

Another solution for disabling plugins in vscode-neovim is to use the cond attribute for plugins and passing a function that checks for g.vscode.

However, today lazyvim with the vscode spec is the best solution.

For packer and using cond you can follow an example as described here.

muelthom avatar Jul 07 '23 12:07 muelthom