mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-24 19:44:53 +01:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { parser } from './url';
|
|
// import { foldNodeProp, foldInside, indentNodeProp } from '@codemirror/language';
|
|
import { styleTags, tags as t } from '@lezer/highlight';
|
|
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
|
import { completeFromList } from '@codemirror/autocomplete';
|
|
|
|
const parserWithMetadata = parser.configure({
|
|
props: [
|
|
styleTags({
|
|
Protocol: t.comment,
|
|
Port: t.attributeName,
|
|
Host: t.variableName,
|
|
PathSegment: t.bool,
|
|
Slash: t.bool,
|
|
Question: t.attributeName,
|
|
QueryName: t.attributeName,
|
|
QueryValue: t.attributeName,
|
|
Amp: t.comment,
|
|
Equal: t.comment,
|
|
}),
|
|
// indentNodeProp.add({
|
|
// Application: (context) => context.column(context.node.from) + context.unit,
|
|
// }),
|
|
// foldNodeProp.add({
|
|
// Application: foldInside,
|
|
// }),
|
|
],
|
|
});
|
|
|
|
const urlLanguage = LRLanguage.define({
|
|
parser: parserWithMetadata,
|
|
languageData: {
|
|
// commentTokens: {line: ";"}
|
|
},
|
|
});
|
|
|
|
const exampleCompletion = urlLanguage.data.of({
|
|
autocomplete: completeFromList([
|
|
{ label: 'http://', type: 'keyword' },
|
|
{ label: 'https://', type: 'keyword' },
|
|
]),
|
|
});
|
|
|
|
export function url() {
|
|
return new LanguageSupport(urlLanguage, [exampleCompletion]);
|
|
}
|