uga-rosa/cmp-dictionary

Error detected while processing TextChangedI Autocommands for "*":

rghvdberg opened this issue · 2 comments

This error seems to be triggered by the latest commit 4286695

Error  21:24:43 msg_show.lua_error Error detected while processing TextChangedI Autocommands for "*":
21:24:43 msg_show Error executing lua callback: ...e/nvim/lazy/cmp-dictionary/lua/cmp_dictionary/source.lua:64: attempt to compare number with nil
stack traceback:
	...e/nvim/lazy/cmp-dictionary/lua/cmp_dictionary/source.lua:64: in function 'complete'
	...dberg/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:326: in function 'complete'
	...rvdberg/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
	...rvdberg/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
	...rvdberg/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
	...rvdberg/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
	...rvdberg/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:346: 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>

I'm using LazyVim and this is my config for nvim-cmp:

return {
  "hrsh7th/nvim-cmp",

  dependencies = { "hrsh7th/cmp-emoji", "uga-rosa/cmp-dictionary", "hrsh7th/cmp-calc" },

  ---@param opts cmp.ConfigSchema
  opts = function(_, opts)
    local cmp = require("cmp")
    local dictionary = require("cmp_dictionary")
    opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "dictionary", keywordlength = 2 } }))
    opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "emoji" } }))
    opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "calc" } }))
    opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "neorg" } }))
    dictionary.setup({
      -- paths = ["*"],
      exact_length = 2,
      first_case_insensitive = true,
    })

    vim.api.nvim_create_autocmd("FileType", {
      -- pattern = "norg",
      pattern = "*",
      callback = function()
        local paths = {
          "~/.config/nvim/dicts/nl.dict",
          "~/.config/nvim/dicts/barny.dict",
          "~/.config/nvim/dicts/groepen.dict",
        }
        require("cmp_dictionary").setup({
          paths = paths,
        })
      end,
    })
  end,
}                 

Fixed.
Also, your configuration is wrong, it's keyword_length (the _ is missing).

seems to work fine! thanks