增加scss支持
parent
cec2620c5f
commit
2b1278bc74
18
README.md
18
README.md
|
@ -1,2 +1,18 @@
|
||||||
## string-html-css
|
## string-html-css
|
||||||
一个高亮js代码中的 html/css/scss/sass/less的字符串, 并支持emmet.
|
一个高亮js代码中的 html/css/scss/sass/less的字符串, 并支持emmet.
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
const foo = css`
|
||||||
|
.foo { color: red }
|
||||||
|
`
|
||||||
|
|
||||||
|
const foo = scss`
|
||||||
|
.foo { color: red }
|
||||||
|
`
|
||||||
|
|
||||||
|
const foo = html`
|
||||||
|
<div>hello</div>
|
||||||
|
`
|
||||||
|
|
||||||
|
```
|
|
@ -131,7 +131,8 @@ export class HTMLStyleCompletionItemProvider implements CompletionItemProvider {
|
||||||
|
|
||||||
export class CSSCompletionItemProvider implements CompletionItemProvider {
|
export class CSSCompletionItemProvider implements CompletionItemProvider {
|
||||||
private _CSSLanguageService: CSSLanguageService = GetCSSLanguageService()
|
private _CSSLanguageService: CSSLanguageService = GetCSSLanguageService()
|
||||||
private _expression = /(\/\*\s*(css|less|scss)\s*\*\/\s*`|css\s*`)([^`]*)(`)/g
|
private _expression =
|
||||||
|
/(\/\*\s*(css|less|scss|sass)\s*\*\/\s*`|(scss|sass|less|css)\s*`)([^`]*)(`)/g
|
||||||
private _cache = new CompletionsCache()
|
private _cache = new CompletionsCache()
|
||||||
|
|
||||||
public provideCompletionItems(
|
public provideCompletionItems(
|
||||||
|
|
17
src/util.ts
17
src/util.ts
|
@ -54,10 +54,7 @@ export function MatchOffset(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Match(
|
export function Match(regex: RegExp, data: string): RegExpMatchArray {
|
||||||
regex: RegExp,
|
|
||||||
data: string
|
|
||||||
): RegExpMatchArray {
|
|
||||||
regex.exec(null)
|
regex.exec(null)
|
||||||
|
|
||||||
let match: RegExpExecArray
|
let match: RegExpExecArray
|
||||||
|
@ -115,9 +112,15 @@ export function TranslateHTMLTextEdits(
|
||||||
offset: number
|
offset: number
|
||||||
): TextEdit[] {
|
): TextEdit[] {
|
||||||
return input.map((item: HTMLTextEdit) => {
|
return input.map((item: HTMLTextEdit) => {
|
||||||
const startPosition = new Position(item.range.start.line + offset, item.range.start.character);
|
const startPosition = new Position(
|
||||||
const endPosition = new Position(item.range.end.line + offset - 1, item.range.end.character);
|
item.range.start.line + offset,
|
||||||
const itemRange = new Range(startPosition, endPosition);
|
item.range.start.character
|
||||||
|
)
|
||||||
|
const endPosition = new Position(
|
||||||
|
item.range.end.line + offset - 1,
|
||||||
|
item.range.end.character
|
||||||
|
)
|
||||||
|
const itemRange = new Range(startPosition, endPosition)
|
||||||
return new TextEdit(itemRange, item.newText)
|
return new TextEdit(itemRange, item.newText)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
{
|
{
|
||||||
"fileTypes": [
|
"fileTypes": ["js", "jsx", "ts", "tsx"],
|
||||||
"js",
|
|
||||||
"jsx",
|
|
||||||
"ts",
|
|
||||||
"tsx"
|
|
||||||
],
|
|
||||||
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"contentName": "meta.embedded.block.css",
|
"contentName": "meta.embedded.block.css",
|
||||||
"begin": "(?x)(\\s*?(\\w+\\.)?(?:css|\/\\*\\s*css\\s*\\*\/)\\s*)(`)",
|
"begin": "(?x)(\\s*?(\\w+\\.)?(?:css|/\\*\\s*css\\s*\\*/)\\s*)(`)",
|
||||||
"beginCaptures": {
|
"beginCaptures": {
|
||||||
"0": {
|
"0": {
|
||||||
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
||||||
|
@ -38,4 +33,4 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scopeName": "es6.inline.css"
|
"scopeName": "es6.inline.css"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
{
|
{
|
||||||
"fileTypes": [
|
"fileTypes": ["js", "jsx", "ts", "tsx"],
|
||||||
"js",
|
|
||||||
"jsx",
|
|
||||||
"ts",
|
|
||||||
"tsx"
|
|
||||||
],
|
|
||||||
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
||||||
"injections": {
|
"injections": {
|
||||||
"L:source": {
|
"L:source": {
|
||||||
|
@ -19,7 +14,7 @@
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"contentName": "meta.embedded.block.html",
|
"contentName": "meta.embedded.block.html",
|
||||||
"begin": "(?x)(\\s*?(\\w+\\.)?(?:html|\/\\*\\s*html\\s*\\*\/)\\s*)(`)",
|
"begin": "(?x)(\\s*?(\\w+\\.)?(?:html|/\\*\\s*html\\s*\\*/)\\s*)(`)",
|
||||||
"beginCaptures": {
|
"beginCaptures": {
|
||||||
"0": {
|
"0": {
|
||||||
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
||||||
|
@ -48,4 +43,4 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scopeName": "es6.inline.html"
|
"scopeName": "es6.inline.html"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
{
|
{
|
||||||
"fileTypes": [
|
"fileTypes": ["js", "jsx", "ts", "tsx"],
|
||||||
"js",
|
|
||||||
"jsx",
|
|
||||||
"ts",
|
|
||||||
"tsx"
|
|
||||||
],
|
|
||||||
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"contentName": "meta.embedded.block.css",
|
"contentName": "meta.embedded.block.css",
|
||||||
"begin": "(?x)(\\s*?(\\w+\\.)?(?:\/\\*\\s*less\\s*\\*\/)\\s*)(`)",
|
"begin": "(?x)(\\s*?(\\w+\\.)?(?:less|/\\*\\s*less\\s*\\*/)\\s*)(`)",
|
||||||
"beginCaptures": {
|
"beginCaptures": {
|
||||||
"0": {
|
"0": {
|
||||||
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
||||||
|
@ -38,4 +33,4 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scopeName": "es6.inline.less"
|
"scopeName": "es6.inline.less"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
{
|
{
|
||||||
"fileTypes": [
|
"fileTypes": ["js", "jsx", "ts", "tsx"],
|
||||||
"js",
|
|
||||||
"jsx",
|
|
||||||
"ts",
|
|
||||||
"tsx"
|
|
||||||
],
|
|
||||||
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.ts -comment -string, L:source.tsx -comment -string",
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"contentName": "meta.embedded.block.css",
|
"contentName": "meta.embedded.block.css",
|
||||||
"begin": "(?x)(\\s*?(\\w+\\.)?(?:\/\\*\\s*scss\\s*\\*\/)\\s*)(`)",
|
"begin": "(?x)(\\s*?(\\w+\\.)?(?:scss|/\\*\\s*scss\\s*\\*/)\\s*)(`)",
|
||||||
"beginCaptures": {
|
"beginCaptures": {
|
||||||
"0": {
|
"0": {
|
||||||
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
|
||||||
|
@ -38,4 +33,4 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scopeName": "es6.inline.scss"
|
"scopeName": "es6.inline.scss"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue