neoclide / coc-tabnine

Tabnine integration of coc.nvim
467 stars 18 forks source link

Multi-line snippet suggestions preview #87

Closed mateusz28 closed 1 year ago

mateusz28 commented 1 year ago

Hi, is there any way to preview final look of long multi-line suggestion? It looks cumbersome in preview pop-up when long snippet suggestion is present. Currently it looks like this for me: Screenshot_20230330_172635

Perfect solution would be to shorten suggestion visible in complete popup and show it similarly to coc-snippets: 54837017-62891300-4d00-11e9-9e53-49742a1a33f2

My configuration: Screenshot_20230330_172917

mateusz28 commented 1 year ago

I'll answer my own question. Field detail in tabnine request response contains percent value (probably representing accuracy). To achieve my goal I've created simple patch

diff --git a/src/index.ts b/src/index.ts
index 8578c6a..784bc3f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -198,7 +198,8 @@ export async function activate(context: ExtensionContext): Promise<void> {
     if (args.entry.documentation) {
       item.documentation = formatDocumentation(args.entry.documentation)
     }
-    item.detail = args.entry.detail ? args.entry.detail : args.detailMessage
+    //item detail shows full multiline newText content
+    item.detail = args.entry.detail ? newText : args.detailMessage
     let detail = item.detail || ''
     if (detail == DEFAULT_DETAIL || [
       'Buy a license',
@@ -223,6 +224,8 @@ export async function activate(context: ExtensionContext): Promise<void> {
     if (pre.indexOf('TabNine::') !== -1) {
       item.filterText = pre
     }
+    //label is new_prefix up to newline
+    item.label = `${new_prefix.split('\n')[0]}~`
     return item
   }

Screenshot_20230404_182825

aemonge commented 1 year ago

How can we enable this by default?