nvim-lua / completion-nvim

A async completion framework aims to provide completion to neovim's built in LSP written in Lua
Apache License 2.0
973 stars 78 forks source link

`opt.get_option` in `on_attach()` returns `nil` for unset options #402

Open brainplot opened 3 years ago

brainplot commented 3 years ago

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:

https://github.com/nvim-lua/completion-nvim/blob/139fb6cfbd9f7384a5489d3e4afdacb8ed977ab0/lua/completion.lua#L246-L255

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.

https://github.com/nvim-lua/completion-nvim/blob/139fb6cfbd9f7384a5489d3e4afdacb8ed977ab0/lua/completion.lua#L265-L270

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 (?)