Skip to content

Repository files navigation

@fazelstudio/codemirror-lang-kotlin

NPM version

This package implements Kotlin (.kt, .kts) language support for the CodeMirror code editor: a full Lezer grammar covering classes, interfaces, objects, sealed/data classes, functions (including extension and infix functions), lambdas, when expressions, null-safety operators, string templates, ranges, generics, annotations, and KDoc documentation comments — with syntax highlighting compatible with any CodeMirror 6 theme.

This code is released under an MIT license.

Usage

import { EditorView, basicSetup } from "codemirror"
import { kotlin } from "@fazelstudio/codemirror-lang-kotlin"

new EditorView({
  parent: document.body,
  doc: `fun main() {\n    val name = "World"\n    println("Hello, $name!")\n}`,
  extensions: [basicSetup, kotlin()],
})

API

kotlin(config?) → LanguageSupport

kotlinLanguage: LRLanguage

Known limitations

  • Smart-cast analysis (narrowing type after is/!= null check) is a semantic feature and out of scope — this package only provides syntax highlighting and parsing, not type inference.
  • KDoc tag content (@param name description) is highlighted as part of the doc comment block, not parsed into structured fields, in v0.1.

About

Kotlin language support for the CodeMirror 6 code editor

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages