Browse Source

Merge pull request #36 from avelino/clojure

Clojure support
Alexandru Dima 7 years ago
parent
commit
0474b13c9d
8 changed files with 396 additions and 113 deletions
  1. 1 0
      README.md
  2. 112 112
      package-lock.json
  3. 1 0
      scripts/bundle.js
  4. 18 0
      src/clojure/clojure.contribution.ts
  5. 96 0
      src/clojure/clojure.test.ts
  6. 165 0
      src/clojure/clojure.ts
  7. 1 0
      src/monaco.contribution.ts
  8. 2 1
      test/setup.js

+ 1 - 0
README.md

@@ -5,6 +5,7 @@ Colorization and configuration supports for multiple languages for the Monaco Ed
 ![monaco-languages](https://cloud.githubusercontent.com/assets/5047891/15938606/1fd4bac6-2e74-11e6-8839-d455da8bc8a7.gif)
 
 * bat
+* clojure
 * coffee script
 * cpp
 * csharp

+ 112 - 112
package-lock.json

@@ -10,10 +10,10 @@
       "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
       "dev": true,
       "requires": {
-        "co": "4.6.0",
-        "fast-deep-equal": "1.1.0",
-        "fast-json-stable-stringify": "2.0.0",
-        "json-schema-traverse": "0.3.1"
+        "co": "^4.6.0",
+        "fast-deep-equal": "^1.0.0",
+        "fast-json-stable-stringify": "^2.0.0",
+        "json-schema-traverse": "^0.3.0"
       }
     },
     "asn1": {
@@ -59,7 +59,7 @@
       "dev": true,
       "optional": true,
       "requires": {
-        "tweetnacl": "0.14.5"
+        "tweetnacl": "^0.14.3"
       }
     },
     "boom": {
@@ -68,7 +68,7 @@
       "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=",
       "dev": true,
       "requires": {
-        "hoek": "4.2.1"
+        "hoek": "4.x.x"
       }
     },
     "brace-expansion": {
@@ -77,7 +77,7 @@
       "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
       "dev": true,
       "requires": {
-        "balanced-match": "1.0.0",
+        "balanced-match": "^1.0.0",
         "concat-map": "0.0.1"
       }
     },
@@ -111,7 +111,7 @@
       "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
       "dev": true,
       "requires": {
-        "delayed-stream": "1.0.0"
+        "delayed-stream": "~1.0.0"
       }
     },
     "commander": {
@@ -120,7 +120,7 @@
       "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
       "dev": true,
       "requires": {
-        "graceful-readlink": "1.0.1"
+        "graceful-readlink": ">= 1.0.0"
       }
     },
     "concat-map": {
@@ -141,7 +141,7 @@
       "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=",
       "dev": true,
       "requires": {
-        "boom": "5.2.0"
+        "boom": "5.x.x"
       },
       "dependencies": {
         "boom": {
@@ -150,7 +150,7 @@
           "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==",
           "dev": true,
           "requires": {
-            "hoek": "4.2.1"
+            "hoek": "4.x.x"
           }
         }
       }
@@ -167,7 +167,7 @@
       "integrity": "sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ=",
       "dev": true,
       "requires": {
-        "cssom": "0.3.2"
+        "cssom": "0.3.x"
       }
     },
     "dashdash": {
@@ -176,7 +176,7 @@
       "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
       "dev": true,
       "requires": {
-        "assert-plus": "1.0.0"
+        "assert-plus": "^1.0.0"
       }
     },
     "debug": {
@@ -206,8 +206,8 @@
       "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=",
       "dev": true,
       "requires": {
-        "domelementtype": "1.1.3",
-        "entities": "1.1.1"
+        "domelementtype": "~1.1.1",
+        "entities": "~1.1.1"
       },
       "dependencies": {
         "domelementtype": {
@@ -230,7 +230,7 @@
       "integrity": "sha1-iS5HAAqZvlW783dP/qBWHYh5wlk=",
       "dev": true,
       "requires": {
-        "domelementtype": "1.3.0"
+        "domelementtype": "1"
       }
     },
     "domutils": {
@@ -239,8 +239,8 @@
       "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==",
       "dev": true,
       "requires": {
-        "dom-serializer": "0.1.0",
-        "domelementtype": "1.3.0"
+        "dom-serializer": "0",
+        "domelementtype": "1"
       }
     },
     "ecc-jsbn": {
@@ -250,7 +250,7 @@
       "dev": true,
       "optional": true,
       "requires": {
-        "jsbn": "0.1.1"
+        "jsbn": "~0.1.0"
       }
     },
     "entities": {
@@ -301,9 +301,9 @@
       "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
       "dev": true,
       "requires": {
-        "asynckit": "0.4.0",
+        "asynckit": "^0.4.0",
         "combined-stream": "1.0.6",
-        "mime-types": "2.1.18"
+        "mime-types": "^2.1.12"
       }
     },
     "fs.realpath": {
@@ -318,7 +318,7 @@
       "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
       "dev": true,
       "requires": {
-        "assert-plus": "1.0.0"
+        "assert-plus": "^1.0.0"
       }
     },
     "glob": {
@@ -327,12 +327,12 @@
       "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=",
       "dev": true,
       "requires": {
-        "fs.realpath": "1.0.0",
-        "inflight": "1.0.6",
-        "inherits": "2.0.3",
-        "minimatch": "3.0.4",
-        "once": "1.4.0",
-        "path-is-absolute": "1.0.1"
+        "fs.realpath": "^1.0.0",
+        "inflight": "^1.0.4",
+        "inherits": "2",
+        "minimatch": "^3.0.2",
+        "once": "^1.3.0",
+        "path-is-absolute": "^1.0.0"
       }
     },
     "graceful-readlink": {
@@ -359,8 +359,8 @@
       "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
       "dev": true,
       "requires": {
-        "ajv": "5.5.2",
-        "har-schema": "2.0.0"
+        "ajv": "^5.1.0",
+        "har-schema": "^2.0.0"
       }
     },
     "has-flag": {
@@ -375,10 +375,10 @@
       "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==",
       "dev": true,
       "requires": {
-        "boom": "4.3.1",
-        "cryptiles": "3.1.2",
-        "hoek": "4.2.1",
-        "sntp": "2.1.0"
+        "boom": "4.x.x",
+        "cryptiles": "3.x.x",
+        "hoek": "4.x.x",
+        "sntp": "2.x.x"
       }
     },
     "he": {
@@ -399,12 +399,12 @@
       "integrity": "sha1-G9+HrMoPP55T+k/M6w9LTLsAszg=",
       "dev": true,
       "requires": {
-        "domelementtype": "1.3.0",
-        "domhandler": "2.4.1",
-        "domutils": "1.7.0",
-        "entities": "1.1.1",
-        "inherits": "2.0.3",
-        "readable-stream": "2.3.5"
+        "domelementtype": "^1.3.0",
+        "domhandler": "^2.3.0",
+        "domutils": "^1.5.1",
+        "entities": "^1.1.1",
+        "inherits": "^2.0.1",
+        "readable-stream": "^2.0.2"
       }
     },
     "http-signature": {
@@ -413,9 +413,9 @@
       "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
       "dev": true,
       "requires": {
-        "assert-plus": "1.0.0",
-        "jsprim": "1.4.1",
-        "sshpk": "1.13.1"
+        "assert-plus": "^1.0.0",
+        "jsprim": "^1.2.2",
+        "sshpk": "^1.7.0"
       }
     },
     "inflight": {
@@ -424,8 +424,8 @@
       "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
       "dev": true,
       "requires": {
-        "once": "1.4.0",
-        "wrappy": "1.0.2"
+        "once": "^1.3.0",
+        "wrappy": "1"
       }
     },
     "inherits": {
@@ -465,15 +465,15 @@
       "integrity": "sha1-DYvq9hDC/yOJT1Tfp/id0i/Q96s=",
       "dev": true,
       "requires": {
-        "browser-request": "0.3.3",
-        "cssom": "0.3.2",
-        "cssstyle": "0.2.37",
-        "htmlparser2": "3.9.2",
-        "nwmatcher": "1.4.3",
-        "parse5": "1.5.1",
-        "request": "2.85.0",
-        "xml-name-validator": "1.0.0",
-        "xmlhttprequest": "1.8.0"
+        "browser-request": ">= 0.3.1 < 0.4.0",
+        "cssom": ">= 0.3.0 < 0.4.0",
+        "cssstyle": ">= 0.2.21 < 0.3.0",
+        "htmlparser2": ">= 3.7.3 < 4.0.0",
+        "nwmatcher": ">= 1.3.4 < 2.0.0",
+        "parse5": ">= 1.3.1 < 2.0.0",
+        "request": ">= 2.44.0 < 3.0.0",
+        "xml-name-validator": "^1.0.0",
+        "xmlhttprequest": ">= 1.6.0 < 2.0.0"
       }
     },
     "json-schema": {
@@ -518,8 +518,8 @@
       "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=",
       "dev": true,
       "requires": {
-        "lodash._basecopy": "3.0.1",
-        "lodash.keys": "3.1.2"
+        "lodash._basecopy": "^3.0.0",
+        "lodash.keys": "^3.0.0"
       }
     },
     "lodash._basecopy": {
@@ -552,9 +552,9 @@
       "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=",
       "dev": true,
       "requires": {
-        "lodash._baseassign": "3.2.0",
-        "lodash._basecreate": "3.0.3",
-        "lodash._isiterateecall": "3.0.9"
+        "lodash._baseassign": "^3.0.0",
+        "lodash._basecreate": "^3.0.0",
+        "lodash._isiterateecall": "^3.0.0"
       }
     },
     "lodash.isarguments": {
@@ -575,9 +575,9 @@
       "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=",
       "dev": true,
       "requires": {
-        "lodash._getnative": "3.9.1",
-        "lodash.isarguments": "3.1.0",
-        "lodash.isarray": "3.0.4"
+        "lodash._getnative": "^3.0.0",
+        "lodash.isarguments": "^3.0.0",
+        "lodash.isarray": "^3.0.0"
       }
     },
     "mime-db": {
@@ -592,7 +592,7 @@
       "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
       "dev": true,
       "requires": {
-        "mime-db": "1.33.0"
+        "mime-db": "~1.33.0"
       }
     },
     "minimatch": {
@@ -601,7 +601,7 @@
       "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
       "dev": true,
       "requires": {
-        "brace-expansion": "1.1.11"
+        "brace-expansion": "^1.1.7"
       }
     },
     "minimist": {
@@ -651,7 +651,7 @@
       "integrity": "sha512-7kUx8dtd5qVNVgUARBRhnM8oftPglYwlINfigC4yGUiuzqtIN22u1tly8umiOCIPR0eFiBLjt6aN23oZh2QJgg==",
       "dev": true,
       "requires": {
-        "typescript": "2.7.2"
+        "typescript": "^2.7.2"
       }
     },
     "ms": {
@@ -678,7 +678,7 @@
       "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
       "dev": true,
       "requires": {
-        "wrappy": "1.0.2"
+        "wrappy": "1"
       }
     },
     "parse5": {
@@ -723,13 +723,13 @@
       "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
       "dev": true,
       "requires": {
-        "core-util-is": "1.0.2",
-        "inherits": "2.0.3",
-        "isarray": "1.0.0",
-        "process-nextick-args": "2.0.0",
-        "safe-buffer": "5.1.1",
-        "string_decoder": "1.0.3",
-        "util-deprecate": "1.0.2"
+        "core-util-is": "~1.0.0",
+        "inherits": "~2.0.3",
+        "isarray": "~1.0.0",
+        "process-nextick-args": "~2.0.0",
+        "safe-buffer": "~5.1.1",
+        "string_decoder": "~1.0.3",
+        "util-deprecate": "~1.0.1"
       }
     },
     "request": {
@@ -738,28 +738,28 @@
       "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==",
       "dev": true,
       "requires": {
-        "aws-sign2": "0.7.0",
-        "aws4": "1.6.0",
-        "caseless": "0.12.0",
-        "combined-stream": "1.0.6",
-        "extend": "3.0.1",
-        "forever-agent": "0.6.1",
-        "form-data": "2.3.2",
-        "har-validator": "5.0.3",
-        "hawk": "6.0.2",
-        "http-signature": "1.2.0",
-        "is-typedarray": "1.0.0",
-        "isstream": "0.1.2",
-        "json-stringify-safe": "5.0.1",
-        "mime-types": "2.1.18",
-        "oauth-sign": "0.8.2",
-        "performance-now": "2.1.0",
-        "qs": "6.5.1",
-        "safe-buffer": "5.1.1",
-        "stringstream": "0.0.5",
-        "tough-cookie": "2.3.4",
-        "tunnel-agent": "0.6.0",
-        "uuid": "3.2.1"
+        "aws-sign2": "~0.7.0",
+        "aws4": "^1.6.0",
+        "caseless": "~0.12.0",
+        "combined-stream": "~1.0.5",
+        "extend": "~3.0.1",
+        "forever-agent": "~0.6.1",
+        "form-data": "~2.3.1",
+        "har-validator": "~5.0.3",
+        "hawk": "~6.0.2",
+        "http-signature": "~1.2.0",
+        "is-typedarray": "~1.0.0",
+        "isstream": "~0.1.2",
+        "json-stringify-safe": "~5.0.1",
+        "mime-types": "~2.1.17",
+        "oauth-sign": "~0.8.2",
+        "performance-now": "^2.1.0",
+        "qs": "~6.5.1",
+        "safe-buffer": "^5.1.1",
+        "stringstream": "~0.0.5",
+        "tough-cookie": "~2.3.3",
+        "tunnel-agent": "^0.6.0",
+        "uuid": "^3.1.0"
       }
     },
     "requirejs": {
@@ -780,7 +780,7 @@
       "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==",
       "dev": true,
       "requires": {
-        "hoek": "4.2.1"
+        "hoek": "4.x.x"
       }
     },
     "source-map": {
@@ -795,14 +795,14 @@
       "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=",
       "dev": true,
       "requires": {
-        "asn1": "0.2.3",
-        "assert-plus": "1.0.0",
-        "bcrypt-pbkdf": "1.0.1",
-        "dashdash": "1.14.1",
-        "ecc-jsbn": "0.1.1",
-        "getpass": "0.1.7",
-        "jsbn": "0.1.1",
-        "tweetnacl": "0.14.5"
+        "asn1": "~0.2.3",
+        "assert-plus": "^1.0.0",
+        "bcrypt-pbkdf": "^1.0.0",
+        "dashdash": "^1.12.0",
+        "ecc-jsbn": "~0.1.1",
+        "getpass": "^0.1.1",
+        "jsbn": "~0.1.0",
+        "tweetnacl": "~0.14.0"
       }
     },
     "string_decoder": {
@@ -811,7 +811,7 @@
       "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
       "dev": true,
       "requires": {
-        "safe-buffer": "5.1.1"
+        "safe-buffer": "~5.1.0"
       }
     },
     "stringstream": {
@@ -826,7 +826,7 @@
       "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=",
       "dev": true,
       "requires": {
-        "has-flag": "1.0.0"
+        "has-flag": "^1.0.0"
       }
     },
     "tough-cookie": {
@@ -835,7 +835,7 @@
       "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
       "dev": true,
       "requires": {
-        "punycode": "1.4.1"
+        "punycode": "^1.4.1"
       }
     },
     "tunnel-agent": {
@@ -844,7 +844,7 @@
       "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
       "dev": true,
       "requires": {
-        "safe-buffer": "5.1.1"
+        "safe-buffer": "^5.0.1"
       }
     },
     "tweetnacl": {
@@ -866,8 +866,8 @@
       "integrity": "sha512-OY8VPQU25q09gQRbC+Ekk3xgEVBmYFEfVcgS47ksjTiNht2LmLlUkWutyi38ZsDSToJHwbe76kDGwmD226Z2Fg==",
       "dev": true,
       "requires": {
-        "commander": "2.14.1",
-        "source-map": "0.6.1"
+        "commander": "~2.14.1",
+        "source-map": "~0.6.1"
       },
       "dependencies": {
         "commander": {
@@ -896,9 +896,9 @@
       "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
       "dev": true,
       "requires": {
-        "assert-plus": "1.0.0",
+        "assert-plus": "^1.0.0",
         "core-util-is": "1.0.2",
-        "extsprintf": "1.3.0"
+        "extsprintf": "^1.2.0"
       }
     },
     "wrappy": {

+ 1 - 0
scripts/bundle.js

@@ -62,6 +62,7 @@ bundleOne('pgsql/pgsql');
 bundleOne('redis/redis');
 bundleOne('csp/csp');
 bundleOne('scheme/scheme');
+// bundleOne('clojure/clojure');
 
 function bundleOne(moduleId, exclude) {
 	requirejs.optimize({

+ 18 - 0
src/clojure/clojure.contribution.ts

@@ -0,0 +1,18 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+'use strict';
+
+import { registerLanguage } from '../_.contribution';
+
+// Allow for running under nodejs/requirejs in tests
+const _monaco: typeof monaco =
+    typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
+
+registerLanguage({
+    id: 'clojure',
+    extensions: ['.clj', '.clojure'],
+    aliases: ['clojure', 'Clojure'],
+    loader: () => _monaco.Promise.wrap(import('./clojure')),
+});

+ 96 - 0
src/clojure/clojure.test.ts

@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+'use strict';
+
+import { testTokenization } from '../test/testRunner';
+
+testTokenization('clojure', [
+  // Keywords
+  [
+    {
+      line: 'defmacro some',
+      tokens: [
+        { startIndex: 0, type: 'keyword.clj' },
+        { startIndex: 8, type: 'white.clj' },
+        { startIndex: 9, type: 'variable.clj' },
+      ],
+    },
+
+    {
+      line: 'comment "text comment"',
+      tokens: [
+	{ startIndex: 0, type: 'keyword.clj' },
+	{ startIndex: 7, type: 'white.clj'},
+	{ startIndex: 8, type: 'string.clj'},
+      ],
+    },
+  ],
+
+  // comments
+  [
+    {
+      line: ';; comment',
+      tokens: [{ startIndex: 0, type: 'comment.clj' }],
+    },
+  ],
+  [
+    {
+      line: '(comment',
+      tokens: [{ startIndex: 0, type: 'comment.clj' }],
+    },
+    {
+      line: '(comment let',
+      tokens: [
+        { startIndex: 0, type: 'comment.clj' },
+        { startIndex: 8, type: 'white.clj' },
+        { startIndex: 9, type: 'keyword.clj' },
+      ],
+    },
+  ],
+
+  // strings
+  [
+    {
+      line: '"\\n string "',
+      tokens: [
+        { startIndex: 0, type: 'string.clj' },
+        { startIndex: 1, type: 'string.escape.clj' },
+        { startIndex: 3, type: 'string.clj' },
+      ],
+    },
+  ],
+  [
+    {
+      line: '" string \\',
+      tokens: [{ startIndex: 0, type: 'string.clj' }],
+    },
+    {
+      line: 'multiline',
+      tokens: [{ startIndex: 0, type: 'string.clj' }],
+    },
+    {
+      line: ' ',
+      tokens: [
+        // previous line needs to be terminated with \
+        { startIndex: 0, type: 'white.clj' },
+      ],
+    },
+  ],
+
+  // numbers
+  [
+    {
+      line: '1e2',
+      tokens: [{ startIndex: 0, type: 'number.float.clj' }],
+    },
+  ],
+  [
+    {
+      line: '#x03BB',
+      tokens: [{ startIndex: 0, type: 'number.hex.clj' }],
+    },
+  ],
+]);

+ 165 - 0
src/clojure/clojure.ts

@@ -0,0 +1,165 @@
+/*---------------------------------------------------------------------------------------------
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *  Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+'use strict';
+
+import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
+import ILanguage = monaco.languages.IMonarchLanguage;
+
+export const conf: IRichLanguageConfiguration = {
+  comments: {
+    lineComment: ';;',
+    blockComment: ['(comment', ')'],
+  },
+
+  brackets: [['(', ')'], ['{', '}'], ['[', ']']],
+
+  autoClosingPairs: [
+    { open: '{', close: '}' },
+    { open: '[', close: ']' },
+    { open: '(', close: ')' },
+    { open: '"', close: '"' },
+  ],
+
+  surroundingPairs: [
+    { open: '{', close: '}' },
+    { open: '[', close: ']' },
+    { open: '(', close: ')' },
+    { open: '"', close: '"' },
+  ],
+};
+
+export const language = <ILanguage>{
+  defaultToken: '',
+  ignoreCase: true,
+  tokenPostfix: '.clj',
+
+  brackets: [
+    { open: '(', close: ')', token: 'delimiter.parenthesis' },
+    { open: '{', close: '}', token: 'delimiter.curly' },
+    { open: '[', close: ']', token: 'delimiter.square' },
+  ],
+
+  keywords: [
+    'ns',
+    'ns-unmap',
+    'fn',
+    'def',
+    'defn',
+    'defmacro',
+    'defmulti',
+    'defonce',
+    'bound\\-fn',
+    'if',
+    'if\\-not',
+    'case,',
+    'cond',
+    'condp',
+    'cond\\-\\>',
+    'cond\\-\\>\\>',
+    'when',
+    'while',
+    'when\\-not',
+    'when\\-first',
+    'do',
+    'future',
+    'comment',
+    'doto',
+    'locking',
+    'proxy',
+    'as\\-\\>',
+    'reify',
+    'deftype',
+    'defrecord',
+    'defprotocol',
+    'extend',
+    'extend-protocol',
+    'extend-type',
+    'specify',
+    'specify\\!',
+    'try',
+    'catch',
+    'finally',
+    'let',
+    'letfn',
+    'binding',
+    'loop',
+    'for',
+    'doseq',
+    'dotimes',
+    'when\\-let',
+    'if\\-let',
+    'when\\-some',
+    'if\\-some',
+    'this\\-as',
+    'defmethod',
+    'testing',
+    'deftest',
+    'are',
+    'use\\-fixtures',
+    'run',
+    'run\\*',
+    'fresh',
+    'alt!',
+    'alt!!',
+    'go',
+    'go\\-loop',
+    'thread',
+  ],
+
+  constants: ['true', 'false', 'nil'],
+
+  operators: ['=', 'not=', '<', '<=', '>', '>=', 'and', 'or', 'not', 'inc', 'dec', 'max', 'min', 'rem', 'bit-and', 'bit-or', 'bit-xor', 'bit-not'],
+
+  tokenizer: {
+    root: [
+      [/#[xXoObB][0-9a-fA-F]+/, 'number.hex'],
+      [/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
+
+      [/(?:\b(?:(def|defn|defmacro|defmulti|defonce|ns|ns-unmap|fn))\b)(\s+)((?:\w|\-|\!|\?)*)/, ['keyword', 'white', 'variable']],
+
+      [
+        /[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
+        {
+          cases: {
+            '@keywords': 'keyword',
+            '@constants': 'constant',
+            '@operators': 'operators',
+            '@default': 'identifier',
+          },
+        },
+      ],
+
+      { include: '@whitespace' },
+      { include: '@strings' },
+    ],
+
+    comment: [
+      [/[^\(comment]+/, 'comment'],
+      [/\)/, 'comment', '@push'],
+      [/\(comment/, 'comment', '@pop'],
+      [/[\)]/, 'comment'],
+    ],
+
+    whitespace: [
+      [/[ \t\r\n]+/, 'white'],
+      [/\(comment/, 'comment', '@comment'],
+      [/;;.*$/, 'comment'],
+    ],
+
+    strings: [
+      [/"$/, 'string', '@popall'],
+      [/"(?=.)/, 'string', '@multiLineString'],
+    ],
+
+    multiLineString: [
+      [/\\./, 'string.escape'],
+      [/"/, 'string', '@popall'],
+      [/.(?=.*")/, 'string'],
+      [/.*\\$/, 'string'],
+      [/.*$/, 'string', '@popall'],
+    ],
+  },
+};

+ 1 - 0
src/monaco.contribution.ts

@@ -45,3 +45,4 @@ import './vb/vb.contribution';
 import './xml/xml.contribution';
 import './yaml/yaml.contribution';
 import './scheme/scheme.contribution';
+import './clojure/clojure.contribution';

+ 2 - 1
test/setup.js

@@ -65,7 +65,8 @@ define(['require'], function (require) {
 			'release/dev/redis/redis.test',
 			'release/dev/csp/csp.test',
 			'release/dev/st/st.test',
-			'release/dev/scheme/scheme.test',
+		        'release/dev/scheme/scheme.test',
+		        'release/dev/clojure/clojure.test',
 		], function () {
 			run(); // We can launch the tests!
 		}, function (err) {