diff --git a/LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java b/LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java index 92de881..7139a23 100644 --- a/LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java +++ b/LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java @@ -41,8 +41,9 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex for(SnippetWithName elem : codeSnippetOptions.getSnippets()) { CompletionItem item = new CompletionItem(elem.getName()); - item.setKind(CompletionItemKind.Text); + item.setKind(CompletionItemKind.Snippet); item.setInsertText(elem.getSnippet()); + item.setInsertTextFormat(InsertTextFormat.Snippet); completions.add(item); } client.showMessage(new MessageParams(MessageType.Info, "Returning completion suggestions: " + completions)); diff --git a/LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java b/LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java index 865efba..43a4318 100644 --- a/LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java +++ b/LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java @@ -14,15 +14,15 @@ public class CodeSnippetOptions { } public SnippetWithName getMainSnippet(){ - return new SnippetWithName("main", "public main(args){\n System.out.println(\"Hello World\");\n}\n"); + return new SnippetWithName("main", "public main(args){\n ${1:}\n}\n"); } public SnippetWithName getForLoopSnippet(){ - return new SnippetWithName("forLoop", "for(i = 0; i < list.size(); i++){\n\n}"); + return new SnippetWithName("forLoop", "for(i = 0; i < ${1:listSize}; i++){\n\n}"); } public SnippetWithName getForEachSnippet(){ - return new SnippetWithName("forEachLoop", "for(el : list){\n\n}"); + return new SnippetWithName("forEachLoop", "for(el : ${1:listSize}){\n\n}"); } public ArrayList getSnippets() {