uga-rosa / cmp-dictionary

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

V3: decode error if path starts with ~/ #63

Closed eronde closed 5 months ago

eronde commented 5 months ago

First of all, thanks for this great plugin! I've upgrade the plugin to v3 and I've noticed if the path uses a ~, it produces an trie error.

Error executing luv callback:
...er/start/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:43: bad argument #1 to 'decode' (string expected, got nil)
stack traceback:
    [C]: in function 'decode'
    ...er/start/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:43: in function <...er/start/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:42>
Error in luv thread:
...er/start/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:31: ENOENT: no such file or directory: ~/Dotfiles/vim/dict/nl.txt

Error produces with following config:

local cmp_dict = require("cmp_dictionary")

cmp_dict.setup({
  -- The following are default values.
  exact_length = 2,
  first_case_insensitive = false,
  document = {
    enable = true,
    command = { "wn", "${label}", "-over" },
  },
})

local dict = {
  ["*"] = { "~/Dotfiles/vim/dict/nl.txt" },

}

vim.api.nvim_create_autocmd("FileType", {
  pattern = "*",
  callback = function(ev)
    require("cmp_dictionary").setup({
      paths = dict[ev.match] or dict["*"],
    })
  end,
})

With following config it's runs well:


local dict = {
  ["*"] = { "/home/erc/Dotfiles/vim/dict/nl.txt" },
 }
eronde commented 5 months ago

:pray: