diff --git a/README.md b/README.md index 3dddf0a..ff2b6ae 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ opts = { paths = { "path_to_your_words" }, -- word source file paths. build_command = "" -- Define a Command to rebuild words, eg: `BuildDatWord`, then use `BuildDatWord!` to force rebuild cache. spellsuggest = false,-- Enable limited spellsuggest. eg: enter `thsi` give you `this`. + resolve = nil -- A source:resolve hook function. see https://cmp.saghen.dev/development/source-boilerplate.html } ``` diff --git a/lua/blink-cmp-dat-word/init.lua b/lua/blink-cmp-dat-word/init.lua index 450c808..ac8f615 100644 --- a/lua/blink-cmp-dat-word/init.lua +++ b/lua/blink-cmp-dat-word/init.lua @@ -22,10 +22,12 @@ local query = require("blink-cmp-dat-word.query") ---@field min_keyword_length? number ---@field build_command? string ---@field spellsuggest? boolean +---@field resolve? fun(item: lsp.CompletionItem, callback: fun(item: lsp.CompletionItem)) @see https://cmp.saghen.dev/development/source-boilerplate.html local default_opts = { data_file_dir = vim.fn.stdpath("data"), paths = {}, spellsuggest = false, + resolve = nil, } ---New Source. @@ -164,6 +166,12 @@ function source:get_completions(ctx, callback) }) end +function source:resolve(item, callback) + if self.opts.resolve then + self.opts.resolve(item, callback) + end +end + function source:get_config_by_key(key, default_value) if self.config == nil then return default_value