Error message in trie.lua
kekscode opened this issue · 10 comments
Any idea what i do wrong here?
Error on startup:
Error executing luv callback:
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:45: bad argument #1 to 'decode' (string expected, got nil)
stack traceback:
[C]: in function 'decode'
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:45: in function <...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:44>
Error in luv thread:
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:42: too deep to serialize
Config (lazy):
{
"uga-rosa/cmp-dictionary", -- dictionary manager
enabled = true,
build =
'brew install aspell && brew install wordnet && aspell -d en dump master | aspell -l en expand >$HOME/en.dict && aspell -d de dump master | aspell -l de expand >$HOME/de.dict',
config = function()
require("cmp_dictionary").setup({
paths = {
"/usr/share/dict/words", vim.fn.expand('$HOME/de.dict'), vim.fn.expand('$HOME/en.dict'),
},
exact_length = 2,
first_case_insensitive = true,
document = {
enable = true,
command = { "wn", "${label}", "-over" },
},
})
end
},
neovim:
vim --version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1703358377
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"
Run :checkhealth for more info
Hmm. This is the first error I've seen, but the cause is predictable. You are using a dictionary that contains rather long words, aren't you?
I can solve the problem itself (using vim.json to serialize), but it slows me down somewhat.
Can you tell me what dictionary you are using?
Does 51c48f9 fix it?
Not quite, the error now reads:
Error in luv thread:
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:40: Cannot serialise, excessive nesting (1001)
Error executing luv callback:
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:43: bad argument #1 to 'decode' (string expected, got nil)
stack traceback:
[C]: in function 'decode'
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:43: in function <...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:42>
It worked before using #56 if that helps with the same dictionaries de
and en
. I added the wordnet stuff while migrating my config to v3 though, so it is not really comparable. I'll come back to your question about the dictionary data i use in a sec.
Hmm. This is the first error I've seen, but the cause is predictable. You are using a dictionary that contains rather long words, aren't you? I can solve the problem itself (using vim.json to serialize), but it slows me down somewhat. Can you tell me what dictionary you are using?
w=/usr/share/dict/words && wc $w && wc --max-line-length $w
235976 235976 2493885 /usr/share/dict/words
28 /usr/share/dict/words
w=$HOME/de.dict && wc $w && wc --max-line-length $w
84577 382300 5043131 /Users/<redacted>/de.dict
1047 /Users/<redacted>/de.dict
w=$HOME/en.dict && wc $w && wc --max-line-length $w
127351 127351 1232855 /Users/<redacted>/en.dict
24 /Users/<redacted>/en.dict
The dicts are unpacked using:
brew install aspell && brew install wordnet && aspell -d en dump master | aspell -l en expand >$HOME/en.dict && aspell -d de dump master | aspell -l de expand >$HOME/de.dict
Hmmm, there is supposed to be a single word with more than 500 bytes. Perhaps it is not compatible with the new format of the dictionary.
I have checked the dictionary and understand. It's because of the change in dictionary specifications (:h cmp-dictionary-option-paths
).
I only used newlines as word separators (to be able to use external commands like look
, grep
, etc.). If you replace all the white space in the dictionary with newlines, it should work.
aspell -d de dump master | aspell -l de expand | sed 's/\s\+/\n/g' > de.dict
I fixed the Find dictionaries
chapter of the documentation.
I have checked the dictionary and understand. It's because of the change in dictionary specifications (
:h cmp-dictionary-option-paths
). I only used newlines as word separators (to be able to use external commands likelook
,grep
, etc.). If you replace all the white space in the dictionary with newlines, it should work.aspell -d de dump master | aspell -l de expand | sed 's/\s\+/\n/g' > de.dict
wow... you're awesome, it just works now!
Full config line for lazy's build
parameter:
build = [[brew install aspell && brew install wordnet && aspell -d en dump master | aspell -l en expand | sed "s/\s\+/\n/g" >$HOME/en.dict && aspell -d de dump master | aspell -l de expand | sed "s/\s\+/\n/g" >$HOME/de.dict]],
The lua [[
and ]]
are helpful to avoid issues with nesting and escape sequence interpretation.
I'm glad it's fixed.
I'm facing the same issue though creating a new dict using aspell -d de dump master | aspell -l de expand | sed 's/\s\+/\n/g' > de.dict
doesn't work for me :/
EDIT:
Nevermind, forgot to wrap my path with vim.fn.expand