Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a custom plugin, it loads but I get cache.lua invalid value (table) at index 2 #1902

Open
squareborg opened this issue Apr 26, 2024 · 0 comments

Comments

@squareborg
Copy link

Hi I tried to create my own custom completion plugin for cmp,

it seems CMP loads it as I can see it in CmpStatus but on every keypress I get this error:

Any ideas? Thanks

Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/cache.lua:15: invalid value (table) at index 2 in table for 'concat'
stack traceback:
	[C]: in function 'key'
	.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/cache.lua:15: in function 'get'
	.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/cache.lua:36: in function 'get_offset'
	...s/stm/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:270: in function 'complete'
	/Users/stm/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
	/Users/stm/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
	/Users/stm/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
	/Users/stm/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
	/Users/stm/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:338: in function 'callback'
	...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:49: in function 'emit'
	...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:23: in function <...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22>
Error detected while processing TextChangedI Autocommands for "*":

my plugin below


local M = {}
local source = {}

function source:is_available()
  return true
end
function source:get_debug_name()
  return "i8n"
end
function source:get_keyword_pattern()
  return { "t(" }
end
function source:get_trigger_characters()
  return { "'" }
end

local trans_table = {
  { label = "SomeThingHere" },
  { label = "AnotherThingHere" },
}

function source:complete(_, callback)
  print("in complete")
  callback({ items = trans_table })
end

function source:resolve(completion, callback)
  callback(completion)
end

function source:execute(completion, callback)
  callback(completion)
end

M.setup = function()
  require("cmp").register_source("i8n", source)
end

return M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant