├── .gitignore ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── highlightjs-nelua.js ├── language-configuration.json ├── package.json ├── syntaxes ├── codeblock.json └── nelua.tmLanguage.json └── vsc-extension-quickstart.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "nelua" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nelua vscode 2 | 3 | Nelua syntax highlighting for Visual Studio Code. 4 | 5 | ## Installing 6 | 7 | Clone this repository into ~/.vscode/extensions/ and restart vscode. -------------------------------------------------------------------------------- /highlightjs-nelua.js: -------------------------------------------------------------------------------- 1 | var module = module ? module : {}; // shim for browser use 2 | 3 | function hljsDefineNelua(hljs) { 4 | hljs.registerLanguage("nelua", function(e) { 5 | var OPENING_LONG_BRACKET = "\\[=*\\[", 6 | CLOSING_LONG_BRACKET = "\\]=*\\]", 7 | LONG_BRACKETS = { 8 | b: OPENING_LONG_BRACKET, 9 | e: CLOSING_LONG_BRACKET, 10 | c: ["self"] 11 | }, 12 | COMMENTS = [ 13 | e.C("--(?!" + OPENING_LONG_BRACKET + ")", "$"), 14 | e.C("--" + OPENING_LONG_BRACKET, 15 | CLOSING_LONG_BRACKET, { 16 | c: [LONG_BRACKETS], 17 | r: 10 18 | }) 19 | ]; 20 | return { 21 | l:e.UIR, k: { 22 | literal: "true false nil nilptr", 23 | keyword: 24 | //Lua 25 | "function and break do else elseif end for goto if in local not or repeat return then until while " + 26 | //Extended lua 27 | "switch case continue defer global" 28 | , 29 | built_in: 30 | //Metatags and globals: 31 | '_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len ' + 32 | '__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert ' + 33 | //Standard methods and properties: 34 | 'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring' + 35 | 'module next pairs pcall print rawequal rawget rawset require select setfenv' + 36 | 'setmetatable tonumber tostring type unpack xpcall arg self ' + 37 | //Library methods and properties (one line per library): 38 | 'coroutine resume status wrap create running debug getupvalue ' + 39 | 'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv ' + 40 | 'io lines write close flush open output type read stderr stdin input stdout popen tmpfile ' + 41 | 'math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan ' + 42 | 'os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall ' + 43 | 'string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower ' + 44 | 'table setn insert getn foreachi maxn foreach concat sort remove ' + 45 | //Extended lua 46 | 'char uchar int uint int16 uint16 int32 uint32 int64 uint64 ' + 47 | 'isize usize float double ptr typed untyped ' + 48 | 'void ' 49 | }, 50 | c:COMMENTS.concat([ 51 | e.CNM, 52 | e.ASM, 53 | e.QSM, 54 | { 55 | cN: "string", 56 | b: OPENING_LONG_BRACKET, 57 | e: CLOSING_LONG_BRACKET, 58 | c: [LONG_BRACKETS], 59 | r: 5 60 | } 61 | ]) 62 | } 63 | }); 64 | } 65 | 66 | module.exports = function(hljs) { 67 | hljs.registerLanguage('nelua', hljsDefineNelua); 68 | }; 69 | 70 | module.exports.definer = hljsDefineNelua; -------------------------------------------------------------------------------- /language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "--", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | "blockComment": [ "--[[", "--" ] 7 | }, 8 | // symbols used as brackets 9 | "brackets": [ 10 | ["{", "}"], 11 | ["[", "]"], 12 | ["(", ")"] 13 | ], 14 | // symbols that are auto closed when typing 15 | "autoClosingPairs": [ 16 | ["{", "}"], 17 | ["[", "]"], 18 | ["(", ")"], 19 | ["\"", "\""], 20 | ["'", "'"] 21 | ], 22 | // symbols that that can be used to surround a selection 23 | "surroundingPairs": [ 24 | ["{", "}"], 25 | ["[", "]"], 26 | ["(", ")"], 27 | ["\"", "\""], 28 | ["'", "'"] 29 | ] 30 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nelua", 3 | "displayName": "nelua", 4 | "description": "Nelua programming language syntax", 5 | "version": "0.0.1", 6 | "engines": { 7 | "vscode": "^1.31.0" 8 | }, 9 | "categories": [ 10 | "Programming Languages" 11 | ], 12 | "contributes": { 13 | "markdown.previewScripts": ["./highlightjs-nelua.js"], 14 | "languages": [{ 15 | "id": "nelua", 16 | "aliases": ["Nelua", "nelua"], 17 | "extensions": [".nelua"], 18 | "configuration": "./language-configuration.json" 19 | }], 20 | "grammars": [{ 21 | "language": "nelua", 22 | "scopeName": "source.nelua", 23 | "path": "./syntaxes/nelua.tmLanguage.json" 24 | }, { 25 | "scopeName": "markdown.nelua.codeblock", 26 | "path": "./syntaxes/codeblock.json", 27 | "injectTo": [ 28 | "text.html.markdown" 29 | ], 30 | "embeddedLanguages": { 31 | "meta.embedded.block.nelua": "nelua" 32 | } 33 | }] 34 | } 35 | } -------------------------------------------------------------------------------- /syntaxes/codeblock.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileTypes": [], 3 | "injectionSelector": "L:text.html.markdown", 4 | "patterns": [ 5 | { 6 | "include": "#fenced_code_block_nelua" 7 | } 8 | ], 9 | "repository": { 10 | "fenced_code_block_nelua": { 11 | "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(nelua)(\\s+[^`~]*)?$)", 12 | "beginCaptures": { 13 | "3": { 14 | "name": "punctuation.definition.markdown" 15 | }, 16 | "5": { 17 | "name": "fenced_code.block.language" 18 | }, 19 | "6": { 20 | "name": "fenced_code.block.language.attributes" 21 | } 22 | }, 23 | "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", 24 | "endCaptures": { 25 | "3": { 26 | "name": "punctuation.definition.markdown" 27 | } 28 | }, 29 | "name": "markup.fenced_code.block.markdown", 30 | "patterns": [ 31 | { 32 | "begin": "(^|\\G)(\\s*)(.*)", 33 | "contentName": "meta.embedded.block.nelua", 34 | "patterns": [ 35 | { 36 | "include": "source.nelua" 37 | } 38 | ], 39 | "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)" 40 | } 41 | ] 42 | } 43 | }, 44 | "scopeName": "markdown.nelua.codeblock" 45 | } -------------------------------------------------------------------------------- /syntaxes/nelua.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "Nelua", 4 | "scopeName": "source.nelua", 5 | "patterns": [ 6 | { 7 | "begin": "\\b(?:(local)\\s+)?(function)\\s*(?:\\s+([a-zA-Z_][a-zA-Z0-9_]*(?:([\\.:])[a-zA-Z_][a-zA-Z0-9_]*)?)\\s*)?(\\()", 8 | "beginCaptures": { 9 | "1": { 10 | "name": "storage.modifier.local.nelua" 11 | }, 12 | "2": { 13 | "name": "keyword.control.nelua" 14 | }, 15 | "3": { 16 | "name": "entity.name.function.nelua" 17 | }, 18 | "4": { 19 | "name": "punctuation.separator.parameter.nelua" 20 | }, 21 | "5": { 22 | "name": "punctuation.definition.parameters.begin.nelua" 23 | } 24 | }, 25 | "end": "\\)", 26 | "endCaptures": { 27 | "0": { 28 | "name": "punctuation.definition.parameters.end.nelua" 29 | } 30 | }, 31 | "name": "meta.function.nelua", 32 | "patterns": [ 33 | { 34 | "match": "[a-zA-Z_][a-zA-Z0-9_]*", 35 | "name": "variable.parameter.function.nelua" 36 | }, 37 | { 38 | "match": ",", 39 | "name": "punctuation.separator.arguments.nelua" 40 | } 41 | ] 42 | }, 43 | { 44 | "match": "(?=?|(?/.vscode/extensions` folder and restart Code. 29 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 30 | --------------------------------------------------------------------------------