Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
88 lines
2.1 KiB
Lua
88 lines
2.1 KiB
Lua
local config = require("cmp_dictionary.config")
|
|
|
|
local M = {}
|
|
|
|
function M.setup(opt)
|
|
require("cmp_dictionary.config").setup(opt)
|
|
end
|
|
|
|
function M.update()
|
|
if config.get("sqlite") then
|
|
require("cmp_dictionary.db").update()
|
|
else
|
|
require("cmp_dictionary.caches").update()
|
|
end
|
|
end
|
|
|
|
---@alias dictionaries table<string, string | string[]>
|
|
---#key is a pattern, value is a value of option 'dictionary'.
|
|
|
|
---@param opt { filetype: dictionaries, filepath: dictionaries, spelllang: dictionaries }
|
|
--- Usage:
|
|
--- require("cmp_dictionary").switcher({
|
|
--- filetype = {
|
|
--- lua = "/path/to/lua.dict",
|
|
--- javascript = { "/path/to/js.dict", "/path/to/js2.dict" },
|
|
--- },
|
|
--- filepath = {
|
|
--- ["*xmake.lua"] = { "/path/to/xmake.dict", "/path/to/lua.dict" }
|
|
--- [".tmux*.conf"] = { "/path/to/js.dict", "/path/to/js2.dict" },
|
|
--- },
|
|
--- spelllang = {
|
|
--- en = "/path/to/english.dict",
|
|
--- },
|
|
-- })
|
|
function M.switcher(opt)
|
|
vim.validate({ opt = { opt, "table" } })
|
|
|
|
local id = vim.api.nvim_create_augroup("cmp_dictionary", {})
|
|
|
|
local function callback()
|
|
vim.opt_local.dictionary = {}
|
|
if opt.filetype then
|
|
vim.opt_local.dictionary:append(opt.filetype[vim.bo.filetype] or "")
|
|
end
|
|
if opt.filepath then
|
|
local fullpath = vim.fn.expand("%:p")
|
|
for path, dict in pairs(opt.filepath) do
|
|
if fullpath:find(path) then
|
|
vim.opt_local.dictionary:append(dict)
|
|
end
|
|
end
|
|
end
|
|
if opt.spelllang then
|
|
for _, sl in ipairs(vim.opt.spelllang:get()) do
|
|
vim.opt_local.dictionary:append(opt.spelllang[sl] or "")
|
|
end
|
|
end
|
|
M.update()
|
|
end
|
|
|
|
if opt.filetype then
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
group = id,
|
|
pattern = vim.tbl_keys(opt.filetype),
|
|
callback = callback,
|
|
})
|
|
end
|
|
|
|
if opt.filepath then
|
|
vim.api.nvim_create_autocmd("BufEnter", {
|
|
group = id,
|
|
callback = callback,
|
|
})
|
|
end
|
|
|
|
if opt.spelllang then
|
|
vim.api.nvim_create_autocmd("OptionSet", {
|
|
group = id,
|
|
pattern = "spelllang",
|
|
callback = callback,
|
|
})
|
|
end
|
|
|
|
callback()
|
|
end
|
|
|
|
return M
|