uga-rosa / cmp-dictionary Goto Github PK
View Code? Open in Web Editor NEWA dictionary completion source for nvim-cmp
License: MIT License
A dictionary completion source for nvim-cmp
License: MIT License
Hello, thank you for the plugin. Can you please hint me on how to set up suggestions from russian dictionary? I have the following init.vim
:
let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir . '/autoload/plug.vim')
execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'uga-rosa/cmp-dictionary'
call plug#end()
if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
echom 'Some modules are missing, running :PlugInstall'
PlugInstall --sync
endif
lua <<EOF
local cmp = require('cmp')
require("cmp_dictionary").setup({
dic = {
spelllang = {
en = "/path/to/en.dict",
ru = "/path/to/ru.dict",
},
},
})
cmp.setup{
mapping = {
["<C-j>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
end
end, { "i", "s" }),
["<C-k>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
end
end, { "i", "s" }),
['<C-l>'] = cmp.mapping({
i = cmp.mapping.confirm({ select = false }),
}),
},
sources = {
{
name = "dictionary",
keyword_length = 2,
},
}
}
EOF
set keymap=russian-jcuken
set spelllang=ru
But I do not get any completions as I type in russian:
Executing CmpDictionaryUpdate
after entering buffer also does not help.
While english seems to work fine:
I use aspell-en
and aspell-ru
packages on archlinux and the following command to get dictionaries:
aspell -d en dump master | aspell -l en expand > en.dict
aspell -d ru dump master | aspell -l ru expand > ru.dict
Hi, I'm not sure if spellcorrection is in scope of this plugin but I noticed dict suggest words only for new typed in words, but it wont suggest anything of existing words with spell mistake:
In video above TabNine suggested correction, but I got not entries from cmp-dict.
Any chances for cmp-dict to suggest correction for spelling mistakes?
Hi!
Is possible to change dictionaries on-demand?
I have cmp-dictionary
configured with:
require('cmp_dictionary').setup({
dic = {
-- ['*'] = '/usr/share/dict/words',
['markdown'] = '/path/to/es.dict',
},
-- The following are default values, so you don't need to write them if you don't want to change them
exact = 3,
first_case_insensitive = true,
async = true,
-- capacity = 5,
-- debug = false,
})
I tried:
:lua require('cmp_dictionary').setup({dic={['markdown'] = '/path/to/en.dict'}})
And after:
:lua require("cmp_dictionary.caches").update()
After that, I try to see the current config:
:lua dump(require("cmp_dictionary.config"))
{
config = {
async = false,
capacity = 5,
debug = false,
dic = {
["*"] = <1>{},
markdown = "/path/to/en.dict"
},
exact = 2,
first_case_insensitive = false
},
default = {
async = false,
capacity = 5,
debug = false,
dic = {
["*"] = <table 1>
},
exact = 2,
first_case_insensitive = false
},
get = <function 1>,
ready = true,
setup = <function 2>
}
I see the new dictionary in config (I notice that all my other settings get back to the defaults), but I'm still seeing only the words of the previous dict (not the new one).
Is this possible?
Thank you!
When I've updated cmp-dictionary and nvim to 0.6 I get 2 errors:
The first is when I have async enabled and the mpack can't be find - I don't know if I have to install that or the new nvim should provide it.
vim.g.cmp_dictionary_async = true
cmp_dictionary/caches.lua:32 module mpack not found
When I disable async I get this error:
Error executing luv callback:
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:49: attempt to index a nil value
stack traceback:
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:49: in function 'indexing'
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:119: in function '_create_cache'
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:129: in function 'create_cache_sync'
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:219: in function <...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:205>
Hi, first of all, thank you for the plugin. It's a life saver for me, being an old CoC user, which had this feature.
I think it's a recent issue I'm noticing, but when I open a buffer in Neovim, I saw a HUGE delay until my cursor becomes interactive (the UI is basically frozen).
I do have A LOT of plugins, however I managed to pin the issue down to this plugin: when I disable this, my cursor is instantly interactive and I can immediately start interacting with the buffer, but if it's enabled, I have that delay.
I'm not configuring anything for the plugin and just loading it as a dependency (like below). Is there a setting I can configure to avoid the delay?
I'm using lazy.nvim
as my package manager:
-- nvim-cmp
return {
'hrsh7th/nvim-cmp',
event = 'VeryLazy',
dependencies = {
-- other sources ...
'uga-rosa/cmp-dictionary'
},
-- other settings for nvim-cmp
}
source is loaded but I am not getting any completion from cmp-dictionary. I am aware of the v2 changes and am not using any .setup()
This is my only reference to cmp-dictionary
in my config file.
# cmp.lua
cmp.setup {
sources = {
{ name = "dictionary" },
...
},
...
}
:CmpStatus
# ready source names
- dictionary
- ...
You can download dic from aspell.net or installing by package manager, xbps extract to
$ ls /usr/share/dict/
american-english british-english words
But all I can see is just, tar.bz2 file When I uncompress it contains quite many files.
Tried to install
sudo make install and it outputs
mkdir -p /usr/lib/aspell-0.60/
cp fi.rws fi.multi finnish.alias /usr/lib/aspell-0.60/
cd /usr/lib/aspell-0.60/ && chmod 644 fi.rws fi.multi finnish.alias
mkdir -p /usr/lib/aspell-0.60/
cp fi.dat fi_affix.dat /usr/lib/aspell-0.60/
cd /usr/lib/aspell-0.60/ && chmod 644 fi.dat fi_affix.dat
Any clue "/usr/share/dict/ language or if its in /usr/lib/aspell-0.60/, which file it should be?
I tried
["*"] = { "/usr/lib/aspell-0.60/fi.rws" },
but it didn't give me any completions
Is there any tips for speed up (such as lazy load)?
or
Is this startuptime in the specifications?
Before uninstall cmp-dictionary
1299.237 836.919: BufEnter autocommands
After uninstall cmp-dictionary
372.051 005.900: BufEnter autocommands
NVIM v0.8.0-v0.8.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Packer
use {
"uga-rosa/cmp-dictionary"
["config"] = function() {
local path = vim.fn.expand "en.dict"
local cmp_dict = require("cmp_dictionary")
cmp_dict.setup({
["dict"] = {
["*"] = {"/user/share/dict/words"}
["spelling"] = {["en"] = path}
}
})
}
cmp.config.sources {
["name"] = "dictionary"
["group_incex"] = 5
["keyword_length"] 2
}
Dictionaries are not updated that often, so why not convert them into a program-friendly form and store them under stdpath("cache")?
96 sources = cmp.config.sources({
97 { name = "nvim_lsp" },
98 { name = "luasnip" },
99 { name = "path" },
100 { name = "buffer" },
101 { name = "nvim_lsp_signature_help" },
102 { name = "dictionary", keyword_length = 3 },
103 }),
104
105 diagnost
106 ┌──────────────────────────────────┐
107 │ diagnostic Variable [LSP] │
108 │ diagnostics Variable [LSP] │em)
109 │ diagnostics Variable [LSP] │at("%s %s", kind_icons[vim_item.kind], vim_item.kind)
110 │ diagnostics Variable [LSP] │
111 │ diagnostic Variable [LSP] │
112 │ diagnostics Variable [LSP] │
113 │ diagnosticls Variable [LSP] │
114 │ diagnostic Text │
115 │ diagnostics Text │
116 │ diagnosticate Text │
117 │ diagnostician Text │
118 }) │ diagnostically Text │
119 │ diagnostication Text │
120 -- └──────────────────────────────────┘s
the text was not shown with dictionary
, how should I config for that purpose, here was my config:
147 use({
148 "uga-rosa/cmp-dictionary",
149 config = function()
150 require("cmp_dictionary").setup({
151 dic = {
152 ["*"] = { "/usr/share/dict/words" },
153 },
154 })
155 end,
156 })
If i not use lazyload in packer, cmp-dictionary
work fine.
after I open lazyload local lazyload = 1
, cmp-dictionary
can't work.
I saw cmp-dictionary
config is load. print('config dict')
test init.lua
local fn, cmd = vim.fn, vim.cmd
local root_dir = fn.fnamemodify(fn.resolve(fn.expand('<sfile>:p')), ':h')
cmd('set packpath=' .. root_dir .. '/plugged')
cmd('set runtimepath^=' .. root_dir .. '/plugged')
local install_path = root_dir .. '/plugged/pack/packer/opt/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
Bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
cmd([[
set mouse=n
packadd packer.nvim
nnoremap <space>pu :PackerSync<CR>
nnoremap <space>pi :PackerInstall<CR>
nnoremap <space>pr :PackerClean<CR>
nnoremap <space>pc :PackerCompile<CR>
]])
function Cmp()
local cmp = require('cmp')
cmp.setup({
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'dictionary' },
}),
})
end
function Dict()
print('config dict')
require("cmp_dictionary").setup({
dic = {
['*'] = {root_dir .. '/dictionary'},
},
exact = 2,
async = false,
capacity = 5,
debug = false,
})
end
local packer = require('packer')
local use = packer.use
local lazyload = 1
packer.init({
package_root = root_dir .. '/plugged/pack',
compile_path = root_dir .. '/plugged/plugin/packer_compiled.lua',
plugin_package = 'packer',
auto_clean = false,
})
use({'wbthomason/packer.nvim', opt = true})
if lazyload == 1 then
use {'hrsh7th/nvim-cmp', event='InsertEnter', config='Cmp()'}
use {'hrsh7th/cmp-path', after='nvim-cmp'}
use {'uga-rosa/cmp-dictionary', after='nvim-cmp', config='Dict()'}
else
use {'hrsh7th/nvim-cmp'}
use {'hrsh7th/cmp-path'}
use {'uga-rosa/cmp-dictionary'}
end
if Bootstrap then
packer.sync()
end
if lazyload == 0 then
Cmp()
Dict()
end
test dictionary
Release
Debug
my config (minimal):
local dict = require("cmp_dictionary")
dict.setup({
exact = 2,
first_case_insensitive = false,
document = false,
document_command = "wn %s -over",
async = true,
sqlite = false,
max_items = 1000,
capacity = 5,
debug = false,
})
local google_10k = '/usr/share/dict/google-10000-english.txt'
filetype = {
python = {vim.g.pydiction_location, google_10k},
lua = google_10k,
},
spelllang = {
en = "/usr/share/dict/google-10000-english.txt",
},
})
• with above config when I edited a python file dictionaries seems to be loaded fine, but when I switched to a lua file during editing, items from 'python only' dictionary are also present in completion menu, am I doing something wrong with config??? or what can be done to make cmp using dictionaries set for lua while in lua buffer?
Currently, dict bindding to the file type.
Can you add an option to specify the file name to use the corresponding dict? e.g.
filename = {
["xmake.lua" ] = { "xmake.dict", "lua.dict" }
}
Some special files, not use file type.
Hello,
Thank you for your time to create this plugin.
If you want configure this plugin per filetype, I found this way:
--settings for markdown ft
--vim.opt.dictionary=vim.opt.dictionary + "......."
To use cmp-user_dictionary per filetype, you need to set the ft option in packer so cmp-user_dictionary will only load after the ftplugin. This avoids that the plugin is loaded before the dictionary is set.
use {"uga-rosa/cmp-user_dictionary",ft={"text","markdown"}}
&dictionary
.
switcher
is deprecated.paths
in require("cmp_dictionary").setup()
.:CmpDictionaryUpdate
.
paths
is set.exact
-> exact_length
max_items
-> max_number_items
document
and document_command
-> document
(single table)sqlite
option is deprecated.
external
option could help you.Hi @uga-rosa, thanks for the great work on this plugin. I have it working fine when I have keyword_length <= 2
but anything above that disables Dictionary source completion.
sources = {
{ name = "dictionary", keyword_length = 5 }
}
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
Sorry. Please check README.
cmp-dictionary/lua/cmp_dictionary/db.lua
Line 109 in 3a6035b
Possible fix is remove required?? Not quite sure tbh
I just recently built out an fzf and Rofi commands that will pull from the same dictionary I'm using with cmp-dictionary that will give me a preview of the word overview or return the overview in the case of Rofi. Here is the guide I used. https://ddrscott.github.io/blog/2017/fzf-dictionary/
It would be great if we could get that same sort of preview with cmp-dictionary. Maybe just the option to configure the preview in the setup step.
After updating cmp-dictionary, I'm getting the following Nvim startup error:
Error detected while processing /home/smsjr/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:25: attempt
to index field 'uv' (a nil value)
stack traceback:
...vim/lazy/cmp-dictionary/lua/cmp_dictionary/dict/trie.lua:25: in function 'update'
...e/nvim/lazy/cmp-dictionary/lua/cmp_dictionary/source.lua:49: in function '_update'
...nvim/lazy/cmp-dictionary/after/plugin/cmp_dictionary.lua:10: in function 'update'
...e/nvim/lazy/cmp-dictionary/lua/cmp_dictionary/config.lua:94: in function 'setup'
/home/smsjr/.config/nvim/lua/plugins/config/dictionary.lua:20: in main chunk
[C]: in function 'require'
/home/smsjr/.config/nvim/lua/plugins/init.lua:20: in main chunk
[C]: in function 'require'
/home/smsjr/.config/nvim/init.lua:30: in main chunk
Press ENTER or type command to continue
Here's my cmp-dictionary config file:
require('cmp_dictionary').setup({
paths = { '/usr/share/dict/words' },
exact_length = 2,
max_number_items = 50,
first_case_insensitive = true,
})
The file 'words' exists in the path (/usr/share/dict/words) and the cause of the error is the 'paths' config (without it, the error does not occur, but plugin does not work...).
Any help will be fully appreciated! Thx!!!
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
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 |
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,
}),
},
Hi, as the title said. my config is:
table.insert(lvim.builtin.cmp.sources, { name = 'dictionary', keyword_length = 2 })
lvim.builtin.cmp.formatting.source_names['dictionary'] = ''
lvim.plugins = {
{ 'uga-rosa/cmp-dictionary', before = 'nvim-cmp',
config = function()
require 'cmp_dictionary'.setup {
async = true,
capacity = 5,
dic = { ['*'] = '/path/to/words' }
}
end }, -- vim dictionary source for cmp
}
when i run: PackerLoad cmp-dictionary
, it reports:
Error: attempted to load cmp-dictionary which is not present in plugins table!
Error in packer_compiled: ...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:135: Error: attempted to load cmp-dictionary which is not present in plugins table!
Please check your config for correctness
Could you please take a look or correct my error, mant thanks
I have the following configuration:
require('cmp_dictionary').setup {
dic = {
['*'] = '/usr/share/dict/words',
ledger = '<secret location>/accounting/accounts.txt'
}
}
While it mostly works there are a number of issues with this configuration.
set dictionary+=asd.txt
so one can set dictionaries specific to the particular buffer.'dictionary
and 'thesaurus
is ignored :(I've been using a lot of dictionaries and have quite a few configurations for file types, frameworks, and so forth. It would be great to see the support of 'dictionary
and/or 'thesaurus
in cmp-dictionary. If that's too much work then at least accept a function instead of the string for specifying the dictionary would be very appreciated.
Hi, lovely plugin. I am configuring Neovim into an editor for prose mathematics. I am creating a dictionary of math terminology, and I'd like to use multi-word phrases in said dictionary. For example, the phrase 'finite-dimensional vector space' occurs with high frequency. I have a dictionary of such entries, possibly multi-word, separated by newlines. Right now, the plugin separates all of these into their own entries ('finite-dimensional', 'vector', 'space'). Is there a way to use such a dictionary with your plugin? I poked around for a bit and didn't see a quick way to enable such an option, though I'm not familiar with the codebase.
Howdy,
This just so happens to fill an exact need I have, but had a quick design question. I have my setup configured to add all dictionaries/wordlists to opt:dictionary as well as do something similar with opt:thesaurus (see here). I was curious if it is possible to just pull from those sources instead of having to mark them in the setup for this plugin?
When I define multiple dictionaries for ["*"]
dic = {
["*"] = { "/usr/share/dict/words", "/usr/share/dict/american-english"},
},
then I get the following exception when triggering completion in a "text" filetype.
Dictionary completion works for other filetypes (e.g., py, md).
Error detected while processing TextChangedI Autocommands for "*":
E5108: Error executing lua ...packer/start/cmp-dictionary/lua/cmp_dictionary/merge.lua:160: attempt to get length of field 'array' (a nil value)
stack traceback:
...packer/start/cmp-dictionary/lua/cmp_dictionary/merge.lua:160: in function 'merge'
.../packer/start/cmp-dictionary/lua/cmp_dictionary/init.lua:38: in function 'get_candidate'
.../packer/start/cmp-dictionary/lua/cmp_dictionary/init.lua:53: in function 'complete'
.../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:290: in function 'complete'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:250: in function 'complete'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:163: in function 'callback'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:213: in function 'autoindent'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:155: in function 'on_change'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:301: in function 'callback'
...ite/pack/packer/start/nvim-cmp/lua/cmp/utils/autocmd.lua:31: in function 'emit'
[string ":lua"]:1: in main chun
I have added several words to my general dictionary, but some of them are not displaying
dictionary
x86_64-windows
x86_64-windows-gnu
x86_64-windows-musl
x86_64-linux-gnu
x86_64-linux-musl
aarch64-linux-gnu
aarch64-linux-musl
result:
miss x86_64-windows-musl
my config:
local dict = require("cmp_dictionary")
local dict_path = g.config_dir .. "/dict/"
dict.setup({
exact = 2,
first_case_insensitive = false,
document = false,
document_command = "wn %s -over",
async = false,
sqlite = false,
max_items = -1,
capacity = 5,
debug = true,
})
dict.switcher({
filetype = {
go = { dict_path .. "go.dict" },
},
filepath = {
[".*"] = { dict_path .. "dictionary" },
[".*xmake.lua"] = { dict_path .. "xmake.dict" },
},
})
Hi,
Thanks a lot for this plugin !
Since a recent update, I noticed that my entries were duplicated when setting up a dictionary with vim.opt.dictionary
.
I tested with this minimal config. How can I correct this?
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
'uga-rosa/cmp-dictionary',
'hrsh7th/nvim-cmp',
})
local cmp = require'cmp'
local gl = vim.api.nvim_buf_get_lines
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
gl(0, line -1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = 'dictionary' },
})
})
vim.opt.dictionary = '$HOME/test.dict'
Hi, is there a way to use iskeyword fonction ?
I have a dictionary with words like \word
and another
, and it seems impossible to make the iskeyword function working.
I have already try that in my ftplugin :
vim.cmd[[set iskeyword+=\]]
and
vim.opt.iskeyword:append([[\]])
Is there a solution ?
Thanks !
Thanks !
cmp-dictionary/lua/cmp_dictionary/caches.lua
Line 167 in b60df1d
Is it on purpose you want this to return false? I only ask because it seems to me that when update is called, more often than not setup would have already been called and config wouldn't be empty?
Current config:
local dict = require("cmp_dictionary")
dict.setup({
dic = {
['gap'] = '/Users/kiryph/.vim/GAPWORDS',
},
-- The following are default values, so you don't need to write them if you don't want to change them
exact_length = 3, -- how many characters at the beginning are used as the exact match.
first_case_insensitive = false,
async = false,
debug = false,
max_nubmer_items = 0,
})
dict.switcher({
filetype = {
gap = '/Users/kiryph/.vim/GAPWORDS',
},
})
As far as I see it stopped working. No completion for gap words.
https://github.com/gap-system/gap/blob/master/etc/vim/gap.vim#L170-L173
New version complains that switcher is deprecated and I see no help in the documentation.
I have installed aspell and compile a dict from aspell.net
.
> aspell dicts | grep en
ca-general
ca-valencia
en
en-variant_0
en-variant_1
en-variant_2
en-w_accents
en-wo_accents
en_AU
en_AU-variant_0
en_AU-variant_1
en_AU-w_accents
en_AU-wo_accents
en_CA
en_CA-variant_0
en_CA-variant_1
en_CA-w_accents
en_CA-wo_accents
en_GB
en_GB-ise
en_GB-ise-w_accents
en_GB-ise-wo_accents
en_GB-ize
en_GB-ize-w_accents
en_GB-ize-wo_accents
en_GB-variant_0
en_GB-variant_1
en_GB-w_accents
en_GB-wo_accents
en_US
en_US-variant_0
en_US-variant_1
en_US-w_accents
en_US-wo_accents
fa-generic
fa-scientific
my dict directory:
> ls /usr/share/dict
README connectives propernames web2 web2a words
after update to last version, set dictionary+=xx.dict
can't work, set dict file in setup can work.
Is this a bug? Or will it only support write in setup?
Hi!
Thanks for the great plugin!
I use it with my anki word deck to use the vocabulary I'm learning. Extremely useful!
Please add LSP preview what can display a word meaning or translation.
I use two dictionaries, one for language with inflection which means number of entries is huge (4493307 vs 127466 for British English, which means it is over 35 times larger). cmp-dictionary slows down nvim startup by little more than six seconds for me.
I took a look at source, and it seems that file is read asynchronously, yet it blocks the editor. I'm using nvim v0.5.1.
async
boolean option is not explained in the help file under Options (cmp-dictionary-option).
Would be nice to know what it exactly does, if anything.
v2.0.0
dic
from setup.'dictionoary'
.switcher
, utility to switch 'dictionary'
values according to conditions.See help in details.
For example, with the cmp-path
plugin, the type (file/folder) of each choice is displayed:
Is there any way to get the source dictionary in the same way ?
For example, I have two dictionary files: path/to/dic/EN and path/to/dic/FR. I would like, instead of the Text
placeholder, have the corresponding file (EN/FR in my case) :
I don't have any dev experience in lua nor vim so I really don't know how feasible that would be based on your implementation.
Regardless, thank you for your time and efforts with this nice plugin 😃
The plugin was working fine but suddenly I got the following error msg:
Error executing luv callback:
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:139: bad argument #1 to 'decode' (string expected, got nil)
stack traceback:
[C]: in function 'decode'
...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:139: in function <...acker/start/cmp-dictionary/lua/cmp_dictionary/caches.lua:138>
I tried to use different dictionaries and reduce to few words but the error still persists.
This line of code is not clear enough to me:
aspell -d <lang> dump master | aspell -l <lang> expand > my.dict
I' m not common with aspell
What is "lang"? Also, How can I list the avalible one I have in my OS?
Each time I use the command I'm getting an error that says:
Error: The file "/usr/lib/aspell-0.60/en_US" can not be opened for reading. # What I understand as a permission error
But, in a docker container I made I get the expected long list of words from aspell
Is it possible to change loaded dictionary dynamically based filetype
change?
I've 2 workflows.
tabnnew
to create a scratch window/buffer to do some work, such as edit/format a message before sending, drop the buffer after paste the message to IM. In this case, the &filetype is an empty string. dic = {
[""] = string.format('%s/site/pack/packer/start/vim-dict/dict/text.dict',vim.fn.stdpath('data')),
["text"] = string.format('%s/site/pack/packer/start/vim-dict/dict/text.dict',vim.fn.stdpath('data')),
["javascript,typescript"] = { string.format('%s/site/pack/packer/start/vim-dict/dict/javascript.dict',vim.fn.stdpath('data')) },
["lua"] = { string.format('%s/site/pack/packer/start/vim-dict/dict/lua.dict',vim.fn.stdpath('data')) },
["vim"] = { string.format('%s/site/pack/packer/start/vim-dict/dict/vim.dict',vim.fn.stdpath('data')) },
}
nnoremap <leader>1 :set filetype=html<CR>
nnoremap <leader>2 :set filetype=javascript<CR>
nnoremap <leader>3 :set filetype=json<CR>
nnoremap <leader>4 :set filetype=sh<CR>
nnoremap <leader>5 :set filetype=sql<CR>
nnoremap <leader>6 :set filetype=vim<CR>
nnoremap <leader>7 :set filetype=txt<CR>
nnoremap <leader>8 :set filetype=lua<CR>
nnoremap <leader>9 :set filetype=tdx<CR>
nnoremap <leader>f1 :set filetype=log<CR>
nnoremap <leader>f2 :set filetype=txt<CR>
nnoremap <leader>f3 :set filetype=markdown<CR>
" Set buffer filetype
nnoremap <Leader>f= :set filetype=
For example, when I'm editing a yaml file which contains a lot of shell code, I press 4 to change the filetype to shell, take advantage of shell syntax highlighting.
After the &filetype changed, is it possible to detect the change, and load the specific dicts based on the changed filetype?
Sometimes I write prose in English, or in other languages within vim, and adjust vim's spelllang
option to get spelling corrections.
Is it possible to configure cmp-dictionary
so that the dictionary (and list of words for completion) changes, depending on what spelllang
option is set?
dic
from an option of setup.Currently, dictionaries are registered using the setup function, but this should be changed to refer to the 'dictionary' option in neovim itself.
Instead, I will add a function require('cmp_dictionary').register_dictionary
(name to be determined) to switch 'dictionary' with the same degree of freedom as before.
I have released v1.0.0 in preparation for this disruptive change.
Is it possible to auto detect and change based on input, just like this plugin did: https://github.com/skywind3000/vim-auto-popmenu
for example, the dictionary contains the word "example", if I type "exa", it will prompt a match in the dropdown list. However, if I type "Exam", there's none matched.
this is my config:
` use 'skywind3000/vim-dict'
use {
'uga-rosa/cmp-dictionary',
after='nvim-cmp',
config = function()
require('cmp_dictionary').setup ({
dic = {
["text"] = string.format('%s/site/pack/packer/start/vim-dict/dict/text.dict',vim.fn.stdpath('data')),
["javascript,typescript"] = { string.format('%s/site/pack/packer/start/vim-dict/dict/javascript.dict',vim.fn.stdpath('data')) },
["lua"] = { string.format('%s/site/pack/packer/start/vim-dict/dict/lua.dict',vim.fn.stdpath('data')) },
["vim"] = { string.format('%s/site/pack/packer/start/vim-dict/dict/vim.dict',vim.fn.stdpath('data')) },
},
exact = 2,
async = false,
capacity = 5,
debug = false,
})
end
}
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.