packer.nvim
packer.nvim copied to clipboard
gpanders/editorconfig.nvim breaks :PackerSync
nvim --version: v0.7.2git --version: 2.37.1- Operating system/version: macOS 11.6.8
- Terminal name/version: iTerm2
Steps to reproduce
- Add plugin, source config and install via
:PackerSyncor:PackerInstall. - Restart Neovim and run
:PackerSynca second time.
use 'gpanders/editorconfig.nvim'
The other Packer commands are not affected and the plugin works, Neovim throws no errors. The issue exclusively occurs when running :PackerSync. If I remove the entry from the config and delete its contents from ~/.local/share/nvim/site/pack/packer/start/, everything immediately works as expected again.
Actual behaviour
Packer breaks down and leaves an unusable environment.
Expected behaviour
Plugin gets initialized as usual.
packer files
Plugin specification file(s)
local fn = vim.fn local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) vim.cmd [[packadd packer.nvim]] endreturn require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- packer itself
use 'rstacruz/vim-closer'
use 'tpope/vim-repeat'
use 'tpope/vim-surround'
use 'gpanders/editorconfig.nvim'
use {
'arcticicestudio/nord-vim',
config = 'vim.cmd [[ colorscheme nord ]]'
}
use {
'numToStr/Comment.nvim',
config = [[require('Comment').setup()]]
}
if packer_bootstrap then
require('packer').sync()
end
end)
packer log file
[ERROR Tue Aug 9 13:32:04 2022 3.5885513100549e+14] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:822: Vim(lua):E5108: Error executing lua Vim:E220: Missing }.
stack traceback:
[C]: in function 'glob2regpat'
...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:77: in function 'glob2regpat'
...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:139: in function <...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:128>
[C]: in function 'xpcall'
...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:154: in function 'parse'
...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:168: in function 'config'
[string ":lua"]:1: in main chunk
[C]: in function 'resume'
.../site/pack/packer/start/packer.nvim/lua/packer/async.lua:12: in function <.../site/pack/packer/start/packer.nvim/lua/packer/async.lua:11>
stack traceback:
[C]: in function 'close_handlers_8_auto'
...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:154: in function 'parse'
...pack/packer/start/editorconfig.nvim/lua/editorconfig.lua:168: in function 'config'
[string ":lua"]:1: in main chunk
[C]: in function 'resume'
.../site/pack/packer/start/packer.nvim/lua/packer/async.lua:12: in function <.../site/pack/packer/start/packer.nvim/lua/packer/async.lua:11>
packer compiled file
-- 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/herrbischoff/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/herrbischoff/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/herrbischoff/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/herrbischoff/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/herrbischoff/.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 = {
["Comment.nvim"] = {
config = { "require('Comment').setup()" },
loaded = true,
path = "/Users/herrbischoff/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
["nord-vim"] = {
config = { "vim.cmd [[ colorscheme nord ]]" },
loaded = true,
path = "/Users/herrbischoff/.local/share/nvim/site/pack/packer/start/nord-vim",
url = "https://github.com/arcticicestudio/nord-vim"
},
["packer.nvim"] = {
loaded = true,
path = "/Users/herrbischoff/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["vim-closer"] = {
loaded = true,
path = "/Users/herrbischoff/.local/share/nvim/site/pack/packer/start/vim-closer",
url = "https://github.com/rstacruz/vim-closer"
},
["vim-repeat"] = {
loaded = true,
path = "/Users/herrbischoff/.local/share/nvim/site/pack/packer/start/vim-repeat",
url = "https://github.com/tpope/vim-repeat"
},
["vim-surround"] = {
loaded = true,
path = "/Users/herrbischoff/.local/share/nvim/site/pack/packer/start/vim-surround",
url = "https://github.com/tpope/vim-surround"
}
}
time([[Defining packer_plugins]], false)
-- Config for: nord-vim
time([[Config for nord-vim]], true)
vim.cmd [[ colorscheme nord ]]
time([[Config for nord-vim]], false)
-- Config for: Comment.nvim
time([[Config for Comment.nvim]], true)
require('Comment').setup()
time([[Config for Comment.nvim]], 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
From the log it looks like this is an issue with glob2regpat in gpanders/editorconfig.nvim instead of packer.
The packer report line is pointing to here (if packer is at latest).
What is your?
- .editorconfig file
- packer commit
- editorconfig.nvim commit
Do you have a full minimal reproducible example. I was not able to reproduce with this minimal_init.lua and .editorconfig files in the same directory.
minimal_init.lua
-- `minimal_init.lua` used for reproducible configuration
-- Open with `nvim --clean -u minimal_init.lua`
local is_windows = vim.fn.has 'win32' == 1
local function join(...)
local sep = is_windows and '\\' or '/'
return table.concat({ ... }, sep)
end
local root_tmp = is_windows and os.getenv 'TEMP' or '/tmp'
local site_path = join(root_tmp, 'nvim', 'site')
local pack_path = join(site_path, 'pack')
local install_path = join(pack_path, 'packer', 'start', 'packer.nvim')
local compile_path = join(install_path, 'plugin', 'packer_compiled.lua')
vim.opt.packpath = site_path
vim.g.loaded_remote_plugins = 1
local packer_bootstrap = vim.fn.isdirectory(install_path) == 0
if packer_bootstrap then
vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
local packer = require 'packer'
packer.startup {
function(use)
use 'wbthomason/packer.nvim'
use 'gpanders/editorconfig.nvim'
end,
config = {
compile_path = compile_path,
package_root = pack_path,
},
}
if packer_bootstrap then
packer.sync()
end
.editorconfig
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
tab_width = 4
trim_trailing_whitespace = true
Good to hear that it is not quite an issue with Packer itself.
.editorconfig file
[*.{css,scss,less,js,json,ts,sass,html,hbs,mustache,phtml,html.twig,md,yml}]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
indent_size = 4
trim_trailing_whitespace = false
[site/templates/**.php]
indent_size = 2
[site/snippets/**.php]
indent_size = 2
[package.json,.{babelrc,editorconfig,eslintrc,lintstagedrc,stylelintrc}]
indent_style = space
indent_size = 2
From https://github.com/getkirby/plainkit/blob/main/.editorconfig
packer commit
afab895
editorconfig.nvim commit
https://github.com/gpanders/editorconfig.nvim/commit/73786507073250cf6e32272a630f16a57687c7d8
Your comments appear to have pointed me in the right direction. Commit https://github.com/gpanders/editorconfig.nvim/commit/73786507073250cf6e32272a630f16a57687c7d8 seems relevant but does not remedy the issue I'm facing. In fact, when I remove the .editorconfig file from the working directory, :PackerSync works as expected. I should have checked that beforehand. Yesterday really wasn't my day, sorry.
As this is mostly related to the plugin itself, I will continue the issue there. However, I'm a bit worried how a misbehaving plugin can break this plugin manager's functionality. Should this issue should be closed or remain? It could serve as a reminder to possibly guard against similar breakage, if at all reasonably possible to do so.
For the time being I spotted the issue, which is of course a stupid one. The .editorconfig lines
[site/templates/**.php]
indent_size = 2
Somehow got corrupted into
[site/templates/**.{php]
indent_size = 2
Which of course is invalid and the [...] Error executing lua Vim:E220: Missing } error should have tipped me off.
My other sentiment stands, regarding the question whether such a tiny issue by itself should be allowed to break Packer's functionality. But maybe that's the plugin's responsibility, as the Vimscript-based https://github.com/editorconfig/editorconfig-vim/, for example, does not break Packer with the invalid .editorconfig file.
If compile_on_sync is enabled (default is true) sync will call compile after it has finished the update. If auto_reload_compiled is enabled (default is true), packer will reload installed plugins. Since the plugin had issues this also failed on the reload.
Thank you for the insight!