-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Description
Hi!
Do you have plans to support nvim-cmp? At the moment is a bit intrusive(Because of the LSP), and it will be good to have the support natively, I'm struggling with cmp-tabnine on multi-line, and official support will be great.
The interface to add support is pretty easy, like:
local cmp = require('cmp')
local Source = {
}
function Source.new()
last_instance = setmetatable({}, { __index = Source })
last_instance:on_exit(0)
return last_instance
end
function Source.is_available(self)
return true
end
function Source.get_debug_name()
return 'TabNine'
end
function Source.complete(self, ctx, callback)
local input = string.sub(ctx.context.cursor_before_line, ctx.offset - 1)
local prefix = string.sub(ctx.context.cursor_before_line, 1, ctx.offset - 1)
local items = {}
--- Do tabnine magic here
table.insert(items, {
filterText = "TabNine magic here"
label = "TabNine magic here",
textEdit = {
newText = "Tabnine magic here" ,
range = {
start = {
line = ctx.context.cursor.row - 1,
character = ctx.context.cursor.col - 1 - #input,
},
['end'] = {
line = ctx.context.cursor.row - 1,
character = ctx.context.cursor.col - 1,
},
},
},
})
callback({
items = items,
isIncomplete = true,
})
end
cmp.register_source('cmp_tabnine', M.tabnine_source)
Here is an example video:
https://www.youtube.com/watch?v=gAsYolNrjtQ
My idea is to have nvim with tabnine and LSP playing nice :-)
Happy to do contribution in a branch, and beta-testing :-)
aemonge
Metadata
Metadata
Assignees
Labels
No labels