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 79 forks source link

Report error when attach_on with no option #384

Closed nanozuki closed 3 years ago

nanozuki commented 3 years ago

My testing minimal init.vim

local nvim_lsp = require 'lspconfig'

local nvim_lsp = require 'lspconfig'

local on_attach = function(client, bufnr)
  -- LSP Settings
  -- ....

  -- [Plug] completion-nvim
  require'completion_nvim'.on_attach()
end

-- Use a loop to conveniently both setup defined servers
-- and map buffer local keybindings when the language server attaches
local servers_settings = {
  gopls = {},
  vimls = {},
}

for lsp, settings in pairs(servers_settings) do
  settings['on_attach'] = on_attach
  nvim_lsp[lsp].setup(settings)
end

How to reproduce Let LSP and completion-nvim load on all filetypes. And just open the nvim. And the nvim will print an error message:

Error detected while processing $HOME/.local/share/CrowsEnv/dots/nvim/init.lua:
E5113: Error while calling lua chunk: ...ite/pack/packer/start/completion-nvim/lua/completion.lua:251: bad argument #1 to 'ipairs' (tab
le expected, got nil)

Expected behavior on error message print.

nanozuki commented 3 years ago

I tried to fix this problem at #385

nanozuki commented 3 years ago

Oh no, nvim-completion call on_attach twice in my config file by mistake. this is not a bug.