-
Notifications
You must be signed in to change notification settings - Fork 75
opt.get_option
in on_attach()
returns nil
for unset options #402
Description
When I try to active completion-nvim
in my init.lua
with the on_attach
function, I get a bunch of errors.
Error running config for completion-nvim: ...ite/pack/packer/start/completion-nvim/lua/completion.lua:251: bad argument #1 to 'ipairs' (table expected, got nil)
If we look at the offending line:
completion-nvim/lua/completion.lua
Lines 246 to 255 in 139fb6c
M.on_attach = function(option) | |
-- setup completion_option tables | |
opt.set_option_table(option) | |
local disable_filetypes = opt.get_option("disable_filetypes") | |
local ft = vim.bo.filetype | |
for _, disable_ft in ipairs(disable_filetypes) do | |
if ft == disable_ft then | |
return | |
end | |
end |
disable_filetypes
which is returned by get_options
is nil
the moment ipairs
is called. I tried to manually edit the file and add disable_filetypes = disable_filetypes or {}
at line 250 but I got basically the same error elsewhere.
Error running config for completion-nvim: ...ite/pack/packer/start/completion-nvim/lua/completion.lua:266: bad argument #1 to 'len' (string expected, got nil)
which is basically the same error.
completion-nvim/lua/completion.lua
Lines 265 to 270 in 139fb6c
if string.len(opt.get_option('confirm_key')) ~= 0 then | |
api.nvim_buf_set_keymap(0, 'i', opt.get_option('confirm_key'), | |
'pumvisible() ? complete_info()["selected"] != "-1" ? "\\<Plug>(completion_confirm_completion)" :'.. | |
' "\\<c-e>\\<CR>" : "\\<CR>"', | |
{silent=false, noremap=false, expr=true}) | |
end |
string.len()
is getting nil
as its argument.
My testing minimal init.lua
require('completion').on_attach()
(literally my one-line init.lua
created in a temporary home directory)
Expected behavior
I expect not to get errors when I call on_attach
. Perhaps get_options
should handle missing options better (?)