From 868f1206ff209ae280ecae4b440b470c80523f3d Mon Sep 17 00:00:00 2001 From: Nir Tzachar Date: Thu, 2 Sep 2021 12:36:15 +0300 Subject: [PATCH] move reading lines to resolve --- lua/cmp_path/init.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/cmp_path/init.lua b/lua/cmp_path/init.lua index 18d329f..f57325b 100644 --- a/lua/cmp_path/init.lua +++ b/lua/cmp_path/init.lua @@ -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