From b50ca6baf3743a65f36e5524f0add28482f0016d Mon Sep 17 00:00:00 2001 From: Max Hegler Date: Wed, 12 Apr 2023 09:27:11 -0700 Subject: [PATCH 1/6] WIP - adding language support for CSS/JS (MVT) embedded syntax highlighting --- .hintrc | 9 + client/src/mivaCommands.ts | 28 +-- configurations/MVT/mvt-css.configuration.json | 39 ++++ configurations/MVT/mvt-js.configuration.json | 196 ++++++++++++++++++ package.json | 84 +++++++- server/src/serverMain.ts | 14 +- server/src/util/interfaces.ts | 6 +- syntaxes/MVT/mvt-css.tmLanguage.json | 9 + syntaxes/MVT/mvt-css.tmLanguage.yaml | 7 + syntaxes/MVT/mvt-js.tmLanguage.json | 9 + syntaxes/MVT/mvt-js.tmLanguage.yaml | 7 + syntaxes/MVT/mvt.injection.tmLanguage.json | 6 +- syntaxes/MVT/mvt.injection.tmLanguage.yaml | 61 +++--- syntaxes/MVT/mvt.tmLanguage.json | 2 +- syntaxes/MVT/mvt.tmLanguage.yaml | 2 +- 15 files changed, 424 insertions(+), 55 deletions(-) create mode 100644 .hintrc create mode 100644 configurations/MVT/mvt-css.configuration.json create mode 100644 configurations/MVT/mvt-js.configuration.json create mode 100644 syntaxes/MVT/mvt-css.tmLanguage.json create mode 100644 syntaxes/MVT/mvt-css.tmLanguage.yaml create mode 100644 syntaxes/MVT/mvt-js.tmLanguage.json create mode 100644 syntaxes/MVT/mvt-js.tmLanguage.yaml diff --git a/.hintrc b/.hintrc new file mode 100644 index 0000000..676179f --- /dev/null +++ b/.hintrc @@ -0,0 +1,9 @@ +{ + "extends": [ + "development" + ], + "hints": { + "typescript-config/strict": "off", + "typescript-config/consistent-casing": "off" + } +} \ No newline at end of file diff --git a/client/src/mivaCommands.ts b/client/src/mivaCommands.ts index cbb75a4..1b80097 100644 --- a/client/src/mivaCommands.ts +++ b/client/src/mivaCommands.ts @@ -1,5 +1,5 @@ import patterns from './util/patterns'; -import { TextEditor, TextEditorEdit, Range, commands, env, window, workspace, Uri, languages, Position } from 'vscode'; +import { TextEditor, TextEditorEdit, Range, commands, env, window, workspace, Uri, languages, Position, CharacterPair } from 'vscode'; const boundryAmount = 200; @@ -39,13 +39,13 @@ const insertFileNameCommand = commands.registerTextEditorCommand( 'mivaIde.inser if ( leftMatch ) { insertEdit( leftMatch[0].length, ` ${ fileName } ` ); - + } } leftMatch = patterns.SHARED.LEFT_FILE_ATTR.exec( left ); - + // define helper method for inserting file name function insertEdit( matchLength: number, fileName: string ) { @@ -58,7 +58,7 @@ const insertFileNameCommand = commands.registerTextEditorCommand( 'mivaIde.inser // check & execute the insertion if ( leftMatch ) { - + insertEdit( leftMatch[0].length, fileName ); } @@ -131,7 +131,7 @@ function convertVariableToEntity( variable: string, uri?: Uri ) { const convertAndCopyCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.convertAndCopy', ( textEditor: TextEditor ) => { // exit if not MVT - if ( textEditor.document.languageId !== 'mvt' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { return; } @@ -162,7 +162,7 @@ const convertAndCopyCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.c const convertToEntityCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.convertToEntity', ( textEditor: TextEditor, edit: TextEditorEdit ) => { // exit if not MVT - if ( textEditor.document.languageId !== 'mvt' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { return; } @@ -186,7 +186,7 @@ const convertToEntityCommand = commands.registerTextEditorCommand( 'mivaIde.MVT. const convertToVariableCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.convertToVariable', ( textEditor: TextEditor, edit: TextEditorEdit ) => { // exit if not MVT - if ( textEditor.document.languageId !== 'mvt' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { return; } @@ -211,15 +211,19 @@ const insertHtmlComment = commands.registerTextEditorCommand( 'mivaIde.toggleHtm const languageId = textEditor.document.languageId; - if ( languageId === 'mvt' || languageId === 'mv' ) { - - languages.setLanguageConfiguration( languageId, { comments: { blockComment: [ '' ] } } ); + if ( languageId === 'mvt' || languageId === 'mvt-css' || languageId === 'mvt-js' || languageId === 'mv' ) { + + const blockComment: CharacterPair = languageId === 'mvt-css' || languageId === 'mvt-js' + ? [ '/*', '*/' ] + : [ '' ]; + + languages.setLanguageConfiguration( languageId, { comments: { blockComment: blockComment } } ); commands.executeCommand( 'editor.action.blockComment' ).then(() => { languages.setLanguageConfiguration( languageId, { comments: { blockComment: ( languageId == 'mv' ) ? [ '', '' ] : [ '', '' ] } } ); - }); + }); } else { @@ -232,7 +236,7 @@ const insertHtmlComment = commands.registerTextEditorCommand( 'mivaIde.toggleHtm const calculatePosNumberCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.calculatePosNumber', ( textEditor: TextEditor, edit: TextEditorEdit ) => { - if ( textEditor.document.languageId !== 'mvt' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { return; } diff --git a/configurations/MVT/mvt-css.configuration.json b/configurations/MVT/mvt-css.configuration.json new file mode 100644 index 0000000..fcad40b --- /dev/null +++ b/configurations/MVT/mvt-css.configuration.json @@ -0,0 +1,39 @@ +{ + "comments": { + "blockComment": [ "", "" ] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + [ "<", ">" ], + [ "", "" ] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}", "notIn": ["string", "comment"] }, + { "open": "[", "close": "]", "notIn": ["string", "comment"] }, + { "open": "(", "close": ")", "notIn": ["string", "comment"] }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, + { "open": "'", "close": "'", "notIn": ["string", "comment"] }, + { "open": "", "close": "", "notIn": [ "comment", "string" ] } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"], + { "open": "<", "close": ">" } + ], + "folding": { + "markers": { + "start": "^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/", + "end": "^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/" + } + }, + "indentationRules": { + "increaseIndentPattern": "(^.*\\{[^}]*$)", + "decreaseIndentPattern": "^\\s*\\}" + }, + "wordPattern": "(#?-?\\d*\\.\\d\\w*%?)|(::?[\\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\\w-?]+%?|[@#!.])" +} diff --git a/configurations/MVT/mvt-js.configuration.json b/configurations/MVT/mvt-js.configuration.json new file mode 100644 index 0000000..f6cce25 --- /dev/null +++ b/configurations/MVT/mvt-js.configuration.json @@ -0,0 +1,196 @@ +{ + // Note that this file should stay in sync with 'typescript-language-basics/language-configuration.json' + "comments": { + "lineComment": "//", + "blockComment": [ + "", + "" + ] + }, + "brackets": [ + [ + "${", + "}" + ], + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ "<", ">" ], + [ "", "" ] + ], + "autoClosingPairs": [ + { + "open": "{", + "close": "}" + }, + { + "open": "[", + "close": "]" + }, + { + "open": "(", + "close": ")" + }, + { + "open": "'", + "close": "'", + "notIn": [ + "string", + "comment" + ] + }, + { + "open": "\"", + "close": "\"", + "notIn": [ + "string" + ] + }, + { + "open": "`", + "close": "`", + "notIn": [ + "string", + "comment" + ] + }, + { + "open": "/**", + "close": " */", + "notIn": [ + "string" + ] + }, + { "open": "", "close": "", "notIn": [ "comment", "string" ] } + ], + "surroundingPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "'", + "'" + ], + [ + "\"", + "\"" + ], + [ + "`", + "`" + ], + [ + "<", + ">" + ] + ], + "autoCloseBefore": ";:.,=}])>` \n\t", + "folding": { + "markers": { + "start": "^\\s*//\\s*#?region\\b", + "end": "^\\s*//\\s*#?endregion\\b" + } + }, + "wordPattern": { + "pattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\@\\!\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>/\\?\\s]+)", + }, + "indentationRules": { + "decreaseIndentPattern": { + "pattern": "^((?!.*?/\\*).*\\*\/)?\\s*[\\}\\]].*$" + }, + "increaseIndentPattern": { + "pattern": "^((?!//).)*(\\{([^}\"'`/]*|(\\t|[ ])*//.*)|\\([^)\"'`/]*|\\[[^\\]\"'`/]*)$" + }, + // e.g. * ...| or */| or *-----*/| + "unIndentedLinePattern": { + "pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$" + } + }, + "onEnterRules": [ + { + // e.g. /** | */ + "beforeText": { + "pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$" + }, + "afterText": { + "pattern": "^\\s*\\*/$" + }, + "action": { + "indent": "indentOutdent", + "appendText": " * " + } + }, + { + // e.g. /** ...| + "beforeText": { + "pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$" + }, + "action": { + "indent": "none", + "appendText": " * " + } + }, + { + // e.g. * ...| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$" + }, + "previousLineText": { + "pattern": "(?=^(\\s*(/\\*\\*|\\*)).*)(?=(?!(\\s*\\*/)))" + }, + "action": { + "indent": "none", + "appendText": "* " + } + }, + { + // e.g. */| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*/\\s*$" + }, + "action": { + "indent": "none", + "removeText": 1 + }, + }, + { + // e.g. *-----*/| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$" + }, + "action": { + "indent": "none", + "removeText": 1 + }, + }, + { + "beforeText": { + "pattern": "^\\s*(\\bcase\\s.+:|\\bdefault:)$" + }, + "afterText": { + "pattern": "^(?!\\s*(\\bcase\\b|\\bdefault\\b))" + }, + "action": { + "indent": "indent" + } + } + ] +} diff --git a/package.json b/package.json index 3a68187..468eaf8 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,10 @@ }, "[mv]": { "editor.suggest.snippetsPreventQuickSuggestions": false + }, + "files.associations": { + "**/css/*.mvt": "mvt-css", + "**/js/*.mvt": "mvt-js" } }, "commands": [ @@ -122,10 +126,22 @@ "scopeName": "text.html.mvt", "path": "./syntaxes/MVT/mvt.tmLanguage.json" }, + { + "language": "mvt-css", + "scopeName": "source.css.mvt", + "path": "./syntaxes/MVT/mvt-css.tmLanguage.json" + }, + { + "language": "mvt-js", + "scopeName": "source.js.mvt", + "path": "./syntaxes/MVT/mvt-js.tmLanguage.json" + }, { "scopeName": "mvt.injection", "injectTo": [ - "text.html.mvt" + "text.html.mvt", + "source.css.mvt", + "source.js.mvt" ], "path": "./syntaxes/MVT/mvt.injection.tmLanguage.json" }, @@ -146,7 +162,7 @@ { "command": "mivaIde.MVT.convertAndCopy", "key": "cmd+shift+c", - "when": "(editorHasSelection || editorHasMultipleSelections) && (editorLangId == mv || editorLangId == mvt)" + "when": "(editorHasSelection || editorHasMultipleSelections) && (editorLangId == mv || editorLangId == mvt || editorLangId == mvt-css || editorLangId == mvt-js)" }, { "command": "mivaIde.toggleHtmlComment", @@ -158,17 +174,43 @@ { "id": "mvt", "aliases": [ - "Miva Template Language (MVT)" + "Miva Template Language", + "MVT" ], "extensions": [ ".mvt" ], "configuration": "./configurations/MVT/mvt.configuration.json" }, + { + "id": "mvt-css", + "aliases": [ + "Miva Template Language (CSS)", + "MVT-CSS" + ], + "extensions": [ + ".mvt", + ".css.mvt" + ], + "configuration": "./configurations/MVT/mvt-css.configuration.json" + }, + { + "id": "mvt-js", + "aliases": [ + "Miva Template Language (JS)", + "MVT-JS" + ], + "extensions": [ + ".mvt", + ".js.mvt" + ], + "configuration": "./configurations/MVT/mvt-js.configuration.json" + }, { "id": "mv", "aliases": [ - "Miva Script" + "Miva Script", + "MV" ], "extensions": [ ".mv" @@ -193,6 +235,38 @@ "language": "mvt", "path": "./snippets/builtins.snippets.json" }, + { + "language": "mvt-css", + "path": "./snippets/MVT/tags.snippets.json" + }, + { + "language": "mvt-css", + "path": "./snippets/MVT/customfields.snippets.json" + }, + { + "language": "mvt-css", + "path": "./snippets/MVT/debugging.snippets.json" + }, + { + "language": "mvt-css", + "path": "./snippets/builtins.snippets.json" + }, + { + "language": "mvt-js", + "path": "./snippets/MVT/tags.snippets.json" + }, + { + "language": "mvt-js", + "path": "./snippets/MVT/customfields.snippets.json" + }, + { + "language": "mvt-js", + "path": "./snippets/MVT/debugging.snippets.json" + }, + { + "language": "mvt-js", + "path": "./snippets/builtins.snippets.json" + }, { "language": "mv", "path": "./snippets/builtins.snippets.json" @@ -201,6 +275,8 @@ }, "activationEvents": [ "onLanguage:mvt", + "onLanguage:mvt-css", + "onLanguage:mvt-js", "onLanguage:mv" ], "devDependencies": { diff --git a/server/src/serverMain.ts b/server/src/serverMain.ts index 467ef49..305771a 100644 --- a/server/src/serverMain.ts +++ b/server/src/serverMain.ts @@ -112,6 +112,8 @@ const validationDelayMs = 500; let languages: Languages = { mvt: null, + 'mvt-css': null, + 'mvt-js': null, mv: null }; @@ -133,6 +135,8 @@ connection.onInitialize(( params: InitializeParams ): InitializeResult => { }; languages.mvt = getMVTFeatures( workspace, params.capabilities ); + languages['mvt-css'] = getMVTFeatures( workspace, params.capabilities ); + languages['mvt-js'] = getMVTFeatures( workspace, params.capabilities ); languages.mv = getMVFeatures( workspace, params.capabilities ); function getClientCapability( name: string, def: T ) { @@ -207,9 +211,9 @@ connection.onDidChangeConfiguration(change => { // Handle completion events connection.onCompletion(async ( textDocumentPosition, token ) => { return runSafeAsync(async () => { - + const document = documents.get( textDocumentPosition.textDocument.uri ); - + if ( !document ) { return null; } @@ -263,7 +267,7 @@ connection.onDefinition(( definitionParams, token ) => { return runSafeAsync(async () => { const document = documents.get( definitionParams.textDocument.uri ); - + if ( document ) { const settings = await getDocumentSettings( document ); @@ -272,7 +276,7 @@ connection.onDefinition(( definitionParams, token ) => { if ( features && features.findDefinition ) { return features.findDefinition( document, definitionParams.position, settings ); - + } } @@ -285,7 +289,7 @@ connection.onDefinition(( definitionParams, token ) => { // The content of a text document has changed. This event is emitted // when the text document first opened or when its content has changed. documents.onDidChangeContent(change => { - + triggerValidation( change.document ); }); diff --git a/server/src/util/interfaces.ts b/server/src/util/interfaces.ts index add6b16..189266d 100644 --- a/server/src/util/interfaces.ts +++ b/server/src/util/interfaces.ts @@ -23,14 +23,16 @@ export interface Workspace { export interface Languages { mv: LanguageFeatures, - mvt: LanguageFeatures + mvt: LanguageFeatures, + 'mvt-css': LanguageFeatures, + 'mvt-js': LanguageFeatures } export interface LanguageFeatures { doValidation?: ( document: TextDocument, settings?: Settings ) => Diagnostic[]; - + doCompletion?: ( document: TextDocument, position: Position, settings?: Settings ) => CompletionList; findDocumentSymbols?: ( document: TextDocument ) => SymbolInformation[]; diff --git a/syntaxes/MVT/mvt-css.tmLanguage.json b/syntaxes/MVT/mvt-css.tmLanguage.json new file mode 100644 index 0000000..1e20bc1 --- /dev/null +++ b/syntaxes/MVT/mvt-css.tmLanguage.json @@ -0,0 +1,9 @@ +{ + "name": "Miva Template Language (CSS)", + "scopeName": "source.css.mvt", + "patterns": [ + { + "include": "source.css" + } + ] +} \ No newline at end of file diff --git a/syntaxes/MVT/mvt-css.tmLanguage.yaml b/syntaxes/MVT/mvt-css.tmLanguage.yaml new file mode 100644 index 0000000..a9f7053 --- /dev/null +++ b/syntaxes/MVT/mvt-css.tmLanguage.yaml @@ -0,0 +1,7 @@ +%YAML 1.2 +--- +name: Miva Template Language (CSS) +scopeName: source.css.mvt + +patterns: + - include: source.css \ No newline at end of file diff --git a/syntaxes/MVT/mvt-js.tmLanguage.json b/syntaxes/MVT/mvt-js.tmLanguage.json new file mode 100644 index 0000000..15f5e85 --- /dev/null +++ b/syntaxes/MVT/mvt-js.tmLanguage.json @@ -0,0 +1,9 @@ +{ + "name": "Miva Template Language (JS)", + "scopeName": "source.js.mvt", + "patterns": [ + { + "include": "source.js" + } + ] +} \ No newline at end of file diff --git a/syntaxes/MVT/mvt-js.tmLanguage.yaml b/syntaxes/MVT/mvt-js.tmLanguage.yaml new file mode 100644 index 0000000..0e66396 --- /dev/null +++ b/syntaxes/MVT/mvt-js.tmLanguage.yaml @@ -0,0 +1,7 @@ +%YAML 1.2 +--- +name: Miva Template Language (JS) +scopeName: source.js.mvt + +patterns: + - include: source.js \ No newline at end of file diff --git a/syntaxes/MVT/mvt.injection.tmLanguage.json b/syntaxes/MVT/mvt.injection.tmLanguage.json index c7d7f16..0b79b79 100644 --- a/syntaxes/MVT/mvt.injection.tmLanguage.json +++ b/syntaxes/MVT/mvt.injection.tmLanguage.json @@ -1,7 +1,11 @@ { "name": "MVT (Injection)", "scopeName": "mvt.injection", - "injectionSelector": "L:text.html.mvt -comment.block.mvt", + "injectionSelector": [ + "L:text.html.mvt -comment.block.mvt", + "L:source.css.mvt -comment.block.mvt", + "L:source.js.mvt -comment.block.mvt" + ], "patterns": [ { "include": "#comments" diff --git a/syntaxes/MVT/mvt.injection.tmLanguage.yaml b/syntaxes/MVT/mvt.injection.tmLanguage.yaml index 779fa5a..150b728 100644 --- a/syntaxes/MVT/mvt.injection.tmLanguage.yaml +++ b/syntaxes/MVT/mvt.injection.tmLanguage.yaml @@ -2,7 +2,10 @@ --- name: MVT (Injection) scopeName: mvt.injection -injectionSelector: 'L:text.html.mvt -comment.block.mvt' +injectionSelector: + - 'L:text.html.mvt -comment.block.mvt' + - 'L:source.css.mvt -comment.block.mvt' + - 'L:source.js.mvt -comment.block.mvt' patterns: @@ -16,7 +19,7 @@ patterns: - include: '#tags' repository: - + # =-======================== Comments ========================-= # comments: begin: '(?i)' @@ -24,7 +27,7 @@ repository: 0: {name: punctuation.definition.comment.mvt} end: '(?i)' name: comment.block.mvt - + # =-======================== Entities ========================-= # entities: patterns: @@ -64,7 +67,7 @@ repository: - include: '#assign-name-attribute' - include: '#value-attribute' - include: '#illegal-attributes' - + tag-call: patterns: - begin: '()' @@ -123,7 +126,7 @@ repository: - include: '#name-attribute' - include: '#value-attribute' - include: '#illegal-attributes' - + tag-else: patterns: - begin: '(?i)(<)(mvt)(:)(else)(?=\s|/?>)' @@ -140,7 +143,7 @@ repository: - match: '\/' name: invalid.illegal.slash.mvt - include: '#illegal-attributes' - + tag-elseif: patterns: - begin: '(?i)(<)(mvt)(:)(elseif)(?=\s|/?>)' @@ -158,7 +161,7 @@ repository: name: invalid.illegal.slash.mvt - include: '#expr-attribute' - include: '#illegal-attributes' - + tag-eval: patterns: - begin: '(?i)(<)(mvt)(:)(eval)(?=\s|/?>)' @@ -191,7 +194,7 @@ repository: - include: '#array-attribute' - include: '#iterator-attribute' - include: '#illegal-attributes' - + tag-if: patterns: - begin: '()' @@ -222,7 +225,7 @@ repository: name: meta.tag.inline.$4.mvt patterns: - include: '#illegal-attributes' - + tag-item: patterns: - begin: '(?i)(<)(mvt)(:)(item)(?=\s|/?>)' @@ -239,7 +242,7 @@ repository: - include: '#item-name-attribute' - include: '#param-attribute' - include: '#illegal-attributes' - + tag-miva: patterns: - begin: '(?i)(<)(mvt)(:)(miva)(?=\s|/?>)' @@ -256,7 +259,7 @@ repository: - include: '#compresswhitespace-attribute' - include: '#output-attribute' - include: '#illegal-attributes' - + tag-while: patterns: - begin: '( Date: Wed, 12 Apr 2023 09:31:08 -0700 Subject: [PATCH 2/6] updated year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index d5cb602..2f188d3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Max Hegler +Copyright (c) 2023 Max Hegler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 0c35c52913a6d2202d4ff24cff7492bdf6fd311c Mon Sep 17 00:00:00 2001 From: Max Hegler Date: Wed, 12 Apr 2023 09:32:37 -0700 Subject: [PATCH 3/6] removed old props --- .vscode/launch.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 51dbf08..de3721b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,6 @@ "name": "Launch Client", "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceFolder}" ], - "stopOnEntry": false, "sourceMaps": true, "outFiles": ["${workspaceFolder}/client/out/**/*.js"], "preLaunchTask": "npm: watch" @@ -17,7 +16,6 @@ "request": "attach", "name": "Attach to Server", "address": "localhost", - "protocol": "inspector", "port": 6045, "sourceMaps": true, "outFiles": ["${workspaceFolder}/server/out/**/*.js"] From 2dbcec9b3e3b76a46db3b502d534df3831f7d4f1 Mon Sep 17 00:00:00 2001 From: Max Hegler Date: Wed, 12 Apr 2023 09:41:03 -0700 Subject: [PATCH 4/6] renamed identifiers to js safe format (no dashes) --- client/src/mivaCommands.ts | 12 ++--- package.json | 49 ++++++++++--------- server/src/serverMain.ts | 11 +++-- server/src/util/interfaces.ts | 4 +- ...tmLanguage.json => mvtcss.tmLanguage.json} | 0 ...tmLanguage.yaml => mvtcss.tmLanguage.yaml} | 0 ....tmLanguage.json => mvtjs.tmLanguage.json} | 0 ....tmLanguage.yaml => mvtjs.tmLanguage.yaml} | 0 8 files changed, 39 insertions(+), 37 deletions(-) rename syntaxes/MVT/{mvt-css.tmLanguage.json => mvtcss.tmLanguage.json} (100%) rename syntaxes/MVT/{mvt-css.tmLanguage.yaml => mvtcss.tmLanguage.yaml} (100%) rename syntaxes/MVT/{mvt-js.tmLanguage.json => mvtjs.tmLanguage.json} (100%) rename syntaxes/MVT/{mvt-js.tmLanguage.yaml => mvtjs.tmLanguage.yaml} (100%) diff --git a/client/src/mivaCommands.ts b/client/src/mivaCommands.ts index 1b80097..c93d480 100644 --- a/client/src/mivaCommands.ts +++ b/client/src/mivaCommands.ts @@ -131,7 +131,7 @@ function convertVariableToEntity( variable: string, uri?: Uri ) { const convertAndCopyCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.convertAndCopy', ( textEditor: TextEditor ) => { // exit if not MVT - if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvtcss' && textEditor.document.languageId !== 'mvtjs' ) { return; } @@ -162,7 +162,7 @@ const convertAndCopyCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.c const convertToEntityCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.convertToEntity', ( textEditor: TextEditor, edit: TextEditorEdit ) => { // exit if not MVT - if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvtcss' && textEditor.document.languageId !== 'mvtjs' ) { return; } @@ -186,7 +186,7 @@ const convertToEntityCommand = commands.registerTextEditorCommand( 'mivaIde.MVT. const convertToVariableCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.convertToVariable', ( textEditor: TextEditor, edit: TextEditorEdit ) => { // exit if not MVT - if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvtcss' && textEditor.document.languageId !== 'mvtjs' ) { return; } @@ -211,9 +211,9 @@ const insertHtmlComment = commands.registerTextEditorCommand( 'mivaIde.toggleHtm const languageId = textEditor.document.languageId; - if ( languageId === 'mvt' || languageId === 'mvt-css' || languageId === 'mvt-js' || languageId === 'mv' ) { + if ( languageId === 'mvt' || languageId === 'mvtcss' || languageId === 'mvtjs' || languageId === 'mv' ) { - const blockComment: CharacterPair = languageId === 'mvt-css' || languageId === 'mvt-js' + const blockComment: CharacterPair = languageId === 'mvtcss' || languageId === 'mvtjs' ? [ '/*', '*/' ] : [ '' ]; @@ -236,7 +236,7 @@ const insertHtmlComment = commands.registerTextEditorCommand( 'mivaIde.toggleHtm const calculatePosNumberCommand = commands.registerTextEditorCommand( 'mivaIde.MVT.calculatePosNumber', ( textEditor: TextEditor, edit: TextEditorEdit ) => { - if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvt-css' && textEditor.document.languageId !== 'mvt-js' ) { + if ( textEditor.document.languageId !== 'mvt' && textEditor.document.languageId !== 'mvtcss' && textEditor.document.languageId !== 'mvtjs' ) { return; } diff --git a/package.json b/package.json index 468eaf8..7ce7e14 100644 --- a/package.json +++ b/package.json @@ -89,8 +89,8 @@ "editor.suggest.snippetsPreventQuickSuggestions": false }, "files.associations": { - "**/css/*.mvt": "mvt-css", - "**/js/*.mvt": "mvt-js" + "**/css/*.mvt": "mvtcss", + "**/js/*.mvt": "mvtjs" } }, "commands": [ @@ -127,14 +127,14 @@ "path": "./syntaxes/MVT/mvt.tmLanguage.json" }, { - "language": "mvt-css", + "language": "mvtcss", "scopeName": "source.css.mvt", - "path": "./syntaxes/MVT/mvt-css.tmLanguage.json" + "path": "./syntaxes/MVT/mvtcss.tmLanguage.json" }, { - "language": "mvt-js", + "language": "mvtjs", "scopeName": "source.js.mvt", - "path": "./syntaxes/MVT/mvt-js.tmLanguage.json" + "path": "./syntaxes/MVT/mvtjs.tmLanguage.json" }, { "scopeName": "mvt.injection", @@ -162,7 +162,7 @@ { "command": "mivaIde.MVT.convertAndCopy", "key": "cmd+shift+c", - "when": "(editorHasSelection || editorHasMultipleSelections) && (editorLangId == mv || editorLangId == mvt || editorLangId == mvt-css || editorLangId == mvt-js)" + "when": "(editorHasSelection || editorHasMultipleSelections) && (editorLangId == mv || editorLangId == mvt || editorLangId == mvtcss || editorLangId == mvtjs)" }, { "command": "mivaIde.toggleHtmlComment", @@ -175,7 +175,8 @@ "id": "mvt", "aliases": [ "Miva Template Language", - "MVT" + "MVT", + "MVT (HTML)" ], "extensions": [ ".mvt" @@ -183,28 +184,28 @@ "configuration": "./configurations/MVT/mvt.configuration.json" }, { - "id": "mvt-css", + "id": "mvtcss", "aliases": [ "Miva Template Language (CSS)", - "MVT-CSS" + "MVT (CSS)" ], "extensions": [ ".mvt", ".css.mvt" ], - "configuration": "./configurations/MVT/mvt-css.configuration.json" + "configuration": "./configurations/MVT/mvtcss.configuration.json" }, { - "id": "mvt-js", + "id": "mvtjs", "aliases": [ "Miva Template Language (JS)", - "MVT-JS" + "MVT (JS)" ], "extensions": [ ".mvt", ".js.mvt" ], - "configuration": "./configurations/MVT/mvt-js.configuration.json" + "configuration": "./configurations/MVT/mvtjs.configuration.json" }, { "id": "mv", @@ -236,35 +237,35 @@ "path": "./snippets/builtins.snippets.json" }, { - "language": "mvt-css", + "language": "mvtcss", "path": "./snippets/MVT/tags.snippets.json" }, { - "language": "mvt-css", + "language": "mvtcss", "path": "./snippets/MVT/customfields.snippets.json" }, { - "language": "mvt-css", + "language": "mvtcss", "path": "./snippets/MVT/debugging.snippets.json" }, { - "language": "mvt-css", + "language": "mvtcss", "path": "./snippets/builtins.snippets.json" }, { - "language": "mvt-js", + "language": "mvtjs", "path": "./snippets/MVT/tags.snippets.json" }, { - "language": "mvt-js", + "language": "mvtjs", "path": "./snippets/MVT/customfields.snippets.json" }, { - "language": "mvt-js", + "language": "mvtjs", "path": "./snippets/MVT/debugging.snippets.json" }, { - "language": "mvt-js", + "language": "mvtjs", "path": "./snippets/builtins.snippets.json" }, { @@ -275,8 +276,8 @@ }, "activationEvents": [ "onLanguage:mvt", - "onLanguage:mvt-css", - "onLanguage:mvt-js", + "onLanguage:mvtcss", + "onLanguage:mvtjs", "onLanguage:mv" ], "devDependencies": { diff --git a/server/src/serverMain.ts b/server/src/serverMain.ts index 305771a..4185afc 100644 --- a/server/src/serverMain.ts +++ b/server/src/serverMain.ts @@ -112,8 +112,8 @@ const validationDelayMs = 500; let languages: Languages = { mvt: null, - 'mvt-css': null, - 'mvt-js': null, + mvtcss: null, + mvtjs: null, mv: null }; @@ -134,9 +134,10 @@ connection.onInitialize(( params: InitializeParams ): InitializeResult => { get folders() { return workspaceFolders } }; - languages.mvt = getMVTFeatures( workspace, params.capabilities ); - languages['mvt-css'] = getMVTFeatures( workspace, params.capabilities ); - languages['mvt-js'] = getMVTFeatures( workspace, params.capabilities ); + const mvtFeatures = getMVTFeatures( workspace, params.capabilities ); + languages.mvt = mvtFeatures; + languages.mvtcss = mvtFeatures; + languages.mvtjs = mvtFeatures; languages.mv = getMVFeatures( workspace, params.capabilities ); function getClientCapability( name: string, def: T ) { diff --git a/server/src/util/interfaces.ts b/server/src/util/interfaces.ts index 189266d..7e29a1d 100644 --- a/server/src/util/interfaces.ts +++ b/server/src/util/interfaces.ts @@ -24,8 +24,8 @@ export interface Workspace { export interface Languages { mv: LanguageFeatures, mvt: LanguageFeatures, - 'mvt-css': LanguageFeatures, - 'mvt-js': LanguageFeatures + mvtcss: LanguageFeatures, + mvtjs: LanguageFeatures } export interface LanguageFeatures { diff --git a/syntaxes/MVT/mvt-css.tmLanguage.json b/syntaxes/MVT/mvtcss.tmLanguage.json similarity index 100% rename from syntaxes/MVT/mvt-css.tmLanguage.json rename to syntaxes/MVT/mvtcss.tmLanguage.json diff --git a/syntaxes/MVT/mvt-css.tmLanguage.yaml b/syntaxes/MVT/mvtcss.tmLanguage.yaml similarity index 100% rename from syntaxes/MVT/mvt-css.tmLanguage.yaml rename to syntaxes/MVT/mvtcss.tmLanguage.yaml diff --git a/syntaxes/MVT/mvt-js.tmLanguage.json b/syntaxes/MVT/mvtjs.tmLanguage.json similarity index 100% rename from syntaxes/MVT/mvt-js.tmLanguage.json rename to syntaxes/MVT/mvtjs.tmLanguage.json diff --git a/syntaxes/MVT/mvt-js.tmLanguage.yaml b/syntaxes/MVT/mvtjs.tmLanguage.yaml similarity index 100% rename from syntaxes/MVT/mvt-js.tmLanguage.yaml rename to syntaxes/MVT/mvtjs.tmLanguage.yaml From eb2ef8407580ab601eceef9e6f8b1657a37ad275 Mon Sep 17 00:00:00 2001 From: Max Hegler Date: Wed, 12 Apr 2023 09:59:03 -0700 Subject: [PATCH 5/6] added language trigger for mvtjs mvtcss --- client/src/main.ts | 8 +++++-- ...uration.json => mvtcss.configuration.json} | 0 ...guration.json => mvtjs.configuration.json} | 0 server/src/mivaFeatures.ts | 22 +++++++++---------- 4 files changed, 17 insertions(+), 13 deletions(-) rename configurations/MVT/{mvt-css.configuration.json => mvtcss.configuration.json} (100%) rename configurations/MVT/{mvt-js.configuration.json => mvtjs.configuration.json} (100%) diff --git a/client/src/main.ts b/client/src/main.ts index 62364b2..ae1a884 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -34,6 +34,10 @@ export function activate( context: ExtensionContext ) { let documentSelector = [ { scheme: 'file', language: 'mvt' }, { scheme: 'untitled', language: 'mvt' }, + { scheme: 'file', language: 'mvtcss' }, + { scheme: 'untitled', language: 'mvtcss' }, + { scheme: 'file', language: 'mvtjs' }, + { scheme: 'untitled', language: 'mvtjs' }, { scheme: 'file', language: 'mv' }, { scheme: 'untitled', language: 'mv' } ]; @@ -53,7 +57,7 @@ export function activate( context: ExtensionContext ) { client.registerProposedFeatures(); let clientDisposable = client.start(); - // push client to context + // push client to context context.subscriptions.push( clientDisposable ); // set advanced language configurations @@ -93,7 +97,7 @@ export function activate( context: ExtensionContext ) { } ], }); - + // push all commands to context pushAll( context.subscriptions, mivaCommands ); diff --git a/configurations/MVT/mvt-css.configuration.json b/configurations/MVT/mvtcss.configuration.json similarity index 100% rename from configurations/MVT/mvt-css.configuration.json rename to configurations/MVT/mvtcss.configuration.json diff --git a/configurations/MVT/mvt-js.configuration.json b/configurations/MVT/mvtjs.configuration.json similarity index 100% rename from configurations/MVT/mvt-js.configuration.json rename to configurations/MVT/mvtjs.configuration.json diff --git a/server/src/mivaFeatures.ts b/server/src/mivaFeatures.ts index e318abf..e2454ff 100644 --- a/server/src/mivaFeatures.ts +++ b/server/src/mivaFeatures.ts @@ -20,7 +20,7 @@ import { import { TextDocument } from 'vscode-languageserver-textdocument'; -import { +import { readJSONFile, tokenize, getDoValueCompletions, @@ -76,7 +76,7 @@ export function getMVTFeatures( workspace: Workspace, clientCapabilities: Client // create the pattern to match const pattern = new RegExp( validation.match, 'igm' ); let match: RegExpExecArray; - let count = 0; + let count = 0; while ( (match = pattern.exec( text )) && count < 1000 ) { count++; diagnostics.push( @@ -107,7 +107,7 @@ export function getMVTFeatures( workspace: Workspace, clientCapabilities: Client position ); const left = mvtDocument.getText( leftRange ) || ''; - + // determine right side text range const rightOffset = cursorPositionOffset + boundryAmount; const rightRange = Range.create( @@ -115,7 +115,7 @@ export function getMVTFeatures( workspace: Workspace, clientCapabilities: Client mvtDocument.positionAt( rightOffset ) ); const right = mvtDocument.getText( rightRange ) || ''; - + // mvt:do tag value attribute completions if ( patterns.MVT.LEFT_IN_MVTDO_TAG.test( left ) && @@ -274,10 +274,10 @@ function _getMvDocumentSymbolsByUri (uri) { return output.concat( _mvFindDocumentSymbols( document ) ); }, []); -} +} function _mvFindDocumentSymbols( document: TextDocument ): SymbolInformation[] { - + const results: SymbolInformation[] = []; const scanner = htmlLanguageService.createScanner( document.getText(), 0 ); @@ -334,7 +334,7 @@ function _mvFindDocumentSymbols( document: TextDocument ): SymbolInformation[] { token = scanner.scan(); - } + } return results; @@ -372,7 +372,7 @@ export function getMVFeatures( workspace: Workspace, clientCapabilities: ClientC position ); const left = mvDocument.getText( leftRange ) || ''; - + // determine right side text range const rightOffset = cursorPositionOffset + boundryAmount; const rightRange = Range.create( @@ -380,7 +380,7 @@ export function getMVFeatures( workspace: Workspace, clientCapabilities: ClientC mvDocument.positionAt( rightOffset ) ); const right = mvDocument.getText( rightRange ) || ''; - + // MvDO tag value attribute completions if ( patterns.MV.LEFT_IN_MVDO_TAG.test( left ) && @@ -401,7 +401,7 @@ export function getMVFeatures( workspace: Workspace, clientCapabilities: ClientC }, findDocumentSymbols( document: TextDocument ): SymbolInformation[] { - + return _mvFindDocumentSymbols( mvDocuments.get( document ) ); }, @@ -431,7 +431,7 @@ export function getMVFeatures( workspace: Workspace, clientCapabilities: ClientC } return null; - + } }; From acab85868d0e4b4d5ad67b4c311009d572a6bf8f Mon Sep 17 00:00:00 2001 From: Max Hegler Date: Wed, 12 Apr 2023 09:59:50 -0700 Subject: [PATCH 6/6] bumped version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1df3b87..ad89bab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-miva-ide", - "version": "0.11.0", + "version": "0.12.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-miva-ide", - "version": "0.11.0", + "version": "0.12.0", "hasInstallScript": true, "devDependencies": { "@types/node": "^13.13.30", diff --git a/package.json b/package.json index 7ce7e14..6c833c7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-miva-ide", "displayName": "Miva IDE", "description": "Syntax highlighting, snippets and tools for building websites with Miva.", - "version": "0.11.0", + "version": "0.12.0", "engines": { "vscode": "^1.35.0" },