Add formatting.deprecated option

This commit is contained in:
hrsh7th
2021-08-24 22:59:39 +09:00
parent fc31a7e8ef
commit 2f0f5f3a91
4 changed files with 13 additions and 2 deletions

View File

@@ -195,6 +195,13 @@ vim's `completeopt` setting. Warning: Be careful when changing this value.
Default: `menu,menuone,noselect`
### formatting.deprecated (type: boolean)
Specify deprecated candidate should be marked as deprecated or not.
Default: `true`
### formatting.format (type: fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem)
A function to customize completion menu.

View File

@@ -51,6 +51,7 @@ return function()
mapping = {},
formatting = {
deprecated = true,
format = function(_, vim_item)
return vim_item
end

View File

@@ -204,9 +204,11 @@ entry.get_vim_item = function(self, suggest_offset)
end
-- deprecated
if config.get().formatting.deprecated then
if completion_item.deprecated or vim.tbl_contains(completion_item.tags or {}, types.lsp.CompletionItemTag.Deprecated) then
abbr = str.strikethrough(abbr)
end
end
-- append delta text
if suggest_offset < self:get_offset() then

View File

@@ -75,6 +75,7 @@ cmp.ScrollDirection.Down = 'down'
---@field public comparators function[]
---@class cmp.FormattingConfig
---@field public deprecated boolean
---@field public format fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem
---@class cmp.SnippetConfig