@codemirror/language
Language support infrastructure for the CodeMirror code editor
Last updated 5 years ago by marijn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @codemirror/language 
SYNC missed versions from official npm registry.

@codemirror/language NPM version

[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]

This package implements the language support infrastructure for the CodeMirror code editor.

The project page has more information, a number of examples and the documentation.

This code is released under an MIT license.

We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.

Usage

Setting up a language from a Lezer parser looks like this:

import {parser} from "@lezer/json"
import {LRLanguage, continuedIndent, indentNodeProp,
        foldNodeProp, foldInside} from "@codemirror/language"

export const jsonLanguage = LRLanguage.define({
  name: "json",
  parser: parser.configure({
    props: [
      indentNodeProp.add({
        Object: continuedIndent({except: /^\s*\}/}),
        Array: continuedIndent({except: /^\s*\]/})
      }),
      foldNodeProp.add({
        "Object Array": foldInside
      })
    ]
  }),
  languageData: {
    closeBrackets: {brackets: ["[", "{", '"']},
    indentOnInput: /^\s*[\}\]]$/
  }
})

Often, you'll also use this package just to access some specific language-related features, such as accessing the editor's syntax tree...

import {syntaxTree} from "@codemirror/language"

const tree = syntaxTree(view)

... or computing the appriate indentation at a given point.

import {getIndentation} from "@codemirror/language"

console.log(getIndentation(view.state, view.state.selection.main.head))

Current Tags

  • 6.12.3                                ...           latest (17 days ago)

56 Versions

  • 6.12.3                                ...           17 days ago
  • 6.12.2                                ...           2 months ago
  • 6.12.1                                ...           4 months ago
  • 6.12.0                                ...           4 months ago
  • 6.11.3                                ...           8 months ago
  • 6.11.2                                ...           9 months ago
  • 6.11.1                                ...           10 months ago
  • 6.11.0                                ...           a year ago
  • 6.10.8                                ...           a year ago
  • 6.10.7                                ...           a year ago
  • 6.10.6                                ...           a year ago
  • 6.10.5                                ...           a year ago
  • 6.10.4                                ...           a year ago
  • 6.10.3                                ...           2 years ago
  • 6.10.2                                ...           2 years ago
  • 6.10.1                                ...           2 years ago
  • 6.10.0                                ...           2 years ago
  • 6.9.3                                ...           2 years ago
  • 6.9.2                                ...           2 years ago
  • 6.9.1                                ...           3 years ago
  • 6.9.0                                ...           3 years ago
  • 6.8.0                                ...           3 years ago
  • 6.7.0                                ...           3 years ago
  • 6.6.0                                ...           3 years ago
  • 6.5.0                                ...           3 years ago
  • 6.4.0                                ...           3 years ago
  • 6.3.2                                ...           3 years ago
  • 6.3.1                                ...           3 years ago
  • 6.3.0                                ...           3 years ago
  • 6.2.1                                ...           4 years ago
  • 6.2.0                                ...           4 years ago
  • 6.1.0                                ...           4 years ago
  • 6.0.0                                ...           4 years ago
  • 0.20.2                                ...           4 years ago
  • 0.20.1                                ...           4 years ago
  • 0.20.0                                ...           4 years ago
  • 0.19.10                                ...           4 years ago
  • 0.19.9                                ...           4 years ago
  • 0.19.8                                ...           4 years ago
  • 0.19.7                                ...           4 years ago
  • 0.19.6                                ...           4 years ago
  • 0.19.5                                ...           4 years ago
  • 0.19.4                                ...           4 years ago
  • 0.19.3                                ...           5 years ago
  • 0.19.2                                ...           5 years ago
  • 0.19.1                                ...           5 years ago
  • 0.19.0                                ...           5 years ago
  • 0.18.2                                ...           5 years ago
  • 0.18.1                                ...           5 years ago
  • 0.18.0                                ...           5 years ago
  • 0.17.5                                ...           5 years ago
  • 0.17.4                                ...           5 years ago
  • 0.17.3                                ...           5 years ago
  • 0.17.2                                ...           5 years ago
  • 0.17.1                                ...           5 years ago
  • 0.17.0                                ...           5 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (7)

Copyright 2013 - present © cnpmjs.org | Home |