Skip to content

milahu/codemirror-lang-nix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codemirror-lang-nix

CodeMirror extension for the Nix language

Demo

Live Demo

Usage

git submodule add https://github.com/milahu/codemirror-lang-nix src/codemirror-lang-nix
git commit -m "add submodule src/codemirror-lang-nix"
// src/index.js

import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { basicSetup } from 'codemirror';

import { nix } from "./codemirror-lang-nix";

const nixSource = `\
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = [ pkgs.nodejs ];
}
`;

new EditorView({
  state: EditorState.create({
    doc: nixSource,
    extensions: [basicSetup, nix()],
  }),
  parent: document.querySelector('#editor'),
});

Related

this project is based on