Skip to content

replit/codemirror-lang-nix

Repository files navigation

CodeMirror Nix Mode

Run on Repl.it NPM version

A codemirror extension that adds Nix syntax highlighting and language features.

example of Nix syntax highlighting

Usage

import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { nix } from "@replit/codemirror-lang-nix";
import { basicSetup } from 'codemirror';

new EditorView({
  state: EditorState.create({
    doc: `{ pkgs ? import <nixpkgs> {} }: pkgs.mkShell { buildInputs = [ pkgs.nodejs ]; }`,
    extensions: [basicSetup, nix()],
  }),
  parent: document.querySelector('#editor'),
});