move reading lines to resolve

This commit is contained in:
Nir Tzachar 2021-09-02 12:36:15 +03:00
parent c0d3a5e3ab
commit 868f1206ff

View File

@ -149,7 +149,7 @@ source._candidates = function(_, context, dirname, offset, callback)
filterText = '/' .. name,
insertText = '/' .. name,
kind = cmp.lsp.CompletionItemKind.File,
documentation = try_get_lines(dirname .. '/' .. name, 10),
path = dirname .. '/' .. name,
})
end
end
@ -159,7 +159,7 @@ source._candidates = function(_, context, dirname, offset, callback)
filterText = '/' .. name,
insertText = '/' .. name,
kind = cmp.lsp.CompletionItemKind.File,
documentation = try_get_lines(dirname .. '/' .. name, 10),
path = dirname .. '/' .. name,
})
end
end
@ -176,5 +176,12 @@ source._is_slash_comment = function(_)
return is_slash_comment and not no_filetype
end
function source:resolve(completion_item, callback)
if completion_item.kind == cmp.lsp.CompletionItemKind.File then
completion_item.documentation = try_get_lines(completion_item.path, 10)
end
callback(completion_item)
end
return source