Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Commit 8c5beb3

Browse files
author
Viktor Novikov
committed
PHP Files support
1 parent 4d6b216 commit 8c5beb3

File tree

10 files changed

+89
-36
lines changed

10 files changed

+89
-36
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*.{js,json}]
4+
indent_size = 2
5+
indent_style = space

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,8 @@ The format is based on [Keep a Changelog] (http://keepachangelog.com/en/1.0.0/)
112112

113113
### [2.10.0] - 2021-06-03
114114
## Improved
115-
- GLSL support
115+
- GLSL support
116+
117+
### [2.11.0] - 2021-10-05
118+
## Improved
119+
- PHP file support

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ Simply insert the comment /\*html\*/ or `html` (also works with SQL, SVG, XML, j
7979
### [2.10.0] - 2021-06-03
8080
## Improved
8181
- GLSL support
82+
83+
### [2.11.0] - 2021-10-05
84+
## Improved
85+
- PHP files support
8286
-----------------------------------------------------------------------------------------------------------
8387

8488
**Enjoy!**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "es6-string-html",
33
"displayName": "es6-string-html",
44
"description": "Syntax highlighting in es6 multiline strings",
5-
"version": "2.10.0",
5+
"version": "2.11.0",
66
"publisher": "Tobermory",
77
"icon": "docs/logo.png",
88
"engines": {

scripts/main.js

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,69 @@
1-
'use strict';
1+
import * as vscode from 'vscode';
22

3-
var vscode = require('vscode')
3+
const typeScriptExtensionId = 'vscode.typescript-language-features';
4+
const pluginId = 'typescript-lit-html-plugin';
5+
const configurationSection = 'lit-html';
46

5-
function activate(context) {
6-
context.subscriptions.push(
7-
vscode.commands.registerCommand("es6stringhtml.insertComment", () => insertString()),
8-
vscode.commands.registerCommand("es6stringhtml.insertTemplate", () => insertString(true)),
9-
)
10-
}
7+
export async function activate(context) {
8+
const extension = vscode.extensions.getExtension(typeScriptExtensionId);
9+
10+
if (!extension) {
11+
return;
12+
}
13+
14+
await extension.activate();
15+
16+
if (!extension.exports || !extension.exports.getAPI) {
17+
return;
18+
}
19+
20+
const api = extension.exports.getAPI(0);
21+
22+
if (!api) {
23+
return;
24+
}
25+
26+
vscode.workspace.onDidChangeConfiguration(e => {
27+
if (e.affectsConfiguration(configurationSection)) {
28+
synchronizeConfiguration(api);
29+
}
30+
}, undefined, context.subscriptions);
1131

12-
function deactivate() {
13-
// nothing to dispose
32+
synchronizeConfiguration(api);
1433
}
1534

16-
/**
17-
* Insert comment or comment with string in editor
18-
* @param {boolean} full
19-
*/
20-
function insertString (full) {
21-
const string = full ? '/*html*/ ``' : '/*html*/'
22-
const editor = vscode.window.activeTextEditor
23-
const selections = editor.selections
24-
25-
editor.edit((editBuilder) => {
26-
selections.forEach((selection) => {
27-
editBuilder.replace(selection, '')
28-
editBuilder.insert(selection.active, string)
29-
})
30-
})
35+
function synchronizeConfiguration(api) {
36+
api.configurePlugin(pluginId, getConfiguration());
3137
}
3238

33-
module.exports = {
34-
activate: activate,
35-
deactivate: deactivate
39+
function getConfiguration() {
40+
const config = vscode.workspace.getConfiguration(configurationSection);
41+
const outConfig = {
42+
format: {}
43+
};
44+
45+
withConfigValue(config, 'tags', tags => { outConfig.tags = tags; });
46+
withConfigValue(config, 'format.enabled', enabled => { outConfig.format.enabled = enabled; });
47+
48+
return outConfig;
3649
}
50+
51+
function withConfigValue(config, key, withValue) {
52+
const configSetting = config.inspect(key);
53+
54+
if (!configSetting) {
55+
return;
56+
}
57+
58+
// Make sure the user has actually set the value.
59+
// VS Code will return the default values instead of `undefined`, even if user has not don't set anything.
60+
if (typeof configSetting.globalValue === 'undefined' && typeof configSetting.workspaceFolderValue === 'undefined' && typeof configSetting.workspaceValue === 'undefined') {
61+
return;
62+
}
63+
64+
const value = config.get(key, undefined);
65+
66+
if (typeof value !== 'undefined') {
67+
withValue(value);
68+
}
69+
}

syntaxes/es6-inline-css.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"tsx",
77
"html",
88
"vue",
9-
"svelte"
9+
"svelte",
10+
"php"
1011
],
1112
"injectionSelector": "L:source.js -comment -string, L:source.js -comment -string, L:source.jsx -comment -string, L:source.js.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
1213
"injections": {

syntaxes/es6-inline-glsl.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"tsx",
77
"html",
88
"vue",
9-
"svelte"
9+
"svelte",
10+
"php"
1011
],
1112
"injectionSelector": "L:source.js -comment -string, L:source.js -comment -string, L:source.jsx -comment -string, L:source.js.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
1213
"injections": {

syntaxes/es6-inline-sql.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"jsx",
55
"ts",
66
"tsx",
7+
"html",
78
"vue",
8-
"svelte"
9+
"svelte",
10+
"php"
911
],
1012
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.js.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
1113
"injections": {

syntaxes/es6-inline-xml.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"tsx",
77
"html",
88
"vue",
9-
"svelte"
9+
"svelte",
10+
"php"
1011
],
1112
"injectionSelector": "L:source.js -comment -string, L:source.js -comment -string, L:source.jsx -comment -string, L:source.js.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
1213
"injections": {

syntaxes/es6-js-injection.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"js",
44
"jsx",
55
"ts",
6-
"tsx",
6+
"tsx",
7+
"html",
78
"vue",
8-
"svelte"
9+
"svelte",
10+
"php"
911
],
1012
"injectionSelector": "L:source.js (string.quoted.double.html, string.quoted.single.html), L:source.jsx (string.quoted.double.html, string.quoted.single.html), L:source.js.jsx (string.quoted.double.html, string.quoted.single.html), L:source.ts (string.quoted.double.html, string.quoted.single.html), L:source.tsx (string.quoted.double.html, string.quoted.single.html)",
1113
"patterns": [

0 commit comments

Comments
 (0)