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.88k stars 265 forks source link

Packer is throwing error on compile #289

Closed Tinku10 closed 3 years ago

Tinku10 commented 3 years ago

This started after I removed NERD tree and tried Nvim tree. When I am trying to save the plugins file with :w or do PackerCompile, it throws an error. I also tried deleted packer_compiled.vim. Still I'm getting this error.

Error in packer_compiled: Vim(lua):E5108: Error executing lua [string ":lua"]:159: Vim(command):E182: Invalid command name
Please check your config for correctness

I don't know if this is something to do with packer or with Nvim tree. Sorry for any obvious mistake I've done.

akinsho commented 3 years ago

@Tinku10 I'm not sure this is enough information for us to help. Can you share your use block for NERDTree and NvimTree. It's likely that some part of that config needs to be changed. If you comment out the tree section does this allow the compiled file to rebuild properly?

Tinku10 commented 3 years ago

@akinsho This is my tree section

use {
    'kyazdani42/nvim-tree.lua',                                                                                                                                 
    requires = {'kyazdani42/nvim-web-devicons'}
}

Actually I tried switching back to NERD tree, and it did worked. But again when I used Nvim tree, it is giving error. Sometimes when I open a file with telescope the file opens but shows a blank page as if the file is empty.

Also if you want to check my whole plugin file, here is the link to my plugin config file.

Also, if I delete my packer_compiled.vim file, this error goes away temporarily until I do a :w or :PackerCompile on the plugin file.

wbthomason commented 3 years ago

To confirm: you get no error when your packer_compiled file is deleted, but do get an error when you rebuild the file?

Can you please post your packer_compiled file? At a glance, your plugin config has nothing unusual.

Tinku10 commented 3 years ago

Actually I have again shifted back to NerdTree to see if there is any changes, but it is still there. When I manually delete the packer_compiled.vim file and run nvim . there is no error. But as soon as I try to do :w or :PackerCompile this error pops up. Once this error emerges, it comes every time I launch nvim .. Now because of this error when I am using Telescope and use the command :Telescope find_files it list all my files, but then when I click on a file it navigates me to the file but the file is shown blank. This is rather strange and I am not able to trace the root cause of this issue.

This is the packer_compiled.vim file after I changed back to NerdTree.

" Automatically generated packer.nvim plugin loader code

if !has('nvim-0.5')
  echohl WarningMsg
  echom "Invalid Neovim version for packer.nvim!"
  echohl None
  finish
endif

packadd packer.nvim

try

lua << END
local package_path_str = "/home/tinku/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/tinku/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/tinku/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/tinku/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/tinku/.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

local function try_loadstring(s, component, name)
  local success, result = pcall(loadstring(s))
  if not success then
    print('Error running ' .. component .. ' for ' .. name)
    error(result)
  end
  return result
end

_G.packer_plugins = {
  ["FTerm.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/FTerm.nvim"
  },
  ["auto-pairs"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/auto-pairs"
  },
  ["completion-nvim"] = {
    after = { "vim-vsnip-integ", "vim-vsnip" },
    loaded = false,
    needs_bufread = false,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/opt/completion-nvim"
  },
  ["galaxyline.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/galaxyline.nvim"
  },
  ["goyo.vim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/goyo.vim"
  },
  gruvbox = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/gruvbox"
  },
  ["lspkind-nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/lspkind-nvim"
  },
  neoformat = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/neoformat"
  },
  nerdtree = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/nerdtree"
  },
  ["nlua.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/nlua.nvim"
  },
  ["nvim-lspconfig"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/nvim-lspconfig"
  },
  ["nvim-treesitter"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/nvim-treesitter"
  },
  ["nvim-web-devicons"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/nvim-web-devicons"
  },
  ["packer.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/packer.nvim"
  },
  playground = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/playground"
  },
  ["plenary.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/plenary.nvim"
  },
  ["popup.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/popup.nvim"
  },
  ["telescope-fzy-native.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/telescope-fzy-native.nvim"
  },
  ["telescope.nvim"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/telescope.nvim"
  },
  undotree = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/undotree"
  },
  ["vim-colorschemes"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-colorschemes"
  },
  ["vim-commentary"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-commentary"
  },
  ["vim-fugitive"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-fugitive"
  },
  ["vim-gitgutter"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-gitgutter"
  },
  ["vim-man"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-man"
  },
  ["vim-ripgrep"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-ripgrep"
  },
  ["vim-startify"] = {
    loaded = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/start/vim-startify"
  },
  ["vim-vsnip"] = {
    load_after = {
      ["completion-nvim"] = true
    },
    loaded = false,
    needs_bufread = false,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/opt/vim-vsnip"
  },
  ["vim-vsnip-integ"] = {
    after_files = { "/home/tinku/.local/share/nvim/site/pack/packer/opt/vim-vsnip-integ/after/plugin/vsnip_integ.vim" },
    load_after = {
      ["completion-nvim"] = true
    },
    loaded = false,
    needs_bufread = false,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/opt/vim-vsnip-integ"
  },
  ["vim-which-key"] = {
    commands = { "WhichKey", "WhichKey!" },
    loaded = false,
    needs_bufread = true,
    path = "/home/tinku/.local/share/nvim/site/pack/packer/opt/vim-which-key"
  }
}

-- Command lazy-loads
vim.cmd [[command! -nargs=* -range -bang -complete=file WhichKey lua require("packer.load")({'vim-which-key'}, { cmd = "WhichKey", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]]
vim.cmd [[command! -nargs=* -range -bang -complete=file WhichKey! lua require("packer.load")({'vim-which-key'}, { cmd = "WhichKey!", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]]

END

catch
  echohl ErrorMsg
  echom "Error in packer_compiled: " .. v:exception
  echom "Please check your config for correctness"
  echohl None
endtry

Everything was working fine until I installed NvimTree. I don't know what changed suddenly and which plugin is causing the issue.

akinsho commented 3 years ago

@Tinku10 I believe the error actually isn't related to NERDTree or nvim-tree, I was able to reproduce it locally by adding a ! to one of my command keys. For your whichkey config you have specified two commands Whichkey and Whichkey! the second one with the ! is an invalid nvim command. The ! is essentially an argument to a command not part of the command itself so by specifying it like that to packer, packer thinks it has to create a command with a ! in the name which is not valid. You don't need the second Whichkey command only the first

Tinku10 commented 3 years ago

@akinsho @wbthomason thanks, it solved the issue. So sorry for wasting both of your time. Really enjoying your plugin. Do you know why sometimes during PackerInstall the screen has machine code like characters along with the installation status?

wbthomason commented 3 years ago

@akinsho Nice spot; I missed that.

@Tinku10 Can you show a screenshot of the "machine code"? The display window does use unicode status symbols - perhaps your font doesn't contain these codepoints? You can customize the symbols used here in your settings.

Tinku10 commented 3 years ago

Okay, I'll share when it pops again the next time, because it not always does. Anyways thanks. Should I close this issue?

akinsho commented 3 years ago

I think it's fine to close this, you can post a screenshot here later on regarding the other issue you are seeing if it isn't just a about missing nerd fonts then we can move to making another separate issue for that

Tinku10 commented 3 years ago

Thanks for your help, I am closing this issue now.