wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.83k stars 266 forks source link

Installing markdown-preview in example config fails #620

Closed danjenson closed 2 years ago

danjenson commented 2 years ago

Steps to reproduce

Add line from example config in readme

 use {'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', cmd = 'MarkdownPreview'}

Actual behaviour

When calling :MarkdownPreview from a README.md: Error in packer_compiled: ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:82: Vim:E492: Not an editor command: MarkdownPreview Please check your config for correctness Press ENTER or type command to continue

Expected behaviour

A markdown preview...

packer files

Post the contents of packer_compiled.vim here

packer_compiled.lua ```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 = "/home/danj/.cache/nvim/packer_hererocks/2.0.5/share/lua/5.1/?.lua;/home/danj/.cache/nvim/packer_hererocks/2.0.5/share/lua/5.1/?/init.lua;/home/danj/.cache/nvim/packer_hererocks/2.0.5/lib/luarocks/rocks-5.1/?.lua;/home/danj/.cache/nvim/packer_hererocks/2.0.5/lib/luarocks/rocks-5.1/?/init.lua" local install_cpath_pattern = "/home/danj/.cache/nvim/packer_hererocks/2.0.5/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)) 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 = { LuaSnip = { after = { "cmp_luasnip" }, config = { "require('plugins.configs.others').luasnip()" }, load_after = { ["nvim-cmp"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/LuaSnip", wants = { "friendly-snippets" } }, ["better-escape.nvim"] = { config = { "require('plugins.configs.others').better_escape()" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/better-escape.nvim" }, ["bufferline.nvim"] = { config = { "require('plugins.configs.bufferline')" }, load_after = { ["nvim-web-devicons"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/bufferline.nvim" }, ["cheatsheet.nvim"] = { keys = { { "", "?" } }, loaded = false, needs_bufread = true, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/cheatsheet.nvim" }, ["cmp-buffer"] = { after_files = { "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp-buffer/after/plugin/cmp_buffer.lua" }, load_after = { ["cmp-nvim-lsp"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp-buffer" }, ["cmp-nvim-lsp"] = { after = { "cmp-buffer" }, after_files = { "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp/after/plugin/cmp_nvim_lsp.lua" }, load_after = { ["cmp-nvim-lua"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp" }, ["cmp-nvim-lua"] = { after = { "cmp-nvim-lsp" }, after_files = { "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lua/after/plugin/cmp_nvim_lua.lua" }, load_after = { cmp_luasnip = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lua" }, cmp_luasnip = { after = { "cmp-nvim-lua" }, after_files = { "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp_luasnip/after/plugin/cmp_luasnip.lua" }, load_after = { LuaSnip = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/cmp_luasnip" }, extensions = { loaded = true, path = "/home/danj/.local/share/nvim/site/pack/packer/start/extensions" }, ["feline.nvim"] = { config = { "require('plugins.configs.statusline')" }, load_after = { ["nvim-web-devicons"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/feline.nvim" }, ["friendly-snippets"] = { after = { "nvim-cmp" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/friendly-snippets" }, ["gitsigns.nvim"] = { config = { "require('plugins.configs.gitsigns')" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/gitsigns.nvim" }, ["indent-blankline.nvim"] = { config = { "require('plugins.configs.others').blankline()" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/indent-blankline.nvim" }, ["iron.nvim"] = { commands = { "IronRepl" }, config = { "\27LJ\1\2;\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0 custom.plugins.configs.iron\frequire\0" }, keys = { { "", "L" } }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/iron.nvim" }, ["lsp_signature.nvim"] = { config = { "require('plugins.configs.others').signature()" }, load_after = { ["nvim-lspconfig"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/lsp_signature.nvim" }, ["markdown-preview.nvim"] = { commands = { "MarkdownPreview" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/markdown-preview.nvim" }, neoformat = { commands = { "Neoformat" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/neoformat" }, ["nvim-autopairs"] = { config = { "require('plugins.configs.others').autopairs()" }, load_after = { ["nvim-cmp"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-autopairs" }, ["nvim-base16.lua"] = { after = { "nvim-web-devicons" }, config = { "\27LJ\1\0023\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\tinit\vcolors\frequire\0" }, load_after = { ["packer.nvim"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-base16.lua" }, ["nvim-cmp"] = { after = { "nvim-autopairs", "LuaSnip" }, config = { "require('plugins.configs.cmp')" }, load_after = { ["friendly-snippets"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-cmp" }, ["nvim-comment"] = { commands = { "CommentToggle" }, config = { "require('plugins.configs.others').comment()" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-comment" }, ["nvim-lspconfig"] = { after = { "lsp_signature.nvim" }, config = { "require('plugins.configs.lspconfig')" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig" }, ["nvim-tree.lua"] = { commands = { "NvimTreeToggle", "NvimTreeFocus" }, config = { "require('plugins.configs.nvimtree')" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua" }, ["nvim-treesitter"] = { config = { "require('plugins.configs.treesitter')" }, loaded = false, needs_bufread = true, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-treesitter" }, ["nvim-web-devicons"] = { after = { "bufferline.nvim", "feline.nvim" }, config = { "require('plugins.configs.icons')" }, load_after = { ["nvim-base16.lua"] = true }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons" }, ["packer.nvim"] = { after = { "nvim-base16.lua" }, loaded = false, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/packer.nvim" }, ["plenary.nvim"] = { loaded = true, path = "/home/danj/.local/share/nvim/site/pack/packer/start/plenary.nvim" }, ["popup.nvim"] = { loaded = true, path = "/home/danj/.local/share/nvim/site/pack/packer/start/popup.nvim" }, ["telescope-fzf-native.nvim"] = { loaded = true, path = "/home/danj/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim" }, ["telescope-media-files.nvim"] = { loaded = true, needs_bufread = false, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/telescope-media-files.nvim" }, ["telescope.nvim"] = { commands = { "Telescope" }, config = { "require('plugins.configs.telescope')" }, loaded = false, needs_bufread = true, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/telescope.nvim" }, ["vim-matchup"] = { after_files = { "/home/danj/.local/share/nvim/site/pack/packer/opt/vim-matchup/after/plugin/matchit.vim" }, loaded = false, needs_bufread = true, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/vim-matchup" }, vimtex = { config = { '\27LJ\1\2=\0\0\2\0\2\0\0044\0\0\0%\1\1\0>\0\2\1G\0\1\0"custom.plugins.configs.vimtex\frequire\0' }, loaded = false, needs_bufread = true, path = "/home/danj/.local/share/nvim/site/pack/packer/opt/vimtex" } } time([[Defining packer_plugins]], false) -- Setup for: telescope-media-files.nvim time([[Setup for telescope-media-files.nvim]], true) try_loadstring("\27LJ\1\2E\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\20telescope_media\18core.mappings\frequire\0", "setup", "telescope-media-files.nvim") time([[Setup for telescope-media-files.nvim]], false) time([[packadd for telescope-media-files.nvim]], true) vim.cmd [[packadd telescope-media-files.nvim]] time([[packadd for telescope-media-files.nvim]], false) -- Setup for: telescope.nvim time([[Setup for telescope.nvim]], true) try_loadstring("\27LJ\1\2?\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\14telescope\18core.mappings\frequire\0", "setup", "telescope.nvim") time([[Setup for telescope.nvim]], false) -- Setup for: nvim-tree.lua time([[Setup for nvim-tree.lua]], true) try_loadstring("\27LJ\1\2>\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\rnvimtree\18core.mappings\frequire\0", "setup", "nvim-tree.lua") time([[Setup for nvim-tree.lua]], false) -- Setup for: neoformat time([[Setup for neoformat]], true) try_loadstring("\27LJ\1\2?\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\14neoformat\18core.mappings\frequire\0", "setup", "neoformat") time([[Setup for neoformat]], false) -- Setup for: gitsigns.nvim time([[Setup for gitsigns.nvim]], true) try_loadstring("\27LJ\1\2U\0\0\2\0\4\0\a4\0\0\0%\1\1\0>\0\2\0027\0\2\0%\1\3\0>\0\2\1G\0\1\0\18gitsigns.nvim\21packer_lazy_load\15core.utils\frequire\0", "setup", "gitsigns.nvim") time([[Setup for gitsigns.nvim]], false) -- Setup for: bufferline.nvim time([[Setup for bufferline.nvim]], true) try_loadstring("\27LJ\1\2@\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\15bufferline\18core.mappings\frequire\0", "setup", "bufferline.nvim") time([[Setup for bufferline.nvim]], false) -- Setup for: vim-matchup time([[Setup for vim-matchup]], true) try_loadstring("\27LJ\1\2S\0\0\2\0\4\0\a4\0\0\0%\1\1\0>\0\2\0027\0\2\0%\1\3\0>\0\2\1G\0\1\0\16vim-matchup\21packer_lazy_load\15core.utils\frequire\0", "setup", "vim-matchup") time([[Setup for vim-matchup]], false) -- Setup for: nvim-lspconfig time([[Setup for nvim-lspconfig]], true) try_loadstring("\27LJ\1\2/\0\0\2\0\3\0\0054\0\0\0007\0\1\0%\1\2\0>\0\2\1G\0\1\0\16silent! e %\bcmd\bvimx\1\0\3\0\a\0\f4\0\0\0%\1\1\0>\0\2\0027\0\2\0%\1\3\0>\0\2\0014\0\4\0007\0\5\0001\1\6\0'\2\0\0>\0\3\1G\0\1\0\0\rdefer_fn\bvim\19nvim-lspconfig\21packer_lazy_load\15core.utils\frequire\0", "setup", "nvim-lspconfig") time([[Setup for nvim-lspconfig]], false) -- Setup for: nvim-comment time([[Setup for nvim-comment]], true) try_loadstring("\27LJ\1\2=\0\0\2\0\3\0\0064\0\0\0%\1\1\0>\0\2\0027\0\2\0>\0\1\1G\0\1\0\fcomment\18core.mappings\frequire\0", "setup", "nvim-comment") time([[Setup for nvim-comment]], false) -- Command lazy-loads time([[Defining lazy-load commands]], true) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file MarkdownPreview lua require("packer.load")({'markdown-preview.nvim'}, { cmd = "MarkdownPreview", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neoformat lua require("packer.load")({'neoformat'}, { cmd = "Neoformat", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Telescope lua require("packer.load")({'telescope.nvim'}, { cmd = "Telescope", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file NvimTreeToggle lua require("packer.load")({'nvim-tree.lua'}, { cmd = "NvimTreeToggle", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file IronRepl lua require("packer.load")({'iron.nvim'}, { cmd = "IronRepl", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file CommentToggle lua require("packer.load")({'nvim-comment'}, { cmd = "CommentToggle", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file NvimTreeFocus lua require("packer.load")({'nvim-tree.lua'}, { cmd = "NvimTreeFocus", l1 = , l2 = , bang = , args = }, _G.packer_plugins)]]) time([[Defining lazy-load commands]], false) -- Keymap lazy-loads time([[Defining lazy-load keymaps]], true) vim.cmd [[noremap ? lua require("packer.load")({'cheatsheet.nvim'}, { keys = "leader>?", prefix = "" }, _G.packer_plugins)]] vim.cmd [[noremap L lua require("packer.load")({'iron.nvim'}, { keys = "L", prefix = "" }, _G.packer_plugins)]] time([[Defining lazy-load keymaps]], false) vim.cmd [[augroup packer_load_aucmds]] vim.cmd [[au!]] -- Filetype lazy-loads time([[Defining lazy-load filetype autocommands]], true) vim.cmd [[au FileType r ++once lua require("packer.load")({'iron.nvim'}, { ft = "r" }, _G.packer_plugins)]] vim.cmd [[au FileType lua ++once lua require("packer.load")({'iron.nvim'}, { ft = "lua" }, _G.packer_plugins)]] vim.cmd [[au FileType python ++once lua require("packer.load")({'iron.nvim'}, { ft = "python" }, _G.packer_plugins)]] vim.cmd [[au FileType tex ++once lua require("packer.load")({'vimtex'}, { ft = "tex" }, _G.packer_plugins)]] time([[Defining lazy-load filetype autocommands]], false) -- Event lazy-loads time([[Defining lazy-load event autocommands]], true) vim.cmd [[au InsertEnter * ++once lua require("packer.load")({'friendly-snippets', 'better-escape.nvim'}, { event = "InsertEnter *" }, _G.packer_plugins)]] vim.cmd [[au VimEnter * ++once lua require("packer.load")({'packer.nvim'}, { event = "VimEnter *" }, _G.packer_plugins)]] vim.cmd [[au BufRead * ++once lua require("packer.load")({'nvim-treesitter', 'indent-blankline.nvim'}, { event = "BufRead *" }, _G.packer_plugins)]] time([[Defining lazy-load event autocommands]], false) vim.cmd("augroup END") vim.cmd [[augroup filetypedetect]] time([[Sourcing ftdetect script at: /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/cls.vim]], true) vim.cmd [[source /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/cls.vim]] time([[Sourcing ftdetect script at: /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/cls.vim]], false) time([[Sourcing ftdetect script at: /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/tex.vim]], true) vim.cmd [[source /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/tex.vim]] time([[Sourcing ftdetect script at: /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/tex.vim]], false) time([[Sourcing ftdetect script at: /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/tikz.vim]], true) vim.cmd [[source /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/tikz.vim]] time([[Sourcing ftdetect script at: /home/danj/.local/share/nvim/site/pack/packer/opt/vimtex/ftdetect/tikz.vim]], false) vim.cmd("augroup END") if should_profile then save_profiles() end end) if not no_errors then vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') end ```
wbthomason commented 2 years ago

Ah. This is because markdown-preview only creates its commands on BufEnter, which won't be re-triggered on lazy-loading. See https://github.com/iamcco/markdown-preview.nvim/blob/master/plugin/mkdp.vim#L119. This must've changed since I wrote that README example; it should be updated.

As a workaround, try adding a doautocmd mkdp_init BufEnter in your config key for markdown-preview.

itaysmalia commented 2 years ago

removing the cmd key worked for me if still not working, try removing the plugin, the installing it again without the cmd key

danjenson commented 2 years ago

Appears to have been fixed for me.