Expose get_selected_entry() from view module to main cmp module fixes #385 (#386)

* Expose get_selected_entry() from view module to main cmp module fixes #385

* add get_active_entry() also

* fix linting

* remove unused vars

Co-authored-by: alex.tylor <atylor@gmail.com>
This commit is contained in:
Alex Tylor
2021-10-22 09:47:55 +01:00
committed by GitHub
parent 8f92f57043
commit b546f50f09
5 changed files with 12 additions and 5 deletions

View File

@@ -1,5 +1,3 @@
local api = require('cmp.utils.api')
local mapping local mapping
mapping = setmetatable({}, { mapping = setmetatable({}, {
__call = function(_, invoke, modes) __call = function(_, invoke, modes)

View File

@@ -389,7 +389,7 @@ core.confirm = function(self, e, option, callback)
}, },
['end'] = snippet_ctx.cursor, ['end'] = snippet_ctx.cursor,
}, },
newText = '' newText = '',
} }) } })
config.get().snippet.expand({ config.get().snippet.expand({
body = completion_item.textEdit.newText, body = completion_item.textEdit.newText,

View File

@@ -49,6 +49,16 @@ cmp.visible = function()
return cmp.core.view:visible() or vim.fn.pumvisible() == 1 return cmp.core.view:visible() or vim.fn.pumvisible() == 1
end end
---Get current selected entry or nil
cmp.get_selected_entry = function()
return cmp.core.view:get_selected_entry()
end
---Get current active entry or nil
cmp.get_active_entry = function()
return cmp.core.view:get_active_entry()
end
---Close current completion ---Close current completion
cmp.close = function() cmp.close = function()
if cmp.core.view:visible() then if cmp.core.view:visible() then

View File

@@ -351,7 +351,7 @@ keymap.spec = function()
keymap.feedkeys(keymap.t('foo2'), 'n') keymap.feedkeys(keymap.t('foo2'), 'n')
keymap.feedkeys(keymap.t('bar2'), 'nt') keymap.feedkeys(keymap.t('bar2'), 'nt')
keymap.feedkeys(keymap.t('baz2'), 'n', function() keymap.feedkeys(keymap.t('baz2'), 'n', function()
vim.cmd[[normal! q]] vim.cmd([[normal! q]])
end) end)
keymap.feedkeys(keymap.t('baz1'), 'ni') keymap.feedkeys(keymap.t('baz1'), 'ni')
keymap.feedkeys(keymap.t('bar1'), 'nti') keymap.feedkeys(keymap.t('bar1'), 'nti')

View File

@@ -1,7 +1,6 @@
local cache = require('cmp.utils.cache') local cache = require('cmp.utils.cache')
local misc = require('cmp.utils.misc') local misc = require('cmp.utils.misc')
local buffer = require('cmp.utils.buffer') local buffer = require('cmp.utils.buffer')
local api = require('cmp.utils.api')
---@class cmp.WindowStyle ---@class cmp.WindowStyle
---@field public relative string ---@field public relative string