diff --git a/lib/languages.js b/lib/languages.js index 18dc5f0b7..e75be3538 100644 --- a/lib/languages.js +++ b/lib/languages.js @@ -178,8 +178,7 @@ const languages = { }, nim: { name: 'Nim', - // Make it plain text until the language definition is ready - monaco: 'text', + monaco: 'nim', extensions: ['.nim'], alias: [] } diff --git a/static/modes/nim-mode.js b/static/modes/nim-mode.js index a936e7100..9292e4215 100644 --- a/static/modes/nim-mode.js +++ b/static/modes/nim-mode.js @@ -1,4 +1,4 @@ -// Copyright (c) 2019, Matt Godbolt +// Copyright (c) 2019, Ray Imber // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -21,7 +21,119 @@ // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. + "use strict"; var monaco = require('monaco-editor'); +function definition() { + // Nim language definition + + return { + keywords: [ + "addr", "as", "asm", + "bind", "block", "break", + "case", "cast", "concept", "const", "continue", "converter", + "defer", "discard", "distinct", "div", "do", + "elif", "else", "end", "enum", "except", "export", + "finally", "for", "from", "func", + "if", "import", "include", "interface", "iterator", + "let", + "macro", "method", "mixin", "mod", + "nil", + "object", "out", + "proc", "ptr", + "raise", "ref", "return", + "static", + "template", "try", "tuple", "type", + "using", + "var", + "when", "while", + "yield" + ], + operators: [ + '=', '+', '-', '*', '/', '<', '>', + '@', '$', '~', '&', '%', '|', + '!', '?', '^', '.', ':', '\\' + ], + wordOperators: [ + 'and', 'or', 'not', 'xor', 'shl', 'shr', 'div', 'mod', 'in', 'notin', 'is', 'isnot', 'of' + ], + symbols: /[=>