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.72k stars 263 forks source link

packer.nvim: Error running config for dracula.nvim: [string "..."]:0: attempt to call a nil value #1259

Closed promitheas17j closed 8 months ago

promitheas17j commented 10 months ago

Run :checkhealth for more info

- `git --version`: 

git version 2.41.0

- Operating system/version:

EndeavourOS (6.1.45-1-lt)

- Terminal name/version:

alacritty 0.12.2 (9d9982df)

### Steps to reproduce
- Add dracula.nvim as per instructions on the github page (https://github.com/Mofiqul/dracula.nvim)
- Run PackerCompile and PackerSync
- Quit and reopen neovim
- Error appears after each PackerCompile or PackerSync, but not after PackerUpdate
- packer.nvim: Error running config for dracula.nvim: [string "..."]:0: attempt to call a nil value

### Actual behaviour
- When starting Neovim, or running any of PackerCompile or PackerSync commands, the error is displayed on the bottom.
- Theme seems to apply correctly nevertheless

### Expected behaviour
- Neovim to open without this error

### packer files

<details>
<summary>Plugin specification file(s)</summary>
packer.lua:

--astrotheme This file can be loaded by calling lua require('plugins') from your init.vim

-- Only required if you have packer configured as opt vim.cmd [[packadd packer.nvim]]

return require('packer').startup(function(use) -- Packer can manage itself use 'wbthomason/packer.nvim' --[[ use { "AstroNvim/astrotheme", config = function() require("astrotheme").setup() end, } --]] --[[ use { 'Mofiqul/dracula.nvim', config = function() require('lualine').setup() { options = { theme = 'dracula-soft' } } end, } ]]-- use { 'Mofiqul/dracula.nvim', config = function() require('lualine').setup() { options = { theme = 'dracula-soft' } } vim.cmd("luafile $HOME/.config/nvim/lua/promitheas/dracula.lua") end, } use { 'nvim-telescope/telescope.nvim', tag = '0.1.1', -- or , branch = '0.1.x', requires = { {'nvim-lua/plenary.nvim'} } } use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) use { 'VonHeikemen/lsp-zero.nvim', branch = 'v2.x', requires = { -- LSP Support {'neovim/nvim-lspconfig'}, -- Required {'williamboman/mason.nvim'}, -- Optional {'williamboman/mason-lspconfig.nvim'}, -- Optional

        -- Autocompletion
        {'hrsh7th/nvim-cmp'},     -- Required
        {'hrsh7th/cmp-nvim-lsp'}, -- Required
        {'L3MON4D3/LuaSnip'},     -- Required
    }
}
use('tpope/vim-fugitive')
use
{
    'folke/todo-comments.nvim',
    requires = {'nvim-lua/plenary.nvim'},
}
use
{
    "nvim-lualine/lualine.nvim",
    requires = {
        "nvim-tree/nvim-web-devicons",
        opts = true
    }
}

end)


dracula.lua: (default config as shown in Mofiqul/dracula.nvim github)

local dracula = require("dracula") dracula.setup({ -- customize dracula color palette colors = { bg = "#282A36", fg = "#F8F8F2", selection = "#44475A", comment = "#6272A4", red = "#FF5555", orange = "#FFB86C", yellow = "#F1FA8C", green = "#50fa7b", purple = "#BD93F9", cyan = "#8BE9FD", pink = "#FF79C6", bright_red = "#FF6E6E", bright_green = "#69FF94", bright_yellow = "#FFFFA5", bright_blue = "#D6ACFF", bright_magenta = "#FF92DF", bright_cyan = "#A4FFFF", bright_white = "#FFFFFF", menu = "#21222C", visual = "#3E4452", gutter_fg = "#4B5263", nontext = "#3B4048", white = "#ABB2BF", black = "#191A21", }, -- show the '~' characters after the end of buffers show_end_of_buffer = true, -- default false -- use transparent background transparent_bg = true, -- default false -- set custom lualine background color lualine_bg_color = "#44475a", -- default nil -- set italic comment italic_comment = true, -- default false -- overrides the default highlights with table see :h synIDattr overrides = {}, -- You can use overrides as table like this -- overrides = { -- NonText = { fg = "white" }, -- set NonText fg to white -- NvimTreeIndentMarker = { link = "NonText" }, -- link to NonText highlight -- Nothing = {} -- clear highlight of Nothing -- }, -- Or you can also use it like a function to get color from theme -- overrides = function (colors) -- return { -- NonText = { fg = colors.white }, -- set NonText fg to white of theme -- } -- end, })

Post or link your plugin specification files here, if you aren't able to provide a minimal
reproducer

</details>

<details>
<summary>packer log file</summary>
~/.cache/nvim/packer.nvim.log:

