{"id":18062117,"url":"https://github.com/jurjanpaul/codemirror6-parinfer","last_synced_at":"2025-10-26T04:30:28.294Z","repository":{"id":260162092,"uuid":"878936877","full_name":"jurjanpaul/codemirror6-parinfer","owner":"jurjanpaul","description":"CodeMirror 6 Parinfer extension","archived":false,"fork":false,"pushed_at":"2025-02-09T21:09:36.000Z","size":206,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T21:15:13.702Z","etag":null,"topics":["clojure","codemirror","codemirror6","parinfer","scittle"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@jurjanpaul/codemirror6-parinfer","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jurjanpaul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-26T14:18:00.000Z","updated_at":"2025-02-09T21:09:18.000Z","dependencies_parsed_at":"2024-11-19T10:18:18.612Z","dependency_job_id":"a061575c-36c1-48e7-8a59-33878ed22a1c","html_url":"https://github.com/jurjanpaul/codemirror6-parinfer","commit_stats":null,"previous_names":["jurjanpaul/codemirror6-parinfer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurjanpaul%2Fcodemirror6-parinfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurjanpaul%2Fcodemirror6-parinfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurjanpaul%2Fcodemirror6-parinfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurjanpaul%2Fcodemirror6-parinfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jurjanpaul","download_url":"https://codeload.github.com/jurjanpaul/codemirror6-parinfer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238229930,"owners_count":19437724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","codemirror","codemirror6","parinfer","scittle"],"created_at":"2024-10-31T05:05:44.487Z","updated_at":"2025-10-26T04:30:28.289Z","avatar_url":"https://github.com/jurjanpaul.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeMirror 6 Parinfer extension\n\n\u003cspan\u003e\u003ca href=\"https://www.npmjs.com/package/@jurjanpaul/codemirror6-parinfer\" title=\"NPM version badge\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@jurjanpaul/codemirror6-parinfer?color=blue\" alt=\"NPM version badge\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\nA [CodeMirror 6](https://codemirror.net/) extension that integrates [Parinfer](https://shaunlebron.github.io/parinfer/), which facilitates structural editing of Lisp code (Clojure code in particular) by indentation.\n\nBy default [`smartMode`](https://github.com/parinfer/parinfer.js/tree/master#status-update-2019-smart-mode) is applied, but both `indentMode` and `parenMode` can be selected as well.\n\nInitially I used ClojureScript on [Scittle](https://babashka.org/scittle/) to explore what was needed to get the integration to work, but the actual extension is written in TypeScript and available as ES module (with the `parinfer.js` dependency inlined for more convenient downstream bundling) from [npmjs.com](https://www.npmjs.com/package/@jurjanpaul/codemirror6-parinfer).\n\nTry it at [the demo page](https://jurjanpaul.github.io/codemirror6-parinfer/)!\n\nPlease let me know if you have a use for this or have any feedback!\n\n## Basic usage\n```typescript\nimport { basicSetup } from 'codemirror';\nimport { EditorState } from '@codemirror/state';\nimport { EditorView } from '@codemirror/view';\nimport { parinferExtension } from '@jurjanpaul/codemirror6-parinfer';\n\nconst doc = `\n(defn foo []\n  [:bar \\\"baz\\\"])`\n\nnew EditorView({\n  state: EditorState.create({\n    doc,\n    extensions: [basicSetup, parinferExtension()],\n  }),\n  parent: document.getElementById(\"editor\");\n});\n```\n\n## API\n\n### `@jurjanpaul/codemirror6-parinfer` TypeScript module\n```typescript\nparinferExtension(initialConfig?: ParinferExtensionConfig): Extension\n```\nMain entry point: initialises the extension with optional configuration.\u003cbr\u003e\nBy default Parinfer is enabled in \u003ccode\u003e\"smart\"\u003c/code\u003e mode.\u003cbr\u003e\u003cbr\u003e\n\n\n```typescript\ntype ParinferExtensionConfig = {\n  enabled?: boolean\n  mode?: ParinferMode\n}\n```\n\n```typescript\ntype ParinferMode = \"smart\" | \"indent\" | \"paren\"\n```\n\n```typescript\nconfigField: StateField\u003cParinferExtensionConfig\u003e\n```\nCodeMirror state field with the current extension configuration.\n\n\u003cbr\u003e\n\n```typescript\nsetConfigEffect: StateEffectType\u003cParinferExtensionConfig\u003e\n```\nCodeMirror state effect that can be used in a transaction to update the extension's configuration.\n\n\u003cbr\u003e\n\n```typescript\nconfigureParinfer(view: EditorView, config: ParinferExtensionConfig)\n```\nConvenience wrapper around the `setConfigEffect` state effect.\u003cbr\u003e\u003cbr\u003e\n\n```typescript\nswitchMode(view: EditorView, mode: ParinferMode)\n```\nSpeaks for itself. Convenience wrapper for `configureParinfer`.\u003cbr\u003e\u003cbr\u003e\n\n```typescript\ndisableParinfer(view: EditorView)\n```\nSpeaks for itself. Convenience wrapper for `configureParinfer`.\u003cbr\u003e\u003cbr\u003e\n\n```typescript\nenableParinfer(view: EditorView)\n```\nSpeaks for itself. Convenience wrapper for `configureParinfer`.\u003cbr\u003e\u003cbr\u003e\n\n## Out of scope (at least for the foreseeable future)\n - visualising/styling the [Paren Trail](https://github.com/parinfer/parinfer.js/blob/master/doc/code.md#paren-trail) that parinfer includes in its result;\n - visualising the `tabStops` that parinfer includes in its result;\n - smart indentation (does not really belong to Parinfer, but missed anyway, because outside the legacy Clojure mode there is no support for CodeMirror 6 yet).\n\n## Motivation\nI had previously used CodeMirror 5 with Parinfer in the [Away from Preferred Editor ClojureScript Playground](https://github.com/jurjanpaul/ape-cljs-playground) and hoped to upgrade to CodeMirror 6 as soon as somebody would make a Parinfer extension available.\n\nFor quite a while, as a Clojure programmer I was simply too intimidated by the statically typed CodeMirror 6 module architecture to even consider taking on that task myself next to a few other side projects. But still not finding one some years after the CodeMirror 6 release, I finally found the time and motivation to take up the challenge, starting with studying TypeScript, etc.\n\n## Implementation\nSome observations w.r.t. the implementation can be found [here](docs/implementation.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjurjanpaul%2Fcodemirror6-parinfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjurjanpaul%2Fcodemirror6-parinfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjurjanpaul%2Fcodemirror6-parinfer/lists"}