ADD: formatting.expandable_indicator to show the expandable indicator (#1207)
* ADD: formatting.expandable_indicator to show the `expandable` indicator * UPDATA: doc/cmp.txt lua/cmp/entry.lua lua/cmp/typed/cmp.lua
This commit is contained in:
@@ -451,6 +451,11 @@ confirmation.get_commit_characters~
|
||||
You can append or exclude commitCharacters via this configuration option
|
||||
function. The commitCharacters are defined by the LSP spec.
|
||||
|
||||
*cmp-config.formatting.expandable_indicator*
|
||||
formatting.expandable_indicator~
|
||||
`cmp.expandable_indicator`
|
||||
Boolean to show the `~` expandable indicator in cmp's floating window.
|
||||
|
||||
*cmp-config.formatting.fields*
|
||||
formatting.fields~
|
||||
`cmp.ItemField[]`
|
||||
|
||||
@@ -40,6 +40,7 @@ return function()
|
||||
},
|
||||
|
||||
formatting = {
|
||||
expandable_indicator = true,
|
||||
fields = { 'abbr', 'kind', 'menu' },
|
||||
format = function(_, vim_item)
|
||||
return vim_item
|
||||
|
||||
@@ -236,16 +236,17 @@ entry.get_vim_item = function(self, suggest_offset)
|
||||
local abbr = str.oneline(completion_item.label)
|
||||
|
||||
-- ~ indicator
|
||||
local is_snippet = false
|
||||
local is_expandable = false
|
||||
local expandable_indicator = config.get().formatting.expandable_indicator
|
||||
if #(misc.safe(completion_item.additionalTextEdits) or {}) > 0 then
|
||||
is_snippet = true
|
||||
is_expandable = true
|
||||
elseif completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then
|
||||
is_snippet = self:get_insert_text() ~= word
|
||||
is_expandable = self:get_insert_text() ~= word
|
||||
elseif completion_item.kind == types.lsp.CompletionItemKind.Snippet then
|
||||
is_snippet = true
|
||||
is_expandable = true
|
||||
end
|
||||
if is_snippet then
|
||||
abbr = abbr .. '~'
|
||||
if expandable_indicator and is_expandable then
|
||||
abbr = abbr .. '~'
|
||||
end
|
||||
|
||||
-- append delta text
|
||||
|
||||
@@ -133,6 +133,7 @@ cmp.ItemField = {
|
||||
|
||||
---@class cmp.FormattingConfig
|
||||
---@field public fields cmp.ItemField[]
|
||||
---@field public expandable_indicator boolean
|
||||
---@field public format fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem
|
||||
|
||||
---@class cmp.SnippetConfig
|
||||
|
||||
Reference in New Issue
Block a user