dictionary path is only set on entering the first buffer
moetayuko opened this issue · 2 comments
Env
My config looks like this, and nvim-cmp
is loaded on InsertEnter
{
"hrsh7th/nvim-cmp",
dependencies = {
{
"uga-rosa/cmp-dictionary",
config = function(_, opts)
local dict = require("cmp_dictionary")
dict.setup(opts)
dict.switcher({ spelllang = {
en = "/usr/share/dict/words",
} })
end,
},
},
opts = function(_, opts)
local cmp = require("cmp")
opts.sources = cmp.config.sources(vim.list_extend(opts.sources, {
{
name = "dictionary",
keyword_length = 2,
},
}))
end,
}
Since I set the dictionary path for spelllang=en only, the path will be appended to vim.opt_local.dictionary
(notice that it's buffer-local!) on OptionSet
cmp-dictionary/lua/cmp_dictionary/init.lua
Lines 76 to 82 in f076c6b
Issue
vim.opt_local.dictionary
is only populated when entering the first buffer.
If the first is a "normal" buffer, completion keeps working for later buffers despite vim.opt_local.dictionary
being empty, for unknown reasons.
However, if the first buffer is telescope or potentially other special buffers, completion won't work for the entire session.
To reproduce:
# Step | Operation | :setlocal dictionary |
Has word completion? |
---|---|---|---|
1 | start nvim | N/A | |
2 | open a file and enter insert mode | /usr/share/dict/words | Y |
3 | open another file and enter insert mode | Y |
# Step | Operation | :setlocal dictionary |
Has word completion? |
---|---|---|---|
1 | start nvim | N/A | |
2 | :Telescope , then press <esc> to switch to normal mode but not quit telescope |
/usr/share/dict/words | N/A |
3 | quit telescope, open a file and enter insert mode | N |
Please update.
Thanks, it's working now.