Move the base CodeMirror KCL support to a local package (#4897)
* Move CodeMirror LRLanguage to new file This separates the base language support from the LSP and color picker. * Move the base CodeMirror KCL support to a local package * Start CodeMirror grammar tests * Exclude vitest config in tsconfig * Add KCL path to tsconfig * Remove stray import * Drop extension from import * Use __filename for commonjs compat * Check exec return before access * Build ES and CJS to dist * Format * Exclude all.test.ts from codespell This is to work around "fileTests" imported from Lezer. Future codespell versions look like they'll allow the code to be annotated, which would be nicer. --------- Co-authored-by: Matt Mundell <matt@mundell.me>
This commit is contained in:
32
packages/codemirror-lang-kcl/src/highlight.ts
Normal file
32
packages/codemirror-lang-kcl/src/highlight.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { styleTags, tags as t } from '@lezer/highlight'
|
||||
|
||||
export const kclHighlight = styleTags({
|
||||
'import export': t.moduleKeyword,
|
||||
ImportItemAs: t.definitionKeyword,
|
||||
ImportFrom: t.moduleKeyword,
|
||||
'fn var let const': t.definitionKeyword,
|
||||
'if else': t.controlKeyword,
|
||||
return: t.controlKeyword,
|
||||
'true false': t.bool,
|
||||
nil: t.null,
|
||||
'AddOp MultOp ExpOp': t.arithmeticOperator,
|
||||
BangOp: t.logicOperator,
|
||||
CompOp: t.compareOperator,
|
||||
LogicOp: t.logicOperator,
|
||||
'Equals Arrow': t.definitionOperator,
|
||||
PipeOperator: t.controlOperator,
|
||||
String: t.string,
|
||||
Number: t.number,
|
||||
LineComment: t.lineComment,
|
||||
BlockComment: t.blockComment,
|
||||
Shebang: t.meta,
|
||||
PipeSubstitution: t.atom,
|
||||
VariableDefinition: t.definition(t.variableName),
|
||||
VariableName: t.variableName,
|
||||
PropertyName: t.propertyName,
|
||||
TagDeclarator: t.tagName,
|
||||
'( )': t.paren,
|
||||
'{ }': t.brace,
|
||||
'[ ]': t.bracket,
|
||||
', . : ? ..': t.punctuation,
|
||||
})
|
Reference in New Issue
Block a user