From 161cd394e5a5cbb05785ef5594529681b59dbced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=CC=88l=20Galeran?= Date: Fri, 27 Jan 2023 11:43:51 +0100 Subject: [PATCH] feat(ls): completion for nanoid() Part of: https://github.com/prisma/prisma/issues/17199 Note: we want to wait until all the work is done (see issue) before merging this. --- .../language-server/src/__test__/completion.test.ts | 10 +++++++--- .../language-server/src/completion/completions.ts | 11 ++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/language-server/src/__test__/completion.test.ts b/packages/language-server/src/__test__/completion.test.ts index 7baed9a767..6fa201885c 100644 --- a/packages/language-server/src/__test__/completion.test.ts +++ b/packages/language-server/src/__test__/completion.test.ts @@ -2049,6 +2049,10 @@ suite('Completions', function () { kind: CompletionItemKind.Property, } + const functionNanoid = { + label: 'nanoid()', + kind: CompletionItemKind.Function, + } const functionCuid = { label: 'cuid()', kind: CompletionItemKind.Function, @@ -2416,7 +2420,7 @@ suite('Completions', function () { }`, expected: { isIncomplete: false, - items: [functionDbGenerated, functionUuid, functionCuid], + items: [functionDbGenerated, functionUuid, functionCuid, functionNanoid], }, }) }) @@ -2493,7 +2497,7 @@ suite('Completions', function () { }`, expected: { isIncomplete: false, - items: [functionAuto, functionUuid, functionCuid], + items: [functionAuto, functionUuid, functionCuid, functionNanoid], }, }) }) @@ -2533,7 +2537,7 @@ suite('Completions', function () { }`, expected: { isIncomplete: false, - items: [functionAuto, functionUuid, functionCuid], + items: [functionAuto, functionUuid, functionCuid, functionNanoid], }, }) }) diff --git a/packages/language-server/src/completion/completions.ts b/packages/language-server/src/completion/completions.ts index 9317f649f7..e9cc76e092 100644 --- a/packages/language-server/src/completion/completions.ts +++ b/packages/language-server/src/completion/completions.ts @@ -676,7 +676,16 @@ function getDefaultValues({ documentation: { kind: MarkupKind.Markdown, value: - 'Generate a globally unique identifier based on the [cuid](https://github.com/ericelliott/cuid) spec.', + 'Generate a globally unique identifier based on the [cuid]https://github.com/paralleldrive/cuid) spec.', + }, + }, + { + label: 'nanoid()', + kind: CompletionItemKind.Function, + documentation: { + kind: MarkupKind.Markdown, + value: + 'Generate a tiny, secure, URL-friendly, unique identifier based on the [nanoid](https://github.com/ai/nanoid) spec.', }, }, )