[WARN Sun 25 Jun 2023 00:50:54 EEST 14352966734009] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:682: No plugin selected! [WARN Sun 25 Jun 2023 00:50:57 EEST 14355881542790] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:682: No plugin selected! [WARN Sun 25 Jun 2023 00:51:03 EEST 14362711014037] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:812: No plugin selected! [WARN Sun 25 Jun 2023 00:51:06 EEST 14365336042762] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:812: No plugin selected! [WARN Sun 25 Jun 2023 00:51:07 EEST 14365896828719] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:812: No plugin selected! [WARN Sun 25 Jun 2023 00:51:07 EEST 14366373591743] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:812: No plugin selected! [WARN Sun 25 Jun 2023 00:51:08 EEST 14367209837486] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:682: No plugin selected! [WARN Sun 25 Jun 2023 00:51:09 EEST 14368573715129] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:812: No plugin selected! [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217315179] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 2e3034a of AstroNvim/astrotheme [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217460642] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit cd57e69 of AstroNvim/astrotheme [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217839503] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 78b54eb of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217874689] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 2aa9e9b of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217896767] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 8968a3a of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217917015] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 2fb7359 of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217934207] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit ad3805f of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:58:58 EEST 6882217950051] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 46b1ad3 of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933798948911] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 78b54eb of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933798985616] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 2aa9e9b of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933799024022] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 8968a3a of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933799043310] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 2fb7359 of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933799059836] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit ad3805f of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933799076455] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 46b1ad3 of nvim-treesitter/nvim-treesitter [WARN Wed 16 Aug 2023 10:59:50 EEST 6933799108382] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit 2e3034a of AstroNvim/astrotheme [WARN Wed 16 Aug 2023 10:59:50 EEST 6933799127980] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:612: Potential breaking change in commit cd57e69 of AstroNvim/astrotheme

Post the contents of ~/.cache/nvim/packer.nvim.log here

</details>

<details>
<summary>packer compiled file</summary>
packer_compiled.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()

_G._packer = _G._packer or {} _G._packer.inside_compile = true

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 if threshold then table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') end

_G._packer.profile_output = results end

time([[Luarocks path setup]], true) local package_path_str = "/home/turing/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/turing/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/turing/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/turing/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" local install_cpath_pattern = "/home/turing/.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 = { LuaSnip = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/LuaSnip", url = "https://github.com/L3MON4D3/LuaSnip" }, ["cmp-nvim-lsp"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, ["dracula.nvim"] = { config = { "\27LJ\2\n�\1\0\0\4\0\t\0\0146\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\0025\2\4\0005\3\3\0=\3\5\2B\0\2\0016\0\6\0009\0\a\0'\2\b\0B\0\2\1K\0\1\0:luafile $HOME/.config/nvim/lua/promitheas/dracula.lua\bcmd\bvim\foptions\1\0\0\1\0\1\ntheme\17dracula-soft\nsetup\flualine\frequire\0" }, loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/dracula.nvim", url = "https://github.com/Mofiqul/dracula.nvim" }, ["lsp-zero.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim", url = "https://github.com/VonHeikemen/lsp-zero.nvim" }, ["lualine.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/lualine.nvim", url = "https://github.com/nvim-lualine/lualine.nvim" }, ["mason-lspconfig.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", url = "https://github.com/williamboman/mason-lspconfig.nvim" }, ["mason.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/mason.nvim", url = "https://github.com/williamboman/mason.nvim" }, ["nvim-cmp"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/nvim-cmp", url = "https://github.com/hrsh7th/nvim-cmp" }, ["nvim-lspconfig"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", url = "https://github.com/neovim/nvim-lspconfig" }, ["nvim-treesitter"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/nvim-treesitter", url = "https://github.com/nvim-treesitter/nvim-treesitter" }, ["nvim-web-devicons"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", url = "https://github.com/nvim-tree/nvim-web-devicons" }, ["packer.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/packer.nvim", url = "https://github.com/wbthomason/packer.nvim" }, ["plenary.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" }, ["telescope.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" }, ["todo-comments.nvim"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/todo-comments.nvim", url = "https://github.com/folke/todo-comments.nvim" }, ["vim-fugitive"] = { loaded = true, path = "/home/turing/.local/share/nvim/site/pack/packer/start/vim-fugitive", url = "https://github.com/tpope/vim-fugitive" } }

time([[Defining packer_plugins]], false) -- Config for: dracula.nvim time([[Config for dracula.nvim]], true) try_loadstring("\27LJ\2\n�\1\0\0\4\0\t\0\0146\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\0025\2\4\0005\3\3\0=\3\5\2B\0\2\0016\0\6\0009\0\a\0'\2\b\0B\0\2\1K\0\1\0:luafile $HOME/.config/nvim/lua/promitheas/dracula.lua\bcmd\bvim\foptions\1\0\0\1\0\1\ntheme\17dracula-soft\nsetup\flualine\frequire\0", "config", "dracula.nvim") time([[Config for dracula.nvim]], false)

_G._packer.inside_compile = false if _G._packer.needs_bufread == true then vim.cmd("doautocmd BufRead") end _G._packer.needs_bufread = false

if should_profile then save_profiles() end

end)

if not no_errors then error_msg = error_msg:gsub('"', '\"') vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') end


Post the contents of `packer_compiled.vim` here

</details>
promitheas17j commented 8 months ago

Guys, try to sleep well before working on such things. Turns out I hadn't added the dracula.lua file in the right directory. Instead of in nvim/after/plugin/, I had it in the main nvim/lua/user/ directory. It's fine now.

I'm closing this now and going to go sit in the corner in shame.