uga-rosa / cmp-dictionary

A dictionary completion source for nvim-cmp
MIT License
236 stars 16 forks source link

Error executing vim.schedule lua callback #43

Closed Joarell closed 1 year ago

Joarell commented 1 year ago

Hi! Firstly, I'd like to thank you fort this amazing plugin!

I just have an issue when I open neovim I got this error:

Error executing vim.schedule lua callback: .../packer/start/cmp-dictionary/lua/cmp_dictionary/util.lua:48: attempt to index upvalue 'timer' (a nil value) stack traceback: .../packer/start/cmp-dictionary/lua/cmp_dictionary/util.lua:48: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>

I will appreciate a lot if you could have a look at my settings to figure it out where I made a mistake.

local dict = require("cmp_dictionary")

dict.setup({
    exact = 3,
    first_case_insensitive = false,
    document = false,
    document_command = "wn %s -over",
    async = false,
    max_items = -1,
    capacity = 5,
    debug = false,
})

dict.switcher({
    spelllang = {
        en = "~/dotfiles/en.dict",
    },
    filepath = {
        ["*"] = "~/dotfiles/en.dict",
    },
})
cmp.setup({
    snippet = {
        expand = function(args)
            if not ls then
                return
            end
            ls.lsp_expand(args.body)
        end,
    },
    sources = {
        { name = "luasnip" },
        { name = "path" },
        { name = "buffer", keyword_length = 3 },
        { name = "cmdline", keyword_length = 3 },
        { name = "dictionary", keyword_length = 3 },
    },
    window = {
        completion = cmp.config.window.bordered(),
        documentation = cmp.config.window.bordered(),
    },
    formatting = {
        expandable_indicator = true,
        fields = { "kind", "abbr", "menu" },
        format = lspkind.cmp_format({
            mode = "symbol_text",
            maxwidth = 50,
            ellipsis_char = "...",
            menu = {
                nvim_lsp = "   ",
                luasnip = "   ",
                buffer = "  ",
                path = "  ",
                cmdline = " ",
                dictionary = "  ",
            },
            before = function(_, vim_item)
                return vim_item
            end,
        }),
    },
uga-rosa commented 1 year ago

I have not been able to reproduce it, but I guessed and fixed it a little. Could you please check if the latest version fixes it?

Joarell commented 1 year ago

Thank you! Thank you! Thank you! Thank you for all assistance and prompt reply.

The error message was gone! Have a great day! I wish you the best!

uga-rosa commented 1 year ago

And the filepath is lua pattern. It should be written like this.

local dict = require("cmp_dictionary")

dict.setup({
    exact = 3,
        -- You do not need to write it if it is the default.
})

dict.switcher({
    spelllang = {
        en = "~/dotfiles/en.dict",
    },
})

cmp.setup({
        ...
})