{"_id":"@codincod/codemirror-lang-groovy","name":"@codincod/codemirror-lang-groovy","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@codincod/codemirror-lang-groovy","version":"0.1.0","description":"Groovy language support for the CodeMirror code editor","keywords":["editor","code","groovy","gradle","jenkinsfile","jvm","codemirror"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","type":"module","main":"dist/index.cjs","exports":{"import":"./dist/index.js","require":"./dist/index.cjs"},"module":"dist/index.js","types":"dist/index.d.ts","sideEffects":false,"scripts":{"build":"rm -rf dist && lezer-generator src/groovy.grammar -o src/parser.js && cm-buildhelper src/groovy.ts","build-debug":"lezer-generator src/groovy.grammar --names -o src/parser.js && cm-buildhelper src/groovy.ts","prepare":"npm run build","test":"npm run build && node --test \"test/*.test.ts\"","corpus":"npm run build && node ../lezer-survey/src/cli.ts measure --group top","gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group top"},"dependencies":{"@codemirror/autocomplete":"^6.0.0","@codemirror/language":"^6.0.0","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@lezer/lr":"^1.0.0"},"devDependencies":{"@codemirror/buildhelper":"^1.0.2","@codemirror/state":"^6.7.1","@lezer/generator":"^1.7.0","typescript":"^5.6.0"},"homepage":"https://codincod.com/","repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-groovy"},"gitHead":"0a2f7e60f0f5da4df7c7db4aa48585b6eb15ac73","_id":"@codincod/codemirror-lang-groovy@0.1.0","_nodeVersion":"25.0.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-WGFcH3a8Z29R5oxEnChIBMcHdyO+G2U+ocDWWoLDGbHCmY19xLE9Xgojsj+3QeNspEFKrlKrkX7y41KC1DXPYA==","shasum":"26645341e645f2985aabe068b91381a6a2fa06a0","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-groovy/-/codemirror-lang-groovy-0.1.0.tgz","fileCount":15,"unpackedSize":847263,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD6cDlm3yrlfTx3V/sVSmuBTI9qbEzrogqo2XFUE3XXiwIge83PWKead/mJcH4nDurEG6q8BkqMqWHgrT949QXejgE="}]},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"directories":{},"maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/codemirror-lang-groovy_0.1.0_1786363729554_0.5963360809792493"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-10T12:08:49.359Z","0.1.0":"2026-08-10T12:08:49.735Z","modified":"2026-08-10T12:08:49.999Z"},"maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"description":"Groovy language support for the CodeMirror code editor","homepage":"https://codincod.com/","keywords":["editor","code","groovy","gradle","jenkinsfile","jvm","codemirror"],"repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-groovy"},"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","readme":"# @codincod/codemirror-lang-groovy [![NPM version](https://img.shields.io/npm/v/@codincod/codemirror-lang-groovy.svg)](https://www.npmjs.org/package/@codincod/codemirror-lang-groovy)\n\n[ [**CHANGELOG**](https://codeberg.org/reeven/codemirror-lang-groovy/src/branch/master/CHANGELOG.md) ]\n\nThis package implements Groovy language support for the\n[CodeMirror](https://codemirror.net/) code editor, using a\n[Lezer](https://lezer.codemirror.net/) grammar written for this package.\n\nCodeMirror 6 has never shipped Groovy, and no Lezer grammar for it existed\nbefore this one. What gets used instead is the stream mode ported from\nCodeMirror 5, which colours a list of keywords and builds no tree, so nothing\nabove it can fold a closure, indent a `switch` or ask what the word under the\ncursor is. It also has nothing to say about the parts of Groovy that are not\nJava: a build file's parenthesis-free calls, a slashy regular expression, a\n`${}` inside a string.\n\nWritten in part for [CodinCod](https://codincod.com/), a competitive coding\nplatform, where it colours the editor people solve puzzles in.\n\nThis code is released under an\n[MIT license](https://codeberg.org/reeven/codemirror-lang-groovy/src/branch/master/LICENSE).\n\n## Usage\n\n```javascript\nimport {EditorView, basicSetup} from \"codemirror\"\nimport {groovy} from \"@codincod/codemirror-lang-groovy\"\n\nconst view = new EditorView({\n  parent: document.body,\n  doc: `class Greeter {\n    def name\n\n    String greet() {\n        \"Hello, $name!\"\n    }\n}\n`,\n  extensions: [basicSetup, groovy()]\n})\n```\n\n## Coverage\n\nGroovy 4, and with it the Java that Groovy is a superset of. Classes,\ninterfaces, traits, enums, records and annotation types, generics with\nwildcards and bounds, closures and lambdas, `def` in every position it is\nallowed, multiple assignment, command expressions with named arguments and\ntrailing closures, the Elvis, spread, safe navigation, attribute and method\npointer operators, ranges, `==~` and `=~`, Spock's string method names and\nlabels, switch as a statement and as an expression, and every way Groovy writes\na string: single and triple quoted, GStrings with `$name` and `${}` holes,\nslashy, and dollar slashy.\n\nMeasured against 20 662 Groovy and Gradle files from six open source projects\n(Apache Groovy, Gradle, Spock, Grails, Ratpack and Geb), which is 84 MiB of\ncode, of which 98.48% parse with no error node.\n\n## What the grammar cannot say\n\nFive things about Groovy are settled in `src/tokens.ts` rather than in the\ngrammar, because no context free rule can decide them.\n\n**A newline ends a statement, except when it does not.** Groovy's semicolons\nare optional, so `a\\nb` is two statements and `a +\\nb` is one. The tokenizer\nemits a zero width `insertSemi` when a line break stands between two things\nthat could each begin a statement, and holds it back when the next line opens\nwith something that can only continue the one before: a dot in any of Groovy's\nfive spellings, a comma, a closing bracket, `&&`, `||`, `?:`, an arrow, or one\nof `extends`, `implements` and `throws`, which a wrapped signature puts at the\nhead of the next line.\n\n**A brace opens a block or a closure.** `{` is the same character either way,\nand only the arrow a closure's parameters end with tells them apart. Where a\nstatement may begin the grammar settles it with a cut, because a block is the\nonly thing wanted there. Everywhere else the tokenizer looks ahead for the\narrow, giving up at the first character a parameter list cannot hold, so that\n`{ foo(a -> b) }` is not mistaken for a closure that takes `foo`.\n\n**A parenthesis opens a call or a lambda.** `a.b()` and `(a, b) -> a + b` are\nthe same shape until the arrow after the closing bracket, and a call is written\nfar too often for the parser to be left weighing the two. The tokenizer counts\nthe depth along the line and emits `LambdaParen` only when the bracket that\ncloses the group is followed by an arrow.\n\n**A `<` is a comparison or a type argument list.** `a < b` and `Map<K, V>` are\nthe same two characters, and Groovy makes it harder than Java does: a command\nexpression means the parser has a comparison available everywhere a type could\nstand. The tokenizer reads the whole angle bracketed group, then reads the\n*name* after it, and decides on what follows that name. A name being declared\nis followed by its value, by another name, by its parameters, by the colon or\n`in` of a for-each, or by the end of the line; a name being compared is\nfollowed by an operator.\n\n**A slash opens a string or divides.** Groovy's slashy string needs no escaping\nand is what regular expressions are written in, and it starts on the same\ncharacter as division. The tokenizer looks at what stands in front: after a\nname, a number, a string or a closing bracket there is a value to divide, and\neverywhere else there is not. Groovy's own lexer reads the character this way,\nso `len / (w + 1)` divides and `m ==~ /\\d+/` matches, here as in the language.\n\n## Development\n\n```bash\nnpm install\nnpm test          # build, then the parse specs and the editor tests\nnpm run build     # regenerate src/parser.js and dist/\n```\n\nThe corpus scripts want [lezer-survey](https://codeberg.org/reeven/lezer-survey)\nchecked out beside this package, and a corpus of real Groovy to point it at.\n","readmeFilename":"README.md","_rev":"1-a73aff9d778a2998a6252b01e686875a"}