Skip to content

snip not work #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Shane-XB-Qian opened this issue Apr 9, 2023 · 4 comments · May be fixed by #46
Closed

snip not work #44

Shane-XB-Qian opened this issue Apr 9, 2023 · 4 comments · May be fixed by #46

Comments

@Shane-XB-Qian
Copy link

1, seems somewhere did not set for snip compl item:

item: {'label': 'for', 'data': {'type': 2}, 'kind': 15}

e.g: no insertTextFormat is 2 found.

  1. perhaps should be using 'prefix' as its label, or following patch should be required.
diff --git a/server/snippets.json b/server/snippets.json
index f7ea08b..aa3bdab 100644
--- a/server/snippets.json
+++ b/server/snippets.json
@@ -39,13 +39,13 @@
         "description": "! operator",
         "prefix": "not",
         "body": [
             "!${1:expression}"
         ]
     },
-    "compare to": {
+    "compare-to": {
         "description": "comparison operator",
         "prefix": "compare-to",
         "body": [
             "${1:expression} ${2|<,>,<=,>=,==,!=|} ${3:expression}"
         ]
     },
@@ -68,13 +68,13 @@
         "prefix": "if",
         "body": [
             "if (${1:condition})",
             "\t$0"
         ]
     },
-    "if else": {
+    "if-else": {
         "description": "if else operator",
         "prefix": "if-else",
         "body": [
             "if (${1:condition})",
             "\t${2:print}",
             "else",
@@ -87,13 +87,13 @@
         "prefix": "while",
         "body": [
             "while (${1:condition})",
             "\t$0"
         ]
     },
-    "do while": {
+    "do-while": {
         "description": "do while operator",
         "prefix": "do-while",
         "body": [
             "do",
             "\t$0",
             "while (${1:condition})"
@Beaglefoot
Copy link
Owner

Are you sure your editor supports snippets as part of LSP?

@Shane-XB-Qian
Copy link
Author

Shane-XB-Qian commented Apr 9, 2023 via email

@EmilyGraceSeville7cf
Copy link
Contributor

EmilyGraceSeville7cf commented Apr 10, 2023

What editor version do u use? Maybe I can try to reproduce the bug (or maybe it's a feature 😄). Maybe there is already such issue filled for this editor? 🤔

@Shane-XB-Qian
Copy link
Author

Shane-XB-Qian commented Apr 10, 2023

yea, i tried to debug with following, but seems difficult to make it be right though i got the snip items if so.

diff --git a/server/src/completion.ts b/server/src/completion.ts
index 1c53179..eabfd22 100644
--- a/server/src/completion.ts
+++ b/server/src/completion.ts
@@ -73,15 +73,19 @@ export function initCompletionList(docs: Documentation, snippets: Snippets): voi
       data: { type: DataEntryType.Documentation, jsonPath: `patterns.${key}` },
     })),
   )
 
   predefinedCompletionListLight.push(
     ...Object.entries(snippets).map(([title, info]) => ({
-      label: title,
+      label: info.prefix,
       kind: CompletionItemKind.Snippet,
       data: { type: DataEntryType.Snippet },
+
+      detail: info.description,
+      insertText: info.body.join('\n'),
+      insertTextFormat: InsertTextFormat.Snippet,
     })),
   )
 }
 
 export function getPredefinedCompletionItems(): AWKCompletionItem[] {
   return predefinedCompletionListLight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants