Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/repl/app/templates/edit/editor/code-mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { isDestroyed, isDestroying, registerDestructor } from '@ember/destroyabl
import { service } from '@ember/service';
import { waitForPromise } from '@ember/test-waiters';

import { syntaxHighlighting } from '@codemirror/language';
import Modifier from 'ember-modifier';
import { getCompiler } from 'ember-repl';

import { HorizonSyntaxTheme, HorizonTheme } from './theme.ts';
import { HorizonTheme } from './theme.ts';

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to lose the theme 🙈 I like Horizon haha

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably will need to lose it, or reimplement it for shiki. Probably best to either offer a theme selector with the shiki themes or pick your favourite shiki theme :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely need to lose it lol, I had to setup an empty highlighter theme to disable lezer clobbering shiki.

I've asked the author hwo they use lezer language features with shiki (waiting on moderator approval on codemirror forum) so maybe there is another way, but maybe that's how they do it too.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you end up getting a response there?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They recommended just not using syntaxHighlighting() function, but I'm pretty sure I lost other lezer features when doing that.


import type RouterService from '@ember/routing/router-service';
import type EditorService from 'limber/services/editor';
Expand Down Expand Up @@ -171,7 +170,7 @@ class CodeMirror extends Modifier<Signature> {
text: value,
format: formatFromURL,
handleUpdate: updateText,
extensions: [HorizonTheme, syntaxHighlighting(HorizonSyntaxTheme)],
extensions: [HorizonTheme],
});

if (isDestroyed(this) || isDestroying(this)) return;
Expand Down
4 changes: 4 additions & 0 deletions packages/repl-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,23 @@
"@lezer/html": "^1.3.10",
"@lezer/markdown": "^1.4.1",
"@replit/codemirror-lang-svelte": "^6.0.0",
"@shikijs/langs": "^3.13.0",
"@shikijs/themes": "^3.13.0",
"change-case": "^5.4.4",
"codemirror": "^6.0.2",
"codemirror-lang-glimdown": "workspace:*",
"codemirror-lang-glimmer": "workspace:*",
"codemirror-lang-glimmer-js": "workspace:*",
"codemirror-lang-mermaid": "^0.5.0",
"codemirror-languageserver": "^1.12.1",
"codemirror-shiki": "^0.3.0",
"comlink": "^4.4.2",
"es-module-shims": "^2.6.1",
"mime": "^4.0.7",
"package-name-regex": "^4.0.3",
"resolve.exports": "^2.0.3",
"resolve.imports": "^2.0.3",
"shiki": "^3.13.0",
"tarparser": "^0.0.5"
},
"volta": {
Expand Down
22 changes: 21 additions & 1 deletion packages/repl-sdk/src/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import { basicSetup, EditorView } from 'codemirror';
// @ts-ignore
import { foldByIndent } from 'codemirror-lang-mermaid';
import shiki from 'codemirror-shiki';
import { createHighlighterCore } from 'shiki/core';
import { createOnigurumaEngine } from 'shiki/engine/oniguruma';

/**
* Builds and creates a codemirror instance for the given element
Expand Down Expand Up @@ -72,23 +75,40 @@
return Array.isArray(support) ? support : [support];
}

const [language, support] = await Promise.all([

Check failure on line 78 in packages/repl-sdk/src/codemirror.js

View workflow job for this annotation

GitHub Actions / Lints

'language' is assigned a value but never used. Allowed unused vars must match /^_/u
languageForFormat(format),
supportForFormat(format),
]);

const highlighter = createHighlighterCore({
langs: [
import('@shikijs/langs/javascript'),
import('@shikijs/langs/typescript'),
import('@shikijs/langs/glimmer-js'),
import('@shikijs/langs/glimmer-ts'),
],
themes: [import('@shikijs/themes/one-dark-pro')],
engine: createOnigurumaEngine(import('shiki/wasm')),
});

const editorExtensions = [
// features
basicSetup,
foldByIndent(),
// Language
languageConf.of(language),
Comment thread
evoactivity marked this conversation as resolved.
// languageConf.of(language),
supportConf.of(support),

updateListener,
EditorView.lineWrapping,
keymap.of([indentWithTab, ...completionKeymap, ...markdownKeymap]),

shiki({
highlighter,
language: 'glimmer-js',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we'd need a map of format+flavor to language id 🤔

theme: 'one-dark-pro',
}),

// TODO: lsp,

...(extensions ?? []),
Expand Down
100 changes: 94 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading