Comparing version 3.0.2 to 3.1.0
'use strict'; | ||
const { keywords, typeKeywords } = require('../lib/keywords'); | ||
const snippetConfig = require('./snippets.json'); | ||
/// Monaco editor configuration | ||
exports.configure = (monaco) => { | ||
exports.configure = (monaco, { snippets } = {}) => { | ||
monaco.languages.register({ id: 'motoko' }); | ||
@@ -124,2 +125,30 @@ monaco.languages.setLanguageConfiguration('motoko', { | ||
}); | ||
if (snippets) { | ||
monaco.languages.registerCompletionItemProvider('motoko', { | ||
provideCompletionItems() { | ||
return { | ||
suggestions: Object.entries(snippetConfig).map( | ||
([name, snippet]) => { | ||
return { | ||
label: | ||
typeof snippet.prefix === 'string' | ||
? snippet.prefix | ||
: snippet.prefix[0], | ||
detail: name, | ||
insertText: | ||
typeof snippet.body === 'string' | ||
? snippet.body | ||
: snippet.body.join('\n'), | ||
// insert as snippet (https://microsoft.github.io/monaco-editor/api/enums/monaco.languages.CompletionItemInsertTextRule.html) | ||
insertTextRules: 4, | ||
// snippet completion (https://microsoft.github.io/monaco-editor/api/enums/monaco.languages.CompletionItemKind.html) | ||
kind: 27, | ||
}; | ||
}, | ||
), | ||
}; | ||
}, | ||
}); | ||
} | ||
}; |
{ | ||
"name": "motoko", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "Compile and run Motoko smart contracts in Node.js or the browser.", | ||
@@ -25,3 +25,3 @@ "author": "Ryan Vandersmith (https://github.com/rvanasa)", | ||
"isomorphic-parse-github-url": "1.0.2", | ||
"sanitize-filename": "^1.6.3" | ||
"sanitize-filename": "1.6.3" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
3820923
52
2219
Updatedsanitize-filename@1.6.3