{"_id":"@codincod/codemirror-lang-r","_rev":"2-eb012a3d88763d09b8c190df9a3bdf44","name":"@codincod/codemirror-lang-r","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@codincod/codemirror-lang-r","version":"0.1.0","keywords":["editor","code","r","statistics","codemirror"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","_id":"@codincod/codemirror-lang-r@0.1.0","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"homepage":"https://codincod.com/","dist":{"shasum":"8831ce889c4fdda0ecd36bb3ec19514e69b9d3d1","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-r/-/codemirror-lang-r-0.1.0.tgz","fileCount":14,"integrity":"sha512-dIxCfd0sqH0GHINDQAtKjAuM0iEKkPcjcAd9WsRNry2xyNgqGlnjNcUcIXmJsgZGj2Hayvo0+DKDRaOyXBYl7A==","signatures":[{"sig":"MEYCIQCSTh/WCpGFwXAozI/MFMpD4iBtpVK6/PcVy2c+lefcZgIhAJXRB6RDjY+k7iyrCtHzwX7LfRTzIUBgSq0sJ8ahV0Bt","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":101873},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{"import":"./dist/index.js","require":"./dist/index.cjs"},"gitHead":"adbcf5c1d9f832c82041c5048e42f5a253c039f0","scripts":{"test":"npm run build && node --test \"test/*.test.ts\"","build":"rm -rf dist && lezer-generator src/r.grammar -o src/parser.js && cm-buildhelper src/r.ts","corpus":"npm run build && node test/corpus.ts","prepare":"npm run build","build-debug":"lezer-generator src/r.grammar --names -o src/parser.js && cm-buildhelper src/r.ts"},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"repository":{"url":"git+https://codeberg.org/reeven/codemirror-lang-r.git","type":"git"},"_npmVersion":"11.6.2","description":"R language support for the CodeMirror code editor","directories":{},"sideEffects":false,"_nodeVersion":"25.0.0","dependencies":{"@lezer/lr":"^1.0.0","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@codemirror/language":"^6.0.0","@codemirror/autocomplete":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.0","@lezer/generator":"^1.7.0","@codemirror/state":"^6.7.1","@codemirror/buildhelper":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-lang-r_0.1.0_1785679726606_0.2908140004575157","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@codincod/codemirror-lang-r","version":"0.1.1","description":"R language support for the CodeMirror code editor","keywords":["editor","code","r","statistics","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/r.grammar -o src/parser.js && cm-buildhelper src/r.ts","build-debug":"lezer-generator src/r.grammar --names -o src/parser.js && cm-buildhelper src/r.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-r"},"gitHead":"34298baae81014ab7105c64f631e7d6ced3c4d08","_id":"@codincod/codemirror-lang-r@0.1.1","_nodeVersion":"25.0.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-Gyxj9IZxCV6+wnmYbzQnEnYRqMtI2SlpkqnRjh9365MZBBrjYgUmgZ4Oxh0CI9vOtdFEMPYZ+c/XOK4nWyupfg==","shasum":"3f32a327b91b9587db703e1663fefbfc0ff426d8","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-r/-/codemirror-lang-r-0.1.1.tgz","fileCount":14,"unpackedSize":101978,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB2d+2QYNclFk2qs4nlEFQ5jgJqg++2v/MNYG1PUMNVXAiEAgCMZElX3l5wAXUuxFgYlZlzugFqlaWaRmTgImMRC9vE="}]},"_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-r_0.1.1_1785970801271_0.06233455165140622"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-02T14:08:46.435Z","modified":"2026-08-05T23:00:01.609Z","0.1.0":"2026-08-02T14:08:46.757Z","0.1.1":"2026-08-05T23:00:01.446Z"},"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","homepage":"https://codincod.com/","keywords":["editor","code","r","statistics","codemirror"],"repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-r"},"description":"R language support for the CodeMirror code editor","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"readme":"# @codincod/codemirror-lang-r [![NPM version](https://img.shields.io/npm/v/@codincod/codemirror-lang-r.svg)](https://www.npmjs.org/package/@codincod/codemirror-lang-r)\n\n[ [**CHANGELOG**](https://codeberg.org/reeven/codemirror-lang-r/src/branch/master/CHANGELOG.md) ]\n\nThis package implements R language support for the\n[CodeMirror](https://codemirror.net/) code editor, using a\n[Lezer](https://lezer.codemirror.net/) grammar ported from R's own.\n\nCodeMirror 6 has never shipped R. What stands in for it is the stream mode\ncarried over from CodeMirror 5, which colours a keyword list and builds no\ntree, so nothing above it can fold a function, indent an argument list or ask\nwhat the name under the cursor is. There is one other Lezer grammar for R on\nnpm, and it reads under a third of real R: no unary minus, no `<` or `>`, no\n`:`, no `|>`, no `%in%`, no braceless body, no `\\(x)`, no raw 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-r/src/branch/master/LICENSE).\n\n## Usage\n\n```javascript\nimport {EditorView, basicSetup} from \"codemirror\"\nimport {r} from \"@codincod/codemirror-lang-r\"\n\nconst view = new EditorView({\n  parent: document.body,\n  doc: `greet <- function(name = \"world\") {\n  sprintf(\"Hello, %s!\", name)\n}\n`,\n  extensions: [basicSetup, r()]\n})\n```\n\n## Coverage\n\nR 4.5. Every assignment R has, including `:=`; functions written with\n`function` and with `\\(x)`; `if`, `for`, `while` and `repeat` with braces and\nwithout; calls with named, empty and dotted arguments; `[`, `[[` and their\nempty subscripts; `::`, `:::`, `$` and `@`; formulas; the native pipe and the\nones packages define between percent signs; raw strings; backtick names;\ninteger, double, hexadecimal and complex literals; roxygen comments; and `...`,\n`..1` and the pipe placeholder.\n\nMeasured against 2 322 R files from eight open source projects (R itself,\nggplot2, dplyr, tidyr, data.table, shiny, testthat and devtools), which is\n15 MiB of code, of which 99.70% parse with no error node. The seven files that\ndo not are not R: three are fixtures in R's own test suite that hold a\ndeliberate parse error, two are shiny templates holding `{{ }}` placeholders,\none is testthat's `syntax-error` fixture, and one is written in Latin-1.\n\n## What the grammar cannot say\n\nThe grammar is a port of `src/main/gram.y` from the R sources, which is an\nLALR grammar and so nearly a Lezer grammar already. Its precedence table is R's\nread from the other end, and every production answers to one there. Three\nthings are settled in `src/tokens.ts` instead, because no context free rule can\ndecide them.\n\n**A line break ends an expression when the expression is finished.** R has no\nstatement terminator. `x <- 1` followed by a line holding `-2` is two\nexpressions, and `x <- 1 +` followed by a line holding `2` is one. The\ntokenizer offers a terminator of no width at every line break and the parser\ntakes it only where an expression may end, which is nowhere inside a bracket\nand nowhere after an operator still waiting for its right hand side. That is\nthe whole rule, and it needs one exception: a line may open with `else`, which\nR itself allows inside braces and refuses outside them.\n\n**A raw string carries its own delimiter.** `r\"(a\\d+)\"` holds a backslash and\nends at `)\"`. `r\"---(x)---\"` ends only at the dashes it opened with, and how\nmany there were is not something a regular expression can remember.\n\n**A string is cut into pieces.** The escapes inside it are coloured apart from\nthe text around them, so the tokenizer hands over a start, the runs of text,\nthe escapes and an end. Each quote character has its own set of those tokens,\nwhich is how the tokenizer knows what it is looking for without keeping any\nstate.\n\n## Testing\n\n```\nnpm test                       # the parse specs, then highlighting and indentation\nnpm run corpus -- path/to/code # error nodes over a directory of real R files\n```\n\nNo corpus ships with the package, because none of that code is ours to\nredistribute. `npm run corpus` takes a directory and reports the share of files\nthat parse with no error node, grouped by directory so that a project which\ndrags the total down names itself.\n","readmeFilename":"README.md"}