From b6b15d5f6e46643462b5e62269e7babdab17331c Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Tue, 7 Sep 2021 01:38:49 +0900 Subject: [PATCH] Add experimental.ghost_text.hl_group --- lua/cmp/core.lua | 5 +++-- lua/cmp/types/cmp.lua | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/cmp/core.lua b/lua/cmp/core.lua index 70dd2f2..1ec33e9 100644 --- a/lua/cmp/core.lua +++ b/lua/cmp/core.lua @@ -36,7 +36,8 @@ core.menu = menu.new({ core.ghost_text = function(e) vim.api.nvim_buf_clear_namespace(0, core.GHOST_TEXT_NS, 0, -1) - if not config.get().experimental.ghost_text then + local c = config.get().experimental.ghost_text + if not c then return end @@ -58,7 +59,7 @@ core.ghost_text = function(e) if #text > 0 then vim.api.nvim_buf_set_extmark(ctx.bufnr, core.GHOST_TEXT_NS, ctx.cursor.row - 1, ctx.cursor.col - 1, { right_gravity = false, - virt_text = { { text, 'Comment' } }, + virt_text = { { text, c.hl_group } }, virt_text_pos = 'overlay', virt_text_win_col = ctx.virtcol - 1, priority = 1, diff --git a/lua/cmp/types/cmp.lua b/lua/cmp/types/cmp.lua index 946e938..82b9fa6 100644 --- a/lua/cmp/types/cmp.lua +++ b/lua/cmp/types/cmp.lua @@ -49,7 +49,7 @@ cmp.PreselectMode.None = 'none' ---@field private revision number ---@field public preselect cmp.PreselectMode ---@field public completion cmp.CompletionConfig ----@field public documentation cmp.DocumentationConfig +---@field public documentation cmp.DocumentationConfig|"false" ---@field public confirmation cmp.ConfirmationConfig ---@field public sorting cmp.SortingConfig ---@field public formatting cmp.FormattingConfig @@ -91,7 +91,10 @@ cmp.PreselectMode.None = 'none' ---@field on_confirm_done function(e: cmp.Entry) ---@class cmp.ExperimentalConfig ----@field public ghost_text boolean +---@field public ghost_text cmp.GhostTextConfig|"false" + +---@class cmp.GhostTextConfig +---@field hl_group string ---@class cmp.SourceConfig ---@field public name string