Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ 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 = function(item, callback)
callback(item) -- default

-- string
-- item.documentation = "string"
-- callback(item)

-- markdown
-- local word = item.label
-- item.documentation = {kind:"markdown", value:"#"..word.."\n"..word}
-- callback(item)

-- exec command examples
-- local word = item.label
-- vim.system({"look", word}, {}, function(res)
-- if res.code == 0 then item.documentation = res.stdout end
-- callback(item)
--end)
-- vim.system({"wn", word, "-over"}, {}, function(res)
-- if res.code == 0 then item.documentation = res.stdout end
-- callback(item)
--end)
end
}
```

Expand Down
10 changes: 10 additions & 0 deletions lua/blink-cmp-dat-word/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -164,6 +166,14 @@ function source:get_completions(ctx, callback)
})
end

function source:resolve(item, callback)
if self.opts.resolve then
self.opts.resolve(item, callback)
else
callback(item)
end
end

function source:get_config_by_key(key, default_value)
if self.config == nil then
return default_value
Expand Down
Loading