I get the following error when opening Neovim with the most recent version of nvim-treesitter installed.
Error detected while processing /home/locke/.config/nvim/plugin/packer_compiled.vim:
line 147:
E5108: Error executing lua [string ":lua"]:134: bad argument #1 to 'loadstring' (function expected, got boolean)
Output of nvim --version
NVIM v0.5.0-dev+957-gabcbc5a9f
-- Check if the packer tool exists
local packer_exists = pcall(vim.cmd, [[packadd packer.nvim]])
if not packer_exists then
if vim.fn.input("Download Packer? (y for yes)") ~= "y" then
return
end
local directory = string.format(
'%s/pack/packer/opt/',
vim.fn.stdpath('config')
)
vim.fn.mkdir(directory, 'p')
local out = vim.fn.system(string.format(
'git clone %s %s',
'https://github.com/wbthomason/packer.nvim',
directory .. '/packer.nvim'
))
print(out)
print("Downloading packer.nvim...")
return
end
vim.cmd [[autocmd BufWritePost init.lua PackerCompile]]
return require('packer').startup(function()
-- ##################################################
-- #################---GENERAL---####################
-- ##################################################
use { 'wbthomason/packer.nvim', opt = true }
use {
'nvim-treesitter/nvim-treesitter',
config = require('plugins.treesitter_config'),
run = ':TSUpdate'
}
end)
" 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
lua << END
local plugins = {
["packer.nvim"] = {
loaded = false,
only_sequence = false,
only_setup = false,
path = "/home/locke/.local/share/nvim/site/pack/packer/opt/packer.nvim"
}
}
local function handle_bufread(names)
for _, name in ipairs(names) do
local path = plugins[name].path
for _, dir in ipairs({ 'ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin' }) do
if #vim.fn.finddir(dir, path) > 0 then
vim.cmd('doautocmd BufRead')
return
end
end
end
end
_packer_load = nil
local function handle_after(name, before)
local plugin = plugins[name]
plugin.load_after[before] = nil
if next(plugin.load_after) == nil then
_packer_load({name}, {})
end
end
_packer_load = function(names, cause)
local some_unloaded = false
for _, name in ipairs(names) do
if not plugins[name].loaded then
some_unloaded = true
break
end
end
if not some_unloaded then return end
local fmt = string.format
local del_cmds = {}
local del_maps = {}
for _, name in ipairs(names) do
if plugins[name].commands then
for _, cmd in ipairs(plugins[name].commands) do
del_cmds[cmd] = true
end
end
if plugins[name].keys then
for _, key in ipairs(plugins[name].keys) do
del_maps[key] = true
end
end
end
for cmd, _ in pairs(del_cmds) do
vim.cmd('silent! delcommand ' .. cmd)
end
for key, _ in pairs(del_maps) do
vim.cmd(fmt('silent! %sunmap %s', key[1], key[2]))
end
for _, name in ipairs(names) do
if not plugins[name].loaded then
vim.cmd('packadd ' .. name)
if plugins[name].config then
for _i, config_line in ipairs(plugins[name].config) do
loadstring(config_line)()
end
end
if plugins[name].after then
for _, after_name in ipairs(plugins[name].after) do
handle_after(after_name, name)
vim.cmd('redraw')
end
end
plugins[name].loaded = true
end
end
handle_bufread(names)
if cause.cmd then
local lines = cause.l1 == cause.l2 and '' or (cause.l1 .. ',' .. cause.l2)
vim.cmd(fmt('%s%s%s %s', lines, cause.cmd, cause.bang, cause.args))
elseif cause.keys then
local keys = cause.keys
local extra = ''
while true do
local c = vim.fn.getchar(0)
if c == 0 then break end
extra = extra .. vim.fn.nr2char(c)
end
if cause.prefix then
local prefix = vim.v.count and vim.v.count or ''
prefix = prefix .. '"' .. vim.v.register .. cause.prefix
if vim.fn.mode('full') == 'no' then
if vim.v.operator == 'c' then
prefix = '' .. prefix
end
prefix = prefix .. vim.v.operator
end
vim.fn.feedkeys(prefix, 'n')
end
-- NOTE: I'm not sure if the below substitution is correct; it might correspond to the literal
-- characters \<Plug> rather than the special <Plug> key.
vim.fn.feedkeys(string.gsub(string.gsub(cause.keys, '^<Plug>', '\\<Plug>') .. extra, '<[cC][rR]>', '\r'))
elseif cause.event then
vim.cmd(fmt('doautocmd <nomodeline> %s', cause.event))
elseif cause.ft then
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeplugin', cause.ft))
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeindent', cause.ft))
end
end
-- Runtimepath customization
-- Pre-load configuration
-- Post-load configuration
-- Config for: nvim-treesitter
loadstring("\27LJ\2\nĀ\3\0\0\5\0\16\0\0266\0\0\0'\2\1\0B\0\2\0029\1\2\0005\3\4\0005\4\3\0=\4\5\0035\4\6\0=\4\a\3B\1\2\0016\1\0\0'\3\b\0B\1\2\0016\1\t\0009\1\n\0019\1\v\0019\1\f\1'\2\14\0=\2\r\0016\1\t\0009\1\n\0019\1\v\0019\1\f\1+\2\0\0=\2\15\1K\0\1\0\24punctuation.bracket\14Delimiter\26punctuation.delimiter\vhl_map\16highlighter\15treesitter\bvim\30nvim-treesitter.highlight\14highlight\1\0\2\venable\2\21use_languagetree\2\21ensure_installed\1\0\0\1\v\0\0\15javascript\15typescript\fclojure\vkotlin\thtml\truby\tjson\btsx\blua\bcss\nsetup\28nvim-treesitter.configs\frequire\0")()
-- Config for: colorscheme
loadstring("\27LJ\2\nü\b\0\0\3\0\19\00056\0\0\0009\0\1\0'\1\3\0=\1\2\0006\0\0\0009\0\4\0'\1\6\0=\1\5\0006\0\0\0009\0\a\0'\2\b\0B\0\2\0016\0\0\0009\0\a\0'\2\t\0B\0\2\0016\0\0\0009\0\a\0'\2\n\0B\0\2\0016\0\0\0009\0\a\0'\2\v\0B\0\2\0016\0\0\0009\0\a\0'\2\f\0B\0\2\0016\0\0\0009\0\a\0'\2\r\0B\0\2\0016\0\0\0009\0\a\0'\2\14\0B\0\2\0016\0\0\0009\0\a\0'\2\15\0B\0\2\0016\0\0\0009\0\a\0'\2\16\0B\0\2\0016\0\0\0009\0\a\0'\2\17\0B\0\2\0016\0\0\0009\0\a\0'\2\18\0B\0\2\1K\0\1\0c hi LuaTreeFileStaged cterm=none ctermfg=none ctermbg=none gui=none guifg=#00afff guibg=none c hi LuaTreeFileMerge cterm=none ctermfg=none ctermbg=none gui=none guifg=#ff0000 guibg=none c hi LuaTreeFileRenamed cterm=none ctermfg=none ctermbg=none gui=none guifg=#ffff00 guibg=none c hi LuaTreeFileDirty cterm=none ctermfg=none ctermbg=none gui=none guifg=#ffff00 guibg=none c hi LuaTreeFileNew cterm=none ctermfg=none ctermbg=none gui=none guifg=#5fd700 guibg=none [ hi DiffDelete cterm=none ctermfg=none ctermbg=none gui=none guifg=#ff0000 guibg=none [ hi DiffChange cterm=none ctermfg=none ctermbg=none gui=none guifg=#ffff00 guibg=none [ hi DiffText cterm=none ctermfg=none ctermbg=none gui=none guifg=#00afff guibg=none [ hi DiffAdd cterm=none ctermfg=none ctermbg=none gui=none guifg=#5fd700 guibg=none \" hi SignColumn guibg=#282828 \26 colorscheme gruvbox \bcmd\bbg0\26gruvbox_number_column\6g\tdark\15background\6o\bvim\0")()
-- Conditional loads
-- Load plugins in order defined by `after`
END
function! s:load(names, cause) abort
call luaeval('_packer_load(_A[1], _A[2])', [a:names, a:cause])
endfunction
" Command lazy-loads
" Keymap lazy-loads
augroup packer_load_aucmds
au!
" Filetype lazy-loads
" Event lazy-loads
augroup END
Got the same issue
Is this a regression - did this work with previous commits of packer? At a glance, your config looks OK, but I use a very similar config for treesitter and haven't seen this issue myself.
I actually can't reproduce this with your config either. @ruifm is your config similar?
@wbthomason with previous commit nvim doesn't work either.
again packer_compiled.vim
Error on 142 line. loadstring(true)()
" 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
lua << END
local plugins = {
["packer.nvim"] = {
loaded = false,
only_sequence = false,
only_setup = false,
path = "/home/locke/.local/share/nvim/site/pack/packer/opt/packer.nvim"
}
}
local function handle_bufread(names)
for _, name in ipairs(names) do
local path = plugins[name].path
for _, dir in ipairs({ 'ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin' }) do
if #vim.fn.finddir(dir, path) > 0 then
vim.cmd('doautocmd BufRead')
return
end
end
end
end
_packer_load = nil
local function handle_after(name, before)
local plugin = plugins[name]
plugin.load_after[before] = nil
if next(plugin.load_after) == nil then
_packer_load({name}, {})
end
end
_packer_load = function(names, cause)
local some_unloaded = false
for _, name in ipairs(names) do
if not plugins[name].loaded then
some_unloaded = true
break
end
end
if not some_unloaded then return end
local fmt = string.format
local del_cmds = {}
local del_maps = {}
for _, name in ipairs(names) do
if plugins[name].commands then
for _, cmd in ipairs(plugins[name].commands) do
del_cmds[cmd] = true
end
end
if plugins[name].keys then
for _, key in ipairs(plugins[name].keys) do
del_maps[key] = true
end
end
end
for cmd, _ in pairs(del_cmds) do
vim.cmd('silent! delcommand ' .. cmd)
end
for key, _ in pairs(del_maps) do
vim.cmd(fmt('silent! %sunmap %s', key[1], key[2]))
end
for _, name in ipairs(names) do
if not plugins[name].loaded then
vim.cmd('packadd ' .. name)
if plugins[name].config then
for _i, config_line in ipairs(plugins[name].config) do
loadstring(config_line)()
end
end
if plugins[name].after then
for _, after_name in ipairs(plugins[name].after) do
handle_after(after_name, name)
vim.cmd('redraw')
end
end
plugins[name].loaded = true
end
end
handle_bufread(names)
if cause.cmd then
local lines = cause.l1 == cause.l2 and '' or (cause.l1 .. ',' .. cause.l2)
vim.cmd(fmt('%s%s%s %s', lines, cause.cmd, cause.bang, cause.args))
elseif cause.keys then
local keys = cause.keys
local extra = ''
while true do
local c = vim.fn.getchar(0)
if c == 0 then break end
extra = extra .. vim.fn.nr2char(c)
end
if cause.prefix then
local prefix = vim.v.count and vim.v.count or ''
prefix = prefix .. '"' .. vim.v.register .. cause.prefix
if vim.fn.mode('full') == 'no' then
if vim.v.operator == 'c' then
prefix = '' .. prefix
end
prefix = prefix .. vim.v.operator
end
vim.fn.feedkeys(prefix, 'n')
end
-- NOTE: I'm not sure if the below substitution is correct; it might correspond to the literal
-- characters \<Plug> rather than the special <Plug> key.
vim.fn.feedkeys(string.gsub(string.gsub(cause.keys, '^<Plug>', '\\<Plug>') .. extra, '<[cC][rR]>', '\r'))
elseif cause.event then
vim.cmd(fmt('doautocmd <nomodeline> %s', cause.event))
elseif cause.ft then
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeplugin', cause.ft))
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeindent', cause.ft))
end
end
-- Runtimepath customization
-- Pre-load configuration
-- Post-load configuration
-- Config for: tree
loadstring(true)() -- this line!
-- Config for: colorscheme
loadstring("\"\\27LJ\\2\\nü\\b\\0\\0\\3\\0\\19\\00056\\0\\0\\0009\\0\\1\\0'\\1\\3\\0=\\1\\2\\0006\\0\\0\\0009\\0\\4\\0'\\1\\6\\0=\\1\\5\\0006\\0\\0\\0009\\0\\a\\0'\\2\\b\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\t\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\n\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\v\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\f\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\r\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\14\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\15\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\16\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\17\\0B\\0\\2\\0016\\0\\0\\0009\\0\\a\\0'\\2\\18\\0B\\0\\2\\1K\\0\\1\\0c hi LuaTreeFileStaged cterm=none ctermfg=none ctermbg=none gui=none guifg=#00afff guibg=none c hi LuaTreeFileMerge cterm=none ctermfg=none ctermbg=none gui=none guifg=#ff0000 guibg=none c hi LuaTreeFileRenamed cterm=none ctermfg=none ctermbg=none gui=none guifg=#ffff00 guibg=none c hi LuaTreeFileDirty cterm=none ctermfg=none ctermbg=none gui=none guifg=#ffff00 guibg=none c hi LuaTreeFileNew cterm=none ctermfg=none ctermbg=none gui=none guifg=#5fd700 guibg=none [ hi DiffDelete cterm=none ctermfg=none ctermbg=none gui=none guifg=#ff0000 guibg=none [ hi DiffChange cterm=none ctermfg=none ctermbg=none gui=none guifg=#ffff00 guibg=none [ hi DiffText cterm=none ctermfg=none ctermbg=none gui=none guifg=#00afff guibg=none [ hi DiffAdd cterm=none ctermfg=none ctermbg=none gui=none guifg=#5fd700 guibg=none \\\" hi SignColumn guibg=#282828 \\26 colorscheme gruvbox \\bcmd\\bbg0\\26gruvbox_number_column\\6g\\tdark\\15background\\6o\\bvim\\0\"")()
-- Conditional loads
-- Load plugins in order defined by `after`
END
function! s:load(names, cause) abort
call luaeval('_packer_load(_A[1], _A[2])', [a:names, a:cause])
endfunction
" Command lazy-loads
" Keymap lazy-loads
augroup packer_load_aucmds
au!
" Filetype lazy-loads
" Event lazy-loads
augroup END
if i don't use 'config' option in plugin like
use {
'nvim-treesitter/nvim-treesitter',
-- config = require('plugins.treesitter'),
run = ':TSUpdate'
}
then everything is ok
for example I install nvim-tree like
use { 'kyazdani42/nvim-tree.lua', config = require('plugins.tree') }
local map = require('utils').map
local global = vim.g
return function()
global.lua_tree_side = 'left'
global.lua_tree_width = 30
global.lua_tree_auto_close = 1
global.lua_tree_quit_on_open = 1
global.lua_tree_follow = 1
global.lua_tree_indent_markers = 1
global.lua_tree_git_hl = 1
global.lua_tree_allow_resize = 1
global.lua_tree_show_icons = {
git = 1,
folders = 1,
files = 1
}
global.lua_tree_icons = {
default = 'ī',
symlink = 'ļ',
git = {
unstaged = "ā",
staged = "ā",
unmerged = "ī§",
renamed = "ā",
untracked = "ā
"
},
folder = {
default = "īæ",
open = "ī¾"
}
}
map('n', '<leader><leader>', ':LuaTreeToggle<CR>', { noremap = true })
end
And i get an error.
If I take out code from function in tree.lua then ok
local map = require('utils').map
local global = vim.g
global.lua_tree_side = 'left'
global.lua_tree_width = 30
global.lua_tree_auto_close = 1
global.lua_tree_quit_on_open = 1
global.lua_tree_follow = 1
global.lua_tree_indent_markers = 1
global.lua_tree_git_hl = 1
global.lua_tree_allow_resize = 1
global.lua_tree_show_icons = {
git = 1,
folders = 1,
files = 1
}
global.lua_tree_icons = {
default = 'ī',
symlink = 'ļ',
git = {
unstaged = "ā",
staged = "ā",
unmerged = "ī§",
renamed = "ā",
untracked = "ā
"
},
folder = {
default = "īæ",
open = "ī¾"
}
}
map('n', '<leader><leader>', ':LuaTreeToggle<CR>', { noremap = true })
I actually can't reproduce this with your config either. @ruifm is your config similar?
Yes my config is very similar. I can even reproduce it with a very minimal config with just one use if the config key is used (by passing a lua function).
It only happens if I do :PackerCompile twice, i.e., on an even number of :PackerCompile's, after restarting neovim, it exibits the behavior described by the OP. If I run another :PackerCompile and restart neovim again, the issue is gone.
For me it looks like a regression from your fix (for a very similar, alghouth it looks like the same issue) for https://github.com/wbthomason/packer.nvim/issues/128
I actually did not have the problem described by #128 before, only after your fix which is funny :laughing:
Ah, damn, so #128 may have broken something. Thanks; I'll look into this.
Also @letzabelin I think your tree.lua example might not be valid - that function closes over the upvalues global and map, and string.dump in Lua does not support upvalues for functions. Try moving those variable declarations inside the returned function.
@ruifm: is the following (taken from your dotfiles) an example of a specification that triggers the bug for you? I'm having trouble reproducing the error, so I'm looking for a minimal self-contained example.
use {
'editorconfig/editorconfig-vim',
config = function()
vim.g.EditorConfig_exclude_patterns = {'fugitive://.*'}
end
}
@wbthomason, after some investigation, with that config you just posted, close neovim, and do:
1.
nvim +PackerCompile +PackerSync
And the bug appears.
I can reliably reproduce that in 2 different machines with that minimal config
Fascinating! I still cannot reproduce this error on either of my 2 machines...
Sorry to request so much help, @ruifm, but could you share your compiled file for the minimal reproducing example when you get a chance?
Also, just to sanity check: the minimal reproducing example for you has exactly two plugins: one is packer, and the other is the above snippet?
packer_compiled.vim with the minimal example from above I can also reproduce the issue:
" 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
lua << END
local plugins = {}
local function handle_bufread(names)
for _, name in ipairs(names) do
local path = plugins[name].path
for _, dir in ipairs({ 'ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin' }) do
if #vim.fn.finddir(dir, path) > 0 then
vim.cmd('doautocmd BufRead')
return
end
end
end
end
_packer_load = nil
local function handle_after(name, before)
local plugin = plugins[name]
plugin.load_after[before] = nil
if next(plugin.load_after) == nil then
_packer_load({name}, {})
end
end
_packer_load = function(names, cause)
local some_unloaded = false
for _, name in ipairs(names) do
if not plugins[name].loaded then
some_unloaded = true
break
end
end
if not some_unloaded then return end
local fmt = string.format
local del_cmds = {}
local del_maps = {}
for _, name in ipairs(names) do
if plugins[name].commands then
for _, cmd in ipairs(plugins[name].commands) do
del_cmds[cmd] = true
end
end
if plugins[name].keys then
for _, key in ipairs(plugins[name].keys) do
del_maps[key] = true
end
end
end
for cmd, _ in pairs(del_cmds) do
vim.cmd('silent! delcommand ' .. cmd)
end
for key, _ in pairs(del_maps) do
vim.cmd(fmt('silent! %sunmap %s', key[1], key[2]))
end
for _, name in ipairs(names) do
if not plugins[name].loaded then
vim.cmd('packadd ' .. name)
if plugins[name].config then
for _i, config_line in ipairs(plugins[name].config) do
loadstring(config_line)()
end
end
if plugins[name].after then
for _, after_name in ipairs(plugins[name].after) do
handle_after(after_name, name)
vim.cmd('redraw')
end
end
plugins[name].loaded = true
end
end
handle_bufread(names)
if cause.cmd then
local lines = cause.l1 == cause.l2 and '' or (cause.l1 .. ',' .. cause.l2)
vim.cmd(fmt('%s%s%s %s', lines, cause.cmd, cause.bang, cause.args))
elseif cause.keys then
local keys = cause.keys
local extra = ''
while true do
local c = vim.fn.getchar(0)
if c == 0 then break end
extra = extra .. vim.fn.nr2char(c)
end
if cause.prefix then
local prefix = vim.v.count and vim.v.count or ''
prefix = prefix .. '"' .. vim.v.register .. cause.prefix
if vim.fn.mode('full') == 'no' then
if vim.v.operator == 'c' then
prefix = '' .. prefix
end
prefix = prefix .. vim.v.operator
end
vim.fn.feedkeys(prefix, 'n')
end
-- NOTE: I'm not sure if the below substitution is correct; it might correspond to the literal
-- characters \<Plug> rather than the special <Plug> key.
vim.fn.feedkeys(string.gsub(string.gsub(cause.keys, '^<Plug>', '\\<Plug>') .. extra, '<[cC][rR]>', '\r'))
elseif cause.event then
vim.cmd(fmt('doautocmd <nomodeline> %s', cause.event))
elseif cause.ft then
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeplugin', cause.ft))
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeindent', cause.ft))
end
end
-- Runtimepath customization
-- Pre-load configuration
-- Post-load configuration
-- Config for: editorconfig-vim
loadstring("'\\27LJ\\1\\2Q\\0\\0\\2\\0\\4\\0\\0054\\0\\0\\0007\\0\\1\\0003\\1\\3\\0:\\1\\2\\0G\\0\\1\\0\\1\\2\\0\\0\\18fugitive://.*\"EditorConfig_exclude_patterns\\6g\\bvim\\0'")()
-- Conditional loads
-- Load plugins in order defined by `after`
END
function! s:load(names, cause) abort
call luaeval('_packer_load(_A[1], _A[2])', [a:names, a:cause])
endfunction
" Command lazy-loads
" Keymap lazy-loads
augroup packer_load_aucmds
au!
" Filetype lazy-loads
" Event lazy-loads
augroup END
and the error is:
Error detected while processing /home/ruifm/.config/nvim/plugin/packer_compiled.vim:
line 138:
E5108: Error executing lua [string ":lua"]:125: attempt to call a nil value
With your suggested variation:
" 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
lua << END
local plugins = {
["packer.nvim"] = {
loaded = false,
only_sequence = false,
only_setup = false,
path = "/home/ruifm/.local/share/nvim/site/pack/packer/opt/packer.nvim"
}
}
local function handle_bufread(names)
for _, name in ipairs(names) do
local path = plugins[name].path
for _, dir in ipairs({ 'ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin' }) do
if #vim.fn.finddir(dir, path) > 0 then
vim.cmd('doautocmd BufRead')
return
end
end
end
end
_packer_load = nil
local function handle_after(name, before)
local plugin = plugins[name]
plugin.load_after[before] = nil
if next(plugin.load_after) == nil then
_packer_load({name}, {})
end
end
_packer_load = function(names, cause)
local some_unloaded = false
for _, name in ipairs(names) do
if not plugins[name].loaded then
some_unloaded = true
break
end
end
if not some_unloaded then return end
local fmt = string.format
local del_cmds = {}
local del_maps = {}
for _, name in ipairs(names) do
if plugins[name].commands then
for _, cmd in ipairs(plugins[name].commands) do
del_cmds[cmd] = true
end
end
if plugins[name].keys then
for _, key in ipairs(plugins[name].keys) do
del_maps[key] = true
end
end
end
for cmd, _ in pairs(del_cmds) do
vim.cmd('silent! delcommand ' .. cmd)
end
for key, _ in pairs(del_maps) do
vim.cmd(fmt('silent! %sunmap %s', key[1], key[2]))
end
for _, name in ipairs(names) do
if not plugins[name].loaded then
vim.cmd('packadd ' .. name)
if plugins[name].config then
for _i, config_line in ipairs(plugins[name].config) do
loadstring(config_line)()
end
end
if plugins[name].after then
for _, after_name in ipairs(plugins[name].after) do
handle_after(after_name, name)
vim.cmd('redraw')
end
end
plugins[name].loaded = true
end
end
handle_bufread(names)
if cause.cmd then
local lines = cause.l1 == cause.l2 and '' or (cause.l1 .. ',' .. cause.l2)
vim.cmd(fmt('%s%s%s %s', lines, cause.cmd, cause.bang, cause.args))
elseif cause.keys then
local keys = cause.keys
local extra = ''
while true do
local c = vim.fn.getchar(0)
if c == 0 then break end
extra = extra .. vim.fn.nr2char(c)
end
if cause.prefix then
local prefix = vim.v.count and vim.v.count or ''
prefix = prefix .. '"' .. vim.v.register .. cause.prefix
if vim.fn.mode('full') == 'no' then
if vim.v.operator == 'c' then
prefix = '' .. prefix
end
prefix = prefix .. vim.v.operator
end
vim.fn.feedkeys(prefix, 'n')
end
-- NOTE: I'm not sure if the below substitution is correct; it might correspond to the literal
-- characters \<Plug> rather than the special <Plug> key.
vim.fn.feedkeys(string.gsub(string.gsub(cause.keys, '^<Plug>', '\\<Plug>') .. extra, '<[cC][rR]>', '\r'))
elseif cause.event then
vim.cmd(fmt('doautocmd <nomodeline> %s', cause.event))
elseif cause.ft then
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeplugin', cause.ft))
vim.cmd(fmt('doautocmd <nomodeline> %s FileType %s', 'filetypeindent', cause.ft))
end
end
-- Runtimepath customization
-- Pre-load configuration
-- Post-load configuration
-- Config for: editorconfig-vim
loadstring("'\\27LJ\\1\\2Q\\0\\0\\2\\0\\4\\0\\0054\\0\\0\\0007\\0\\1\\0003\\1\\3\\0:\\1\\2\\0G\\0\\1\\0\\1\\2\\0\\0\\18fugitive://.*\"EditorConfig_exclude_patterns\\6g\\bvim\\0'")()
-- Conditional loads
-- Load plugins in order defined by `after`
END
function! s:load(names, cause) abort
call luaeval('_packer_load(_A[1], _A[2])', [a:names, a:cause])
endfunction
" Command lazy-loads
" Keymap lazy-loads
augroup packer_load_aucmds
au!
" Filetype lazy-loads
" Event lazy-loads
augroup END
````
The error is:
Error detected while processing /home/ruifm/.config/nvim/plugin/packer_compiled.vim:
line 145:
E5108: Error executing lua [string ":lua"]:132: attempt to call a nil value
```
Ah! Thank you! I was finally able to reproduce the error and (I think) fix the problem. I'd put a call to vim.inspect in a place that meant it sometimes wrapped a compiled bytecode string in quotes (and escaped values), causing the strange output in packer_compiled and your error.
Please let me know if you (either @ruifm or @letzabelin or anyone else) continue to experience this issue, and sorry for the slow fix!
Thanks @wbthomason it seems fixed!
sorry for the slow fix!
From my perspective it was actually quite fast, specially considering you are doing this practically alone on your free time just out of love.
I've commented directly on the commit, but the fix actually introduces this issue for me:
Error detected while processing /Users/lewis/projects/dotfiles/nvim/plugin/packer_compiled.vim:
line 196:
E5108: Error executing lua [string ":lua"]:171: bad argument #1 to 'loadstring' (function expected, got boolean)
Reverting the line in the fix commit fixes it.
there could be a quoting issue @letzabelin.
in my plugins.lua, config = 'require("klooj.treesitter")' works fine but config = require('klooj.treesitter') causes problems.
the two styles of quoting seem to interact differently with the fix mentioned by @lewis6991. reverting that line and using double quotes inside single quotes works for me.
but, if it's a multiline function beginning with an explicit declaration, then there's no need for the extra layer of quoting ... or so it seems.
yep, now it works. Thanks @wbthomason
@lewis6991: damn, ok. Could you provide a minimal reproducing config?
@kludgeon: the two styles there are different - one provides a string value, which packer directly copies to the compiled output. The other is requiring a module, which must return only a function compatible with string.dump, which packer byte-compiled and loads with loadstring. Both styles should work - from a glance at your config, it appears that the modules you require (e.g. klooj.treesitter) do not return functions. I suspect this is what causes trouble for you?
This seems to do it:
vim.cmd 'packadd packer.nvim'
local packer = require('packer')
packer.startup{{
'euclidianAce/BetterLua.vim',
{'nvim-treesitter/nvim-treesitter', config = "print('hello')"}
}}
return packer
Oooook. I can no longer reproduce any of @lewis6991's issue, this issue, or #128 with the current, hopefully final, fix to this feature. Please let me know if you still experience errors, and sorry for the churn.
LGTM, thanks!
Most helpful comment
Thanks @wbthomason it seems fixed!
From my perspective it was actually quite fast, specially considering you are doing this practically alone on your free time just out of love.