├── .gitignore
├── .travis.yml
├── README.md
├── src
└── mode
│ ├── meta.js
│ └── abap
│ ├── index.html
│ └── abap.js
├── Makefile
├── rollup.config.js
├── .github
└── workflows
│ └── publish.yml
├── package.json
├── LICENSE
└── .eslintrc.js
/.gitignore:
--------------------------------------------------------------------------------
1 | lib/
2 | node_modules/
3 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "6"
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CodeMirror contributions
2 |
3 | CodeMirror community contributions as used by GitHub.
4 |
--------------------------------------------------------------------------------
/src/mode/meta.js:
--------------------------------------------------------------------------------
1 | import CodeMirror from "codemirror/lib/codemirror"
2 | import "codemirror/mode/meta"
3 |
4 | CodeMirror.modeInfo.push({name: "ABAP", mime: "text/abap", mode: "abap", ext: ["abap"], contrib: true})
5 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | all: \
2 | lib/mode/meta.js \
3 | lib/mode/abap/abap.js
4 |
5 | lib/%.js: src/%.js
6 | mkdir -p $(@D)
7 | node_modules/.bin/rollup --config rollup.config.js $< > $@
8 |
9 | lint:
10 | ./node_modules/.bin/eslint src/
11 |
12 | test: all lint
13 |
14 | clean:
15 | git clean -fdx lib/
16 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import buble from 'rollup-plugin-buble'
2 |
3 | export default {
4 | format: 'umd',
5 | external: [
6 | 'codemirror/lib/codemirror',
7 | 'codemirror/mode/meta'
8 | ],
9 | globals: {
10 | 'codemirror/lib/codemirror': 'CodeMirror',
11 | 'codemirror/mode/meta': 'undefined'
12 | },
13 | paths: {
14 | 'codemirror': 'codemirror/lib/codemirror'
15 | },
16 | plugins: [buble()]
17 | }
18 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | release:
5 | types: [created]
6 |
7 | permissions:
8 | contents: read
9 | id-token: write
10 |
11 | jobs:
12 | publish-npm:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: actions/setup-node@v4
17 | with:
18 | node-version: 22
19 | registry-url: https://registry.npmjs.org/
20 | cache: npm
21 | - run: npm ci
22 | - run: npm test
23 | - run: npm version ${TAG_NAME} --git-tag-version=false
24 | env:
25 | TAG_NAME: ${{ github.event.release.tag_name }}
26 | - run: npm whoami; npm --ignore-scripts publish --provenance
27 | env:
28 | NODE_AUTH_TOKEN: ${{secrets.npm_token}}
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "codemirror-contrib",
3 | "version": "0.1.3",
4 | "description": "CodeMirror community contributions",
5 | "scripts": {
6 | "build": "make all",
7 | "prepublish": "make clean all",
8 | "test": "make test"
9 | },
10 | "files": [
11 | "lib",
12 | "src"
13 | ],
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/github/codemirror-contrib.git"
17 | },
18 | "keywords": [
19 | "CodeMirror"
20 | ],
21 | "author": "GitHub, Inc",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/github/codemirror-contrib/issues"
25 | },
26 | "homepage": "https://github.com/github/codemirror-contrib#readme",
27 | "dependencies": {
28 | "codemirror": "^5.19.0"
29 | },
30 | "devDependencies": {
31 | "eslint": "^3.7.1",
32 | "rollup-plugin-buble": "^0.14.0",
33 | "rollup": "^0.36.1"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 GitHub, Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/src/mode/abap/index.html:
--------------------------------------------------------------------------------
1 |
2 |
CodeMirror: ABAP mode
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
17 |
18 |
19 | ABAP mode
20 |
25 |
26 |
33 |
34 | MIME types defined: text/abap (ABAP code)
35 |
36 |
--------------------------------------------------------------------------------
/src/mode/abap/abap.js:
--------------------------------------------------------------------------------
1 | // converted to JavaScript from https://github.com/larshp/codemirror-abap
2 | // Author: Lars Hvam
3 | // Original Author: Lars Hvam
4 |
5 | import CodeMirror from "codemirror/lib/codemirror";
6 |
7 | CodeMirror.defineMode("abap", () => {
8 | const COMMENT = "comment";
9 | const STRING = "string";
10 | const NUMBER = "number";
11 | const KEYWORD = "keyword";
12 | const OPERATOR = "operator";
13 | const ERROR = "error";
14 |
15 | function setupKeywords(str) {
16 | let list = str.split(" ");
17 | let ret = {};
18 | for (let i = 0; i < list.length; ++i) {
19 | ret[list[i]] = true;
20 | }
21 | return ret;
22 | }
23 |
24 | var keywords = setupKeywords("IS NOT EQ GE GT REF " +
25 | "AND ALIAS ALIASES APPEND ASCENDING ASSERT ASSIGN ASSIGNING " +
26 | "BACK BEGIN BINARY BLOCK BOUND BY BYTE " +
27 | "CALL CHANGING CHECK CLEAR CLOSE CNT COLLECT COMMIT CHARACTER " +
28 | "CORRESPONDING COMMUNICATION COMPONENT COMPUTE CONCATENATE CONDENSE CONSTANTS " +
29 | "CONTROLS CONVERT CREATE CURRENCY " +
30 | "DATA DESCENDING DEFAULT DEFINE DEFINITION DEFERRED DELETE DESCRIBE DETAIL DIVIDE DURATION " +
31 | "DELETING " +
32 | "END ENDEXEC ENDFUNCTION " +
33 | "ENDCLASS ENDMETHOD ENDFORM " +
34 | "CLASS METHOD FORM " +
35 | "ENDINTERFACE ENDMODULE " +
36 | "ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT " +
37 | "EXPORTING EXTRACT EXCEPTION EXCEPTIONS " +
38 | "FRAME FETCH FIELDS FINAL FORMAT FREE FROM FUNCTION FIND FOR " +
39 | "GENERATE " +
40 | "HARMLESS HIDE " +
41 | "IMPORT IMPORTING INDEX INFOTYPES INITIAL INITIALIZATION " +
42 | "INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION INTO " +
43 | "LEAVE LEVEL LIKE LINE LOAD LOCAL LENGTH LEFT LEADING " +
44 | "METHOD MESSAGE METHODS MODIFY MODULE MOVE MULTIPLY MATCH " +
45 | "NEW " +
46 | "OBJECT OBLIGATORY OVERLAY OPTIONAL OTHERS OCCURRENCES OCCURS OFFSET " +
47 | "PACK PARAMETERS PERFORM POSITION PRIVATE PROGRAM PROTECTED PROVIDE PUBLIC " +
48 | "RADIOBUTTON RAISING RANGES RECEIVE RECEIVING REDEFINITION REF " +
49 | "REFERENCE REFRESH REGEX REJECT RESULTS " +
50 | "REPLACE REPORT RESERVE RESTORE RETURN RETURNING RISK ROLLBACK READ " +
51 | "SCAN SCROLL SEARCH SELECT SEPARATED SHIFT SHORT SINGLE SKIP SORT SORTED SPLIT STANDARD " +
52 | "STATICS STEP STOP STRUCTURE SUBMATCHES SUBMIT SUBTRACT SUMMARY SUPPRESS SECTION " +
53 | "TABLES TABLE TESTING TIMES TITLE TITLEBAR TO TRANSFER TRANSFORMATION TRANSLATE TYPES TYPE " +
54 | "UNASSIGN ULINE UNPACK UPDATE USING " +
55 | "VALUE " +
56 | "WHEN WHILE WINDOW WRITE WHERE WITH " +
57 | "ADD-CORRESPONDING AUTHORITY-CHECK " +
58 | "BREAK-POINT CLASS-DATA " +
59 | "CLASS-METHOD CLASS-METHODS " +
60 | "DIVIDE-CORRESPONDING DISPLAY DISPLAY-MODE " +
61 | "EDITOR-CALL END-OF-DEFINITION END-OF-PAGE END-OF-SELECTION " +
62 | "FIELD-GROUPS FIELD-SYMBOLS " +
63 | "FUNCTION-POOL LEFT-JUSTIFIED LINE-COUNT LINE-SIZE " +
64 | "MESSAGE-ID MOVE-CORRESPONDING MULTIPLY-CORRESPONDING " +
65 | "NEW-LINE NEW-PAGE NEW-SECTION " +
66 | "NO-GAP NO-SIGN " +
67 | "NO-ZERO PRINT-CONTROL " +
68 | "READ-ONLY RIGHT-JUSTIFIED " +
69 | "SELECT-OPTIONS SELECTION-SCREEN START-OF-SELECTION " +
70 | "SUBTRACT-CORRESPONDING SYNTAX-CHECK " +
71 | "SYNTAX-TRACE SYSTEM-CALL TOP-OF-PAGE TYPE-POOL TYPE-POOLS " +
72 | "AT CASE CATCH CONTINUE DO ELSEIF ELSE ENDAT ENDCASE ENDDO ENDIF " +
73 | "ENDLOOP ENDON IF LOOP ON RAISE TRY WORK");
74 |
75 | function isKeyword(stream) {
76 | let next = stream.next();
77 | let back = 0;
78 | while (true) {
79 | if (!next) {
80 | break;
81 | } else if (next === " " || next === "." || next === "," || next === ":") {
82 | stream.backUp(1);
83 | break;
84 | } else {
85 | back++;
86 | }
87 | next = stream.next();
88 | }
89 |
90 | let match = keywords.propertyIsEnumerable(stream.current().toUpperCase());
91 | if (match === false) {
92 | stream.backUp(back);
93 | }
94 | return match;
95 | }
96 |
97 | function isOperator(str) {
98 | const OPERATORS = "?= = > <> < + - * / &&";
99 |
100 | str = str.trim();
101 |
102 | let list = OPERATORS.split(" ");
103 |
104 | for (let i = 0; i < list.length; i++) {
105 | if (str === list[i]) {
106 | return true;
107 | }
108 | }
109 | return false;
110 | }
111 |
112 | return {
113 | startState: function() {
114 | return {
115 | mode: false
116 | };
117 | },
118 | token: function(stream, state) {
119 | if (stream.eatSpace()) {
120 | return undefined;
121 | }
122 |
123 | if (isKeyword(stream)) {
124 | return KEYWORD;
125 | } else if (stream.match(/^\d+( |\.|$)/, false)) {
126 | stream.match(/^\d+/);
127 | return NUMBER;
128 | } else if (stream.match(/^##\w+/)) {
129 | // pragmas
130 | return COMMENT;
131 | }
132 |
133 | let ch = stream.next();
134 | let peek = stream.peek();
135 | if (peek === undefined) {
136 | peek = "";
137 | }
138 |
139 | if ((ch === "*" && stream.column() === 0) || ch === "\"") {
140 | stream.skipToEnd();
141 | return COMMENT;
142 | } else if (isOperator(ch + peek)) {
143 | if (peek !== " ") {
144 | stream.next();
145 | }
146 | return OPERATOR;
147 | } else if (ch === "\'") {
148 | let next = "";
149 | while (next !== undefined) {
150 | if (next === "\'") {
151 | state.mode = false;
152 | break;
153 | }
154 | next = stream.next();
155 | }
156 | return STRING;
157 | } else if (ch === "|") {
158 | let next = "";
159 | while (next !== undefined) {
160 | if (next === "|") {
161 | state.mode = false;
162 | break;
163 | }
164 | next = stream.next();
165 | }
166 | return STRING;
167 | } else {
168 | stream.eatWhile(/(\w|<|>)/);
169 | return ERROR;
170 | }
171 | }
172 | };
173 | });
174 |
175 | CodeMirror.defineMIME("text/abap", "abap");
176 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // Generated ESLint config from CodeMirror style
2 | //
3 | // $ cd CodeMirror
4 | // $ eslint --init
5 | // ? How would you like to configure ESLint? Inspect your JavaScript file(s)
6 | // ? Which file(s), path(s), or glob(s) should be examined? src
7 | // ? What format do you want your config file to be in? JavaScript
8 | // ? Are you using ECMAScript 6 features? Yes
9 | // ? Are you using ES6 modules? Yes
10 | // ? Where will your code run? Browser
11 | // ? Do you use CommonJS? No
12 | // ? Do you use JSX? No
13 |
14 | module.exports = {
15 | "env": {
16 | "browser": true,
17 | "es6": true
18 | },
19 | "extends": "eslint:recommended",
20 | "parserOptions": {
21 | "sourceType": "module"
22 | },
23 | "rules": {
24 | "accessor-pairs": "error",
25 | "array-bracket-spacing": [
26 | "error",
27 | "never"
28 | ],
29 | "array-callback-return": "error",
30 | "arrow-body-style": "error",
31 | "arrow-parens": [
32 | "error",
33 | "as-needed"
34 | ],
35 | "arrow-spacing": [
36 | "error",
37 | {
38 | "after": true,
39 | "before": true
40 | }
41 | ],
42 | "block-scoped-var": "error",
43 | "block-spacing": "off",
44 | "brace-style": "off",
45 | "callback-return": "error",
46 | "camelcase": "off",
47 | "class-methods-use-this": "error",
48 | "comma-dangle": "error",
49 | "comma-spacing": [
50 | "error",
51 | {
52 | "after": true,
53 | "before": false
54 | }
55 | ],
56 | "comma-style": [
57 | "error",
58 | "last"
59 | ],
60 | "complexity": "off",
61 | "computed-property-spacing": [
62 | "error",
63 | "never"
64 | ],
65 | "consistent-return": "off",
66 | "consistent-this": "off",
67 | "curly": "off",
68 | "default-case": "off",
69 | "dot-location": [
70 | "error",
71 | "property"
72 | ],
73 | "dot-notation": [
74 | "error",
75 | {
76 | "allowKeywords": false
77 | }
78 | ],
79 | "eol-last": "error",
80 | "eqeqeq": "off",
81 | "func-call-spacing": "error",
82 | "func-names": [
83 | "error",
84 | "never"
85 | ],
86 | "func-style": "off",
87 | "generator-star-spacing": "error",
88 | "global-require": "error",
89 | "guard-for-in": "off",
90 | "handle-callback-err": "error",
91 | "id-blacklist": "error",
92 | "id-length": "off",
93 | "id-match": "error",
94 | "indent": "off",
95 | "init-declarations": "off",
96 | "jsx-quotes": "error",
97 | "key-spacing": "error",
98 | "keyword-spacing": "off",
99 | "line-comment-position": "off",
100 | "linebreak-style": [
101 | "error",
102 | "unix"
103 | ],
104 | "lines-around-comment": "error",
105 | "lines-around-directive": "error",
106 | "max-depth": "off",
107 | "max-len": "off",
108 | "max-lines": "off",
109 | "max-nested-callbacks": "error",
110 | "max-params": "off",
111 | "max-statements": "off",
112 | "max-statements-per-line": "off",
113 | "multiline-ternary": "off",
114 | "new-parens": "off",
115 | "newline-after-var": "off",
116 | "newline-before-return": "off",
117 | "newline-per-chained-call": "off",
118 | "no-alert": "error",
119 | "no-array-constructor": "error",
120 | "no-bitwise": "off",
121 | "no-caller": "error",
122 | "no-catch-shadow": "off",
123 | "no-confusing-arrow": "off",
124 | "no-constant-condition": [
125 | "error",
126 | {
127 | "checkLoops": false
128 | }
129 | ],
130 | "no-continue": "off",
131 | "no-div-regex": "error",
132 | "no-duplicate-imports": [
133 | "error",
134 | {
135 | "includeExports": false
136 | }
137 | ],
138 | "no-else-return": "off",
139 | "no-empty-function": "off",
140 | "no-eq-null": "off",
141 | "no-eval": "error",
142 | "no-extend-native": "error",
143 | "no-extra-bind": "error",
144 | "no-extra-label": "error",
145 | "no-extra-parens": "off",
146 | "no-floating-decimal": "off",
147 | "no-global-assign": "error",
148 | "no-implicit-globals": "error",
149 | "no-implied-eval": "error",
150 | "no-inline-comments": "off",
151 | "no-inner-declarations": [
152 | "error",
153 | "functions"
154 | ],
155 | "no-invalid-this": "off",
156 | "no-iterator": "error",
157 | "no-label-var": "error",
158 | "no-lone-blocks": "error",
159 | "no-lonely-if": "error",
160 | "no-loop-func": "error",
161 | "no-magic-numbers": "off",
162 | "no-mixed-operators": "off",
163 | "no-mixed-requires": "error",
164 | "no-multi-spaces": "error",
165 | "no-multi-str": "error",
166 | "no-multiple-empty-lines": "error",
167 | "no-negated-condition": "off",
168 | "no-nested-ternary": "off",
169 | "no-new": "error",
170 | "no-new-func": "error",
171 | "no-new-object": "error",
172 | "no-new-require": "error",
173 | "no-new-wrappers": "error",
174 | "no-octal-escape": "error",
175 | "no-param-reassign": "off",
176 | "no-path-concat": "error",
177 | "no-plusplus": "off",
178 | "no-process-env": "error",
179 | "no-process-exit": "error",
180 | "no-proto": "error",
181 | "no-prototype-builtins": "off",
182 | "no-restricted-globals": "error",
183 | "no-restricted-imports": "error",
184 | "no-restricted-modules": "error",
185 | "no-restricted-properties": "error",
186 | "no-restricted-syntax": "error",
187 | "no-return-assign": "off",
188 | "no-script-url": "error",
189 | "no-self-compare": "error",
190 | "no-sequences": "error",
191 | "no-shadow": "off",
192 | "no-shadow-restricted-names": "error",
193 | "no-spaced-func": "error",
194 | "no-sync": "error",
195 | "no-tabs": "error",
196 | "no-template-curly-in-string": "error",
197 | "no-ternary": "off",
198 | "no-throw-literal": "error",
199 | "no-trailing-spaces": "error",
200 | "no-undef-init": "error",
201 | "no-undefined": "off",
202 | "no-underscore-dangle": "off",
203 | "no-unmodified-loop-condition": "off",
204 | "no-unneeded-ternary": "error",
205 | "no-unsafe-negation": "error",
206 | "no-unused-expressions": "error",
207 | "no-use-before-define": "off",
208 | "no-useless-call": "error",
209 | "no-useless-computed-key": "error",
210 | "no-useless-concat": "error",
211 | "no-useless-constructor": "error",
212 | "no-useless-escape": "off",
213 | "no-useless-rename": "error",
214 | "no-var": "off",
215 | "no-void": "error",
216 | "no-warning-comments": "off",
217 | "no-whitespace-before-property": "error",
218 | "no-with": "error",
219 | "object-curly-newline": "off",
220 | "object-curly-spacing": "off",
221 | "object-property-newline": "off",
222 | "object-shorthand": "off",
223 | "one-var": "off",
224 | "one-var-declaration-per-line": "off",
225 | "operator-assignment": "off",
226 | "operator-linebreak": "off",
227 | "padded-blocks": "off",
228 | "prefer-arrow-callback": "error",
229 | "prefer-const": "off",
230 | "prefer-numeric-literals": "error",
231 | "prefer-reflect": "off",
232 | "prefer-rest-params": "off",
233 | "prefer-spread": "off",
234 | "prefer-template": "off",
235 | "quote-props": "off",
236 | "quotes": "off",
237 | "radix": [
238 | "error",
239 | "as-needed"
240 | ],
241 | "require-jsdoc": "off",
242 | "rest-spread-spacing": "error",
243 | "semi": "off",
244 | "semi-spacing": "off",
245 | "sort-imports": "off",
246 | "sort-keys": "off",
247 | "sort-vars": "off",
248 | "space-before-blocks": "off",
249 | "space-before-function-paren": "off",
250 | "space-in-parens": [
251 | "error",
252 | "never"
253 | ],
254 | "space-infix-ops": "off",
255 | "space-unary-ops": "error",
256 | "spaced-comment": "off",
257 | "strict": "error",
258 | "symbol-description": "error",
259 | "template-curly-spacing": [
260 | "error",
261 | "never"
262 | ],
263 | "unicode-bom": [
264 | "error",
265 | "never"
266 | ],
267 | "valid-jsdoc": "error",
268 | "vars-on-top": "off",
269 | "wrap-iife": "off",
270 | "wrap-regex": "off",
271 | "yield-star-spacing": "error"
272 | }
273 | };
274 |
--------------------------------------------------------------------------------