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
|
You can append or exclude commitCharacters via this configuration option
|
||||||
function. The commitCharacters are defined by the LSP spec.
|
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*
|
*cmp-config.formatting.fields*
|
||||||
formatting.fields~
|
formatting.fields~
|
||||||
`cmp.ItemField[]`
|
`cmp.ItemField[]`
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ return function()
|
|||||||
},
|
},
|
||||||
|
|
||||||
formatting = {
|
formatting = {
|
||||||
|
expandable_indicator = true,
|
||||||
fields = { 'abbr', 'kind', 'menu' },
|
fields = { 'abbr', 'kind', 'menu' },
|
||||||
format = function(_, vim_item)
|
format = function(_, vim_item)
|
||||||
return vim_item
|
return vim_item
|
||||||
|
|||||||
@@ -236,15 +236,16 @@ entry.get_vim_item = function(self, suggest_offset)
|
|||||||
local abbr = str.oneline(completion_item.label)
|
local abbr = str.oneline(completion_item.label)
|
||||||
|
|
||||||
-- ~ indicator
|
-- ~ 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
|
if #(misc.safe(completion_item.additionalTextEdits) or {}) > 0 then
|
||||||
is_snippet = true
|
is_expandable = true
|
||||||
elseif completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then
|
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
|
elseif completion_item.kind == types.lsp.CompletionItemKind.Snippet then
|
||||||
is_snippet = true
|
is_expandable = true
|
||||||
end
|
end
|
||||||
if is_snippet then
|
if expandable_indicator and is_expandable then
|
||||||
abbr = abbr .. '~'
|
abbr = abbr .. '~'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ cmp.ItemField = {
|
|||||||
|
|
||||||
---@class cmp.FormattingConfig
|
---@class cmp.FormattingConfig
|
||||||
---@field public fields cmp.ItemField[]
|
---@field public fields cmp.ItemField[]
|
||||||
|
---@field public expandable_indicator boolean
|
||||||
---@field public format fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem
|
---@field public format fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem
|
||||||
|
|
||||||
---@class cmp.SnippetConfig
|
---@class cmp.SnippetConfig
|
||||||
|
|||||||
Reference in New Issue
Block a user