How to use the monaco-editor.languages function in monaco-editor

To help you get started, we’ve selected a few monaco-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / kui / app / plugins / modules / editor / src / lib / cmds / edit-esm.ts View on Github external
const initEditor = () => {
      if (!initDone) {
        // for now, try to disable the built-in Javascript-specific completion helper thingies
        monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ noLib: true, allowNonTsExtensions: true })

        // install any custom languages we might have
        languages(monaco).forEach(({ language, provider }) => {
          monaco.languages.registerCompletionItemProvider(language, provider)
        })

        initDone = true
      }

      // here we instantiate an editor widget
      editorWrapper['baseFontSize'] = 14.4
      editor = monaco.editor.create(editorWrapper, Object.assign({
        automaticLayout: false, // respond to window layout changes
        minimap: {
          enabled: false
        },
github heremaps / harp-map-editor / src / text-editor-frame / TextEditor.ts View on Github external
init() {
        this.m_editorElem = document.createElement("div");

        monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
            validate: true,
            schemas: [
                {
                    uri: "https://github.com/heremaps/harp.gl/theme.scheme.json",
                    fileMatch: [".theme.json"],
                    schema
                }
            ]
        });

        this.m_editor = monaco.editor.create(this.m_editorElem, {
            language: "json",
            model: this.m_model
        });

        window.addEventListener("resize", () => this.resize());
github ggoodman / velcro / packages / playground / src / lib / EditorManager.ts View on Github external
inlineSourceMap: true,
      inlineSources: true,
      isolatedModules: false,
      jsx: Monaco.languages.typescript.JsxEmit.React,
      lib: ['dom'],
      module: Monaco.languages.typescript.ModuleKind.CommonJS,
      moduleResolution: Monaco.languages.typescript.ModuleResolutionKind.NodeJs,
      noEmit: false,
      outDir: `dist`,
      resolveJsonModule: true,
      rootDir: '/',
      sourceMap: true,
      target: Monaco.languages.typescript.ScriptTarget.ES2015,
      typeRoots: ['node_modules/@types'],
    });
    Monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
      noSemanticValidation: true,
      noSyntaxValidation: false,
    });

    if (options.files) {
      for (const pathname in options.files) {
        const content = options.files[pathname];

        this.createModel(pathname, content);
      }
    }

    Monaco.editor.onDidCreateModel(model => {
      const onDidChangePackageJson = async () => {
        const value = model.getValue();
github mattgodbolt / compiler-explorer / static / modes / zig-mode.js View on Github external
[/\/\*/, 'comment.invalid'],
                [/[/*]/, 'comment']
            ],

            string: [
                [/[^\\"]+/, 'string'],
                [/@escapes/, 'string.escape'],
                [/\\./, 'string.escape.invalid'],
                [/"/, 'string', '@pop']
            ]
        }
    };
}

monaco.languages.register({id: 'zig'});
monaco.languages.setMonarchTokensProvider('zig', definition());
github mattgodbolt / compiler-explorer / static / modes / clean-mode.js View on Github external
comment: [
                [/[^/*]+/, 'comment'],
                [/\*\//, 'comment', '@pop'],
                [/[/*]/, 'comment']
            ],

            whitespace: [
                [/[ \t\r\n]+/, 'white'],
                [/\/\*/, 'comment', '@comment'],
                [/\/\/.*$/, 'comment']
            ]
        }
    };
}

monaco.languages.register({ id: 'clean' });
monaco.languages.setMonarchTokensProvider('clean', definition());
github mattgodbolt / compiler-explorer / static / modes / haskell-mode.js View on Github external
[/\*\//, 'comment', '@pop'],
                [/[/*]/, 'comment']
            ],

            whitespace: [
                [/[ \t\r\n]+/, 'white'],
                [/\/\*/, 'comment', '@comment'],
                [/\/\/.*$/, 'comment'],
                [/--.*$/, 'comment']
            ]
        }
    };
}

monaco.languages.register({id: 'haskell'});
monaco.languages.setMonarchTokensProvider('haskell', definition());
github sourcegraph / sourcegraph / shared / src / search / parser / completion.ts View on Github external
(label: string): Omit => ({
                label,
                kind: Monaco.languages.CompletionItemKind.Keyword,
                detail: description,
                insertText: `${label}:`,
                filterText: label,
            })
        )
github alibaba / form-render / demo / monaco / snippets.js View on Github external
import * as monaco from 'monaco-editor';

const Snippet = monaco.languages.CompletionItemKind.Snippet;
const insertTextRules =
  monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;

export const initialValue = `{
  "propsSchema": {
    "type": "object",
    "properties": {
      
    },
    "required": []
  },
  "uiSchema": {

  },
  "formData": {
    
  }
}`;
github mattgodbolt / compiler-explorer / static / modes / llvm-ir-mode.js View on Github external
}],
                [/[ \t\r\n]+/, 'white']

            ],
            string: [
                [/[^\\"]+/, 'string'],
                [/@escapes/, 'string.escape'],
                [/\\./, 'string.escape.invalid'],
                [/"/, 'string', '@pop']
            ]
        }
    };
}

monaco.languages.register({id: 'llvm-ir'});
monaco.languages.setMonarchTokensProvider('llvm-ir', definition());