From 962a45ac08d6a676863f035f01597685d379f8ec Mon Sep 17 00:00:00 2001 From: Cullie Date: Mon, 24 May 2021 16:30:13 +1000 Subject: [PATCH] #22 - variable auto-complete example --- src/YarnSpinner/yarnSpinnerMonarch.js | 39 ++++++++++----------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/YarnSpinner/yarnSpinnerMonarch.js b/src/YarnSpinner/yarnSpinnerMonarch.js index e32d62d..5352686 100644 --- a/src/YarnSpinner/yarnSpinnerMonarch.js +++ b/src/YarnSpinner/yarnSpinnerMonarch.js @@ -7,35 +7,10 @@ /* Currently unable to import .ts file into renderer, likely a webpack issue. https://webpack.js.org/guides/typescript/ * Monaco Custom Language Documentation: https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages - * Yarn Spinner Documentation: https://yarnspinner.dev/docs/syntax/ * JS RegExp Documentation: https://www.w3schools.com/jsref/jsref_obj_regexp.asp * Typescript TokensProvider: https://github.com/microsoft/monaco-languages/blob/main/src/typescript/typescript.ts */ import * as monaco from 'monaco-editor'; - -/* -file - -header - -body - commands -x strings -x keywords -x variables -x numbers -x operators - >> pop - options -x text -x interpolation -x commands - 3 - dialogue -x commands -x interpolation -*/ - //Exports configuration monaco/monarch tokenisation for Yarn Spinner export const tokensWIP = { @@ -376,6 +351,20 @@ export const completions = { documentation: 'Create new node', insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, }]; + + var word = "test" //model.getValueInRange({startLineNumber: 1, startColumn: 1, endLineNumber: position.lineNumber, endColumn: position.column}); + + var match = word.match(/[A-Za-z_]+[\.]*[A-Za-z_]*/); + + if(match) + { + suggestions.push( + {label: word, + kind: monaco.languages.CompletionItemKind.Snippet, + insertText: word, + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,} + ); + } return { suggestions: suggestions }; } }; \ No newline at end of file