mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 10:18:31 +02:00
Fix pairs language not highlighting
This commit is contained in:
@@ -105,6 +105,7 @@ export function getLanguageExtension({
|
|||||||
return graphql();
|
return graphql();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("SELECTING SYNTAX", language);
|
||||||
const base = syntaxExtensions[language ?? 'text'] ?? text();
|
const base = syntaxExtensions[language ?? 'text'] ?? text();
|
||||||
if (!useTemplating) {
|
if (!useTemplating) {
|
||||||
return base;
|
return base;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
||||||
import { parser } from './pairs';
|
import { parser } from './pairs';
|
||||||
|
|
||||||
const urlLanguage = LRLanguage.define({
|
const language = LRLanguage.define({
|
||||||
|
name: 'pairs',
|
||||||
parser,
|
parser,
|
||||||
languageData: {},
|
languageData: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
export function pairs() {
|
export function pairs() {
|
||||||
return new LanguageSupport(urlLanguage, []);
|
return new LanguageSupport(language, []);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
||||||
import { parser } from './text';
|
import { parser } from './text';
|
||||||
|
|
||||||
export const textLanguageName = 'text';
|
export const textLanguage = LRLanguage.define({
|
||||||
|
name: 'text',
|
||||||
const textLanguage = LRLanguage.define({
|
|
||||||
name: textLanguageName,
|
|
||||||
parser,
|
parser,
|
||||||
languageData: {},
|
languageData: {},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { parseMixed } from '@lezer/common';
|
|||||||
import type { EnvironmentVariable } from '@yaakapp-internal/models';
|
import type { EnvironmentVariable } from '@yaakapp-internal/models';
|
||||||
import type { GenericCompletionConfig } from '../genericCompletion';
|
import type { GenericCompletionConfig } from '../genericCompletion';
|
||||||
import { genericCompletion } from '../genericCompletion';
|
import { genericCompletion } from '../genericCompletion';
|
||||||
import { textLanguageName } from '../text/extension';
|
import { textLanguage } from '../text/extension';
|
||||||
import type { TwigCompletionOption } from './completion';
|
import type { TwigCompletionOption } from './completion';
|
||||||
import { twigCompletion } from './completion';
|
import { twigCompletion } from './completion';
|
||||||
import { templateTagsPlugin } from './templateTags';
|
import { templateTagsPlugin } from './templateTags';
|
||||||
@@ -63,12 +63,10 @@ function mixLanguage(base: LanguageSupport): LRLanguage {
|
|||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = 'twig';
|
|
||||||
|
|
||||||
const parser = twigParser.configure({
|
const parser = twigParser.configure({
|
||||||
wrap: parseMixed((node) => {
|
wrap: parseMixed((node) => {
|
||||||
// If the base language is text, we can overwrite at the top
|
// If the base language is text, we can overwrite at the top
|
||||||
if (base.language.name !== textLanguageName && !node.type.isTop) {
|
if (base.language.name !== textLanguage.name && !node.type.isTop) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +77,7 @@ function mixLanguage(base: LanguageSupport): LRLanguage {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const language = LRLanguage.define({ name, parser });
|
const language = LRLanguage.define({ name: 'twig', parser });
|
||||||
mixedLanguagesCache[base.language.name] = language;
|
mixedLanguagesCache[base.language.name] = language;
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
|||||||
import { parser } from './url';
|
import { parser } from './url';
|
||||||
|
|
||||||
const urlLanguage = LRLanguage.define({
|
const urlLanguage = LRLanguage.define({
|
||||||
|
name: 'url',
|
||||||
parser,
|
parser,
|
||||||
languageData: {},
|
languageData: {},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user