-
I try to add the nvim-cmp source cmp-dictionary but failed. Here is my config in the plugin folder. return {
{
"saghen/blink.compat",
-- use the latest release, via version = '*', if you also use the latest release for blink.cmp
version = "*",
-- lazy.nvim will automatically load the plugin when it's required by blink.cmp
lazy = true,
-- make sure to set opts so that lazy.nvim calls blink.compat's setup
opts = {},
},
{
"saghen/blink.cmp",
-- optional: provides snippets for the snippet source
dependencies = "rafamadriz/friendly-snippets",
-- use a release tag to download pre-built binaries
version = "*",
-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
-- build = 'cargo build --release',
-- If you use nix, you can build from source using latest nightly rust with:
-- build = 'nix run .#build-plugin',
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
-- 'default' for mappings similar to built-in completion
-- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
-- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
-- See the full "keymap" documentation for information on defining your own keymap.
keymap = {
-- set to 'none' to disable the 'default' preset
preset = "none",
["<C-space>"] = { "show", "show_documentation", "hide_documentation" },
["<C-e>"] = { "hide" },
["<C-y>"] = { "select_and_accept" },
["<Enter>"] = { "select_and_accept", "fallback" },
["<C-p>"] = { "select_prev", "fallback" },
["<C-n>"] = { "select_next", "fallback" },
["<C-b>"] = { "scroll_documentation_up", "fallback" },
["<C-f>"] = { "scroll_documentation_down", "fallback" },
["<Tab>"] = { "snippet_forward", "fallback" },
["<S-Tab>"] = { "snippet_backward", "fallback" },
},
appearance = {
-- Sets the fallback highlight groups to nvim-cmp's highlight groups
-- Useful for when your theme doesn't support blink.cmp
-- Will be removed in a future release
use_nvim_cmp_as_default = true,
-- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
},
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = { "lsp", "path", "snippets", "buffer" },
providers = {
-- create provider
digraphs = {
name = "dictionary", -- IMPORTANT: use the same name as you would for nvim-cmp
module = "blink.compat.source",
-- all blink.cmp source config options work as normal:
score_offset = -3,
-- this table is passed directly to the proxied completion source
-- as the `option` field in nvim-cmp's source config
--
-- this is NOT the same as the opts in a plugin's lazy.nvim spec
opts = {
-- this is an option from cmp-digraphs
keyword_length = 2,
},
},
},
},
},
opts_extend = { "sources.default" },
},
}
And I add the config in the init.lua require("cmp_dictionary").setup({
paths = { "/home/lizhe/OriNote/notes/Data/google-10000-english-no-swears.txt" },
exact_length = 2,
})
but seems not work for me. Before I add the code to the /ftplugin/markdown.lua(and text.lua) file. But I don't know how to make it now. local cmp = require("cmp")
-- 获取当前的源配置
local sources = vim.deepcopy(cmp.get_config().sources) -- 深拷贝现有源
-- 添加 dictionary 源
table.insert(sources, {
name = "dictionary",
keyword_length = 2,
})
-- 只为当前 buffer 设置配置
cmp.setup.buffer({
sources = sources,
})
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@OriLiMu Keep in mind that the CMP Dictionary is not compatible with If you're looking to use a dictionary source in
Keep in mind that the |
Beta Was this translation helpful? Give feedback.
@OriLiMu Keep in mind that the CMP Dictionary is not compatible with
blink.cmp
as it is designed only fornvim.cmp
.If you're looking to use a dictionary source in
blink.cmp
, you can use blink-cmp-dictionary.