Autocomplete, and more CM stuff!

This commit is contained in:
Gregory Schier
2023-02-28 22:54:54 -08:00
parent 1e57890d2e
commit 5040d73a8b
20 changed files with 220 additions and 178 deletions

View File

@@ -1,43 +1,16 @@
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,
// }),
],
});
import { LanguageSupport, LRLanguage } from '@codemirror/language';
import { parser } from './url';
const urlLanguage = LRLanguage.define({
parser: parserWithMetadata,
languageData: {
// commentTokens: {line: ";"}
},
parser,
languageData: {},
});
const exampleCompletion = urlLanguage.data.of({
autocomplete: completeFromList([
{ label: 'http://', type: 'keyword' },
{ label: 'https://', type: 'keyword' },
{ label: 'http://', type: 'constant' },
{ label: 'https://', type: 'constant' },
]),
});