Open ifplusor opened 2 years ago
I remember that the after
argument should receive a table of tables rather than a table of strings.
By the way, I find that manage two runtimes in packer is way more complicated.
Sometimes the logical connections between different specification is unclear (i.e when there are multiple lazy-loading arguments, especially cond + event, cond + after, etc) it is really a mess to know what on earth will be the event to trigger the plugins to be loaded.
I am thinking about doing it in another way: let compile_path being not in plugin/folder, so it will be not automatically sourced, and put it into another directory and require it in init.lua. And write another config for vscode and generate another compiled file and require it depending on the condition.
In README, after
argument receive a string or a list of table.
IMO, check required plugins is easy before loading specific plugin.
Here's my workaround, if anybody needs it:
local lsp_setup = function()
local required_plugins = { "nvim-lsp-installer", "nvim-lspconfig", }
for _, name in ipairs(required_plugins) do
local plugin = _G.packer_plugins[name]
if plugin == nil or not plugin.loaded then
return
end
end
require("nvim-lsp-installer").setup {}
local lspconfig = require("lspconfig")
-- ...
end
use {
"williamboman/nvim-lsp-installer",
cond = is_nvim,
config = lsp_setup,
}
use {
"neovim/nvim-lspconfig",
cond = is_nvim,
config = lsp_setup,
}
nvim --version
:Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.6.1/share/nvim"
Run :checkhealth for more info
Actual behaviour
load
null-ls.nvim
afternvim-lsp-installer
, loadnvim-lspconfig
afternull-ls.nvim
.Expected behaviour
load
nvim-lspconfig
beforenull-ls.nvim
, loadnull-ls.nvim
beforenvim-lsp-installer
.packer files
Plugin specification file(s)
```lua use({ "neovim/nvim-lspconfig", event = { "VimEnter", "BufWinEnter", "BufRead", "BufNewFile", }, cond = not_run_in_vscode, }) use({ "jose-elias-alvarez/null-ls.nvim", after = "nvim-lspconfig", requires = { "nvim-lua/plenary.nvim" }, config = function() require("plugins.programming.null-ls").setup() end, cond = not_run_in_vscode, }) use({ "williamboman/nvim-lsp-installer", after = { "nvim-lspconfig", "null-ls.nvim", "cmp-nvim-lsp" }, requires = { "neovim/nvim-lspconfig", { "hrsh7th/cmp-nvim-lsp", opt = true } }, config = function() require("plugins.programming.nvim-lsp-installer").setup() end, cond = not_run_in_vscode, }) ```packer compiled file
```lua -- Automatically generated packer.nvim plugin loader code if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') return end vim.api.nvim_command('packadd packer.nvim') local no_errors, error_msg = pcall(function() local time local profile_info local should_profile = false if should_profile then local hrtime = vim.loop.hrtime profile_info = {} time = function(chunk, start) if start then profile_info[chunk] = hrtime() else profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 end end else time = function(chunk, start) end end local function save_profiles(threshold) local sorted_times = {} for chunk_name, time_taken in pairs(profile_info) do sorted_times[#sorted_times + 1] = {chunk_name, time_taken} end table.sort(sorted_times, function(a, b) return a[2] > b[2] end) local results = {} for i, elem in ipairs(sorted_times) do if not threshold or threshold and elem[2] > threshold then results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' end end _G._packer = _G._packer or {} _G._packer.profile_output = results end time([[Luarocks path setup]], true) local package_path_str = "/Users/james/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/james/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/james/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/james/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" local install_cpath_pattern = "/Users/james/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" if not string.find(package.path, package_path_str, 1, true) then package.path = package.path .. ';' .. package_path_str end if not string.find(package.cpath, install_cpath_pattern, 1, true) then package.cpath = package.cpath .. ';' .. install_cpath_pattern end time([[Luarocks path setup]], false) time([[try_loadstring definition]], true) local function try_loadstring(s, component, name) local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) if not success then vim.schedule(function() vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) end) end return result end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { ["AutoSave.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nD\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\27plugins.tools.autosave\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/AutoSave.nvim", url = "https://github.com/Pocco81/AutoSave.nvim" }, LuaSnip = { after = { "nvim-cmp" }, cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nI\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup plugins.programming.luasnip\frequire\0" }, loaded = false, needs_bufread = true, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/LuaSnip", url = "https://github.com/L3MON4D3/LuaSnip" }, ["bufferline.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nC\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\26plugins.ui.bufferline\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/bufferline.nvim", url = "https://github.com/akinsho/bufferline.nvim" }, ["cmp-buffer"] = { after_files = { "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-buffer/after/plugin/cmp_buffer.lua" }, loaded = false, needs_bufread = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-buffer", url = "https://github.com/hrsh7th/cmp-buffer" }, ["cmp-cmdline"] = { after_files = { "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-cmdline/after/plugin/cmp_cmdline.lua" }, loaded = false, needs_bufread = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-cmdline", url = "https://github.com/hrsh7th/cmp-cmdline" }, ["cmp-nvim-lsp"] = { after = { "nvim-lsp-installer" }, after_files = { "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp/after/plugin/cmp_nvim_lsp.lua" }, cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, ["cmp-path"] = { after_files = { "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-path/after/plugin/cmp_path.lua" }, loaded = false, needs_bufread = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp-path", url = "https://github.com/hrsh7th/cmp-path" }, cmp_luasnip = { after_files = { "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp_luasnip/after/plugin/cmp_luasnip.lua" }, loaded = false, needs_bufread = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/cmp_luasnip", url = "https://github.com/saadparwaiz1/cmp_luasnip" }, ["gitsigns.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nE\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\28plugins.editor.gitsigns\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/gitsigns.nvim", url = "https://github.com/lewis6991/gitsigns.nvim" }, ["indent-blankline.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nM\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup$plugins.editor.indent-blankline\frequire\0" }, loaded = false, needs_bufread = false, only_cond = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/indent-blankline.nvim", url = "https://github.com/lukas-reineke/indent-blankline.nvim" }, ["litee.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25plugins.ui.litee.lib\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/litee.nvim", url = "https://github.com/ldelossa/litee.nvim" }, ["lsp_signature.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nO\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup&plugins.programming.lsp_signature\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/lsp_signature.nvim", url = "https://github.com/ray-x/lsp_signature.nvim" }, ["lspkind-nvim"] = { loaded = true, path = "/Users/james/.local/share/nvim/site/pack/packer/start/lspkind-nvim", url = "https://github.com/onsails/lspkind-nvim" }, ["lualine.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\23plugins.ui.lualine\frequire\0" }, loaded = false, needs_bufread = false, only_cond = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/lualine.nvim", url = "https://github.com/nvim-lualine/lualine.nvim" }, ["null-ls.nvim"] = { after = { "nvim-lsp-installer" }, cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nI\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup plugins.programming.null-ls\frequire\0" }, load_after = { ["nvim-lspconfig"] = true }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/null-ls.nvim", url = "https://github.com/jose-elias-alvarez/null-ls.nvim" }, ["nvim-base16"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nD\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\27plugins.ui.nvim-base16\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-base16", url = "https://github.com/RRethy/nvim-base16" }, ["nvim-cmp"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nJ\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup!plugins.programming.nvim-cmp\frequire\0" }, load_after = { LuaSnip = true }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-cmp", url = "https://github.com/hrsh7th/nvim-cmp" }, ["nvim-comment"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nN\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup%plugins.programming.nvim-comment\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-comment", url = "https://github.com/terrortylor/nvim-comment" }, ["nvim-lsp-installer"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nT\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup+plugins.programming.nvim-lsp-installer\frequire\0" }, load_after = { ["cmp-nvim-lsp"] = true, ["null-ls.nvim"] = true, ["nvim-lspconfig"] = true }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-lsp-installer", url = "https://github.com/williamboman/nvim-lsp-installer" }, ["nvim-lspconfig"] = { after = { "nvim-lsp-installer", "null-ls.nvim" }, cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, loaded = false, needs_bufread = false, only_cond = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig", url = "https://github.com/neovim/nvim-lspconfig" }, ["nvim-tree.lua"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25plugins.ui.nvim-tree\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua", url = "https://github.com/kyazdani42/nvim-tree.lua" }, ["nvim-treesitter"] = { after = { "nvim-treesitter-textobjects", "playground" }, commands = { "TSInstall", "TSInstallSync", "TSBufEnable", "TSBufToggle", "TSEnableAll", "TSInstallFromGrammer", "TSToggleAll", "TSUpdate", "TSUpdateSync" }, cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nQ\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup(plugins.programming.nvim-treesitter\frequire\0" }, loaded = false, needs_bufread = true, only_cond = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-treesitter", url = "https://github.com/nvim-treesitter/nvim-treesitter" }, ["nvim-treesitter-textobjects"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, load_after = { ["nvim-treesitter"] = true }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-textobjects", url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" }, ["nvim-web-devicons"] = { loaded = false, needs_bufread = false, only_cond = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons", url = "https://github.com/kyazdani42/nvim-web-devicons" }, ["packer.nvim"] = { loaded = false, needs_bufread = false, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/packer.nvim", url = "https://github.com/wbthomason/packer.nvim" }, playground = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, load_after = { ["nvim-treesitter"] = true }, loaded = false, needs_bufread = true, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/playground", url = "https://github.com/nvim-treesitter/playground" }, ["plenary.nvim"] = { loaded = true, path = "/Users/james/.local/share/nvim/site/pack/packer/start/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" }, ["project.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\n>\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\17project_nvim\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/project.nvim", url = "https://github.com/ahmedkhalf/project.nvim" }, ["stabilize.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nF\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\29plugins.editor.stabilize\frequire\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/stabilize.nvim", url = "https://github.com/luukvbaal/stabilize.nvim" }, ["telescope-fzf-native.nvim"] = { cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, loaded = false, needs_bufread = false, only_cond = true, path = "/Users/james/.local/share/nvim/site/pack/packer/opt/telescope-fzf-native.nvim", url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" }, ["telescope.nvim"] = { commands = { "Telescope" }, cond = { "\27LJ\2\n(\0\0\1\0\3\0\0056\0\0\0009\0\1\0009\0\2\0\19\0\0\0L\0\2\0\vvscode\6g\bvim\0" }, config = { "\27LJ\2\nE\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\28plugins.tools.telescope\frequire\0" }, keys = { { "", "