From 1088b3743b83ffd8973ad65e6b5fed010da0ffd2 Mon Sep 17 00:00:00 2001 From: hrsh7th <629908+hrsh7th@users.noreply.github.com> Date: Sat, 27 May 2023 23:06:46 +0900 Subject: [PATCH] Add extmark inline feature detection --- lua/cmp/view/ghost_text_view.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/cmp/view/ghost_text_view.lua b/lua/cmp/view/ghost_text_view.lua index 00dbf1a..6271b43 100644 --- a/lua/cmp/view/ghost_text_view.lua +++ b/lua/cmp/view/ghost_text_view.lua @@ -9,7 +9,17 @@ local ghost_text_view = {} ghost_text_view.ns = vim.api.nvim_create_namespace('cmp:GHOST_TEXT') -local has_inline = vim.fn.has('nvim-0.10') == 1 +local has_inline, msg = (function() + return pcall(function() + local id = vim.api.nvim_buf_set_extmark(0, ghost_text_view.ns, 0, 0, { + virt_text = { { ' ', 'Comment' } }, + virt_text_pos = 'inline', + hl_mode = 'combine', + ephemeral = true, + }) + vim.api.nvim_buf_del_extmark(0, ghost_text_view.ns, id) + end) +end)() ghost_text_view.new = function() local self = setmetatable({}, { __index = ghost_text_view })