diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..670dfd8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = crlf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7a835bc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# General +* text=auto + +# Project +package-lock.json -diff diff --git a/.gitignore b/.gitignore index 177c940..2d532f1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ test/ *.local.* *.js -*.yaml +*.d.ts +*.json diff --git a/changelog.md b/changelog.md index 8c1bd83..c67f77f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 1.4.1 +- Fixed newlines breaking attribute syntax highlighting (#1). +- Fixed selectors not having syntax highlighting applied when not at the start of a line. +- Fixed empty parameters having superfluous spaces added when formatted (#2). +- Fixed pseudo-classes after parenthetical selectors having invalid spaces added (#2). + ## 1.4.0 - Added breakpoint snippet. - Added previous element selector syntax highlighting. diff --git a/formatters/formatter.ts b/formatters/formatter.ts index ce68fbb..8dbc929 100644 --- a/formatters/formatter.ts +++ b/formatters/formatter.ts @@ -15,6 +15,7 @@ export function activate(context: vscode.ExtensionContext) { .replace(/(?<=(?:\$\(|\))[^()]+) *\)/g, ' )') .replace(/\$\(\s+([^$()|]+)\s+\)/g, '$($1)') .replace(/ *\| */g, ' | ') + .replace(/ \|/g, ' |') .replace(/(?<=\|)(.*?) *=\s*/g, '$1 = ') .replace(/^ ([|)])/gm, '$1') @@ -23,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) { // CSS .replace(/ *{/g, ' {') - .replace(/(?<=[{(][^}]*)([a-z-]+)\s*:(?!\/\/) */g, '$1: ') + .replace(/(?<=[{(][^})]*)([a-z-]+)\s*:(?!\/\/) +/g, '$1: ') .replace(/; *(?!})/g, '; ') .replace(/\s*;/g, ';') .replace(/!\s*important/g, '!important') diff --git a/package-lock.json b/package-lock.json index 3145bcb..9b6b905 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,28 +1,27 @@ { "name": "novasheets", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "novasheets", - "version": "1.4.0", + "version": "1.4.1", "license": "ISC", - "dependencies": { - "@types/vscode": "^1.54.0", - "typescript": "^4.2.3" - }, "devDependencies": { + "@types/vscode": "^1.54.0", + "typescript": "~4.3.2", "yamljs": "^0.3.0" }, "engines": { - "vscode": "^1.52.0" + "vscode": "^1.54.0" } }, "node_modules/@types/vscode": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.54.0.tgz", - "integrity": "sha512-sHHw9HG4bTrnKhLGgmEiOS88OLO/2RQytUN4COX9Djv81zc0FSZsSiYaVyjNidDzUSpXsySKBkZ31lk2/FbdCg==" + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.56.0.tgz", + "integrity": "sha512-Q5VmQxOx+L1Y6lIJiGcJzwcyV3pQo/eiW8P+7sNLhFI16tJCwtua2DLjHRcpjbCLNVYpQM73kzfFo1Z0HyP9eQ==", + "dev": true }, "node_modules/argparse": { "version": "1.0.10", @@ -134,9 +133,10 @@ "dev": true }, "node_modules/typescript": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz", - "integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.2.tgz", + "integrity": "sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==", + "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -168,9 +168,10 @@ }, "dependencies": { "@types/vscode": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.54.0.tgz", - "integrity": "sha512-sHHw9HG4bTrnKhLGgmEiOS88OLO/2RQytUN4COX9Djv81zc0FSZsSiYaVyjNidDzUSpXsySKBkZ31lk2/FbdCg==" + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.56.0.tgz", + "integrity": "sha512-Q5VmQxOx+L1Y6lIJiGcJzwcyV3pQo/eiW8P+7sNLhFI16tJCwtua2DLjHRcpjbCLNVYpQM73kzfFo1Z0HyP9eQ==", + "dev": true }, "argparse": { "version": "1.0.10", @@ -270,9 +271,10 @@ "dev": true }, "typescript": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz", - "integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==" + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.2.tgz", + "integrity": "sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==", + "dev": true }, "wrappy": { "version": "1.0.2", diff --git a/package.json b/package.json index 92786b9..1fa1aa2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Syntax highlighter and formatter for NovaSheets files", "publisher": "Nixinova", "repository": "NovaSheets-vscode", - "version": "1.4.0", + "version": "1.4.1", "license": "ISC", "scripts": { "vscode:prepublish": "npm run compile", @@ -54,7 +54,7 @@ }, "devDependencies": { "@types/vscode": "^1.54.0", - "typescript": "^4.2.3", + "typescript": "~4.3.2", "yamljs": "^0.3.0" } } diff --git a/syntaxes/novasheets.tmLanguage.yaml b/syntaxes/novasheets.tmLanguage.yaml index c0d3a8c..2e9c0a4 100644 --- a/syntaxes/novasheets.tmLanguage.yaml +++ b/syntaxes/novasheets.tmLanguage.yaml @@ -20,9 +20,9 @@ repository: css: patterns: - include: '#selectors' + - include: '#attributes' - include: '#at-rules' - include: '#functions' - - include: '#block' declarations: patterns: @@ -48,7 +48,7 @@ repository: # Parser constant - name: meta.preprocessor.novasheets - match: '(@option)\s+([A-Z_]+)\s+(?=\d+|true|false)' + match: '(@option)\s+([A-Z_]+)\s+' captures: 1: { name: keyword.control.declaration.option.novasheets } 2: { name: variable.parameter.option.novasheets } @@ -163,12 +163,12 @@ repository: selectors: patterns: - name: meta.selector.novasheets - begin: '(?\[\]])(?![^}]*$)' + begin: '(?\[\]])(?=.*{)' end: '(?=\{)' patterns: # Element - name: entity.name.tag.css.selector.element.css - match: '(?<=\s|^|,)[A-Za-z]+[0-9]?(?=\s|[\[,.#:+~>])' + match: '\w+(?=[\s{\[,.#:+~>])' # Class - name: entity.name.tag.css.selector.class.css match: '(\.)(?>\\\s|[^\s,.#:+~>\[\]])+' @@ -222,31 +222,12 @@ repository: - include: '#novasheets' - include: '#chars' - block: - name: meta.block.css - begin: '{' - beginCaptures: - 0: { name: punctuation.definition.block.begin.css } - end: '}' - endCaptures: - 0: { name: punctuation.definition.block.end.css } + attributes: patterns: - # Attribute - - name: meta.language.attribute.name.css - match: '(?<=[;{])\s*([\w-]+)\s*(:)' + - name: entity.other.attribute-name.css + match: '([\w-]+)(:)' captures: - 1: { name: entity.other.attribute-name.css } 2: { name: punctuation.terminator.attribute.name.end.css } - # Value - - name: meta.language.attribute.value.css - begin: '(?<=[{:;])' - end: ';|(?=})' - endCaptures: - 0: { name: punctuation.terminator.attribute.value.end.css } - patterns: - - include: '#novasheets' - - include: '#functions' - - include: '#chars' at-rules: patterns: diff --git a/tsconfig.json b/tsconfig.json index 558c2bf..5f8eac3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ /* Basic Options */ //"incremental": true, - "target": "es2017", + "target": "es2018", "module": "commonjs", //"lib": [], //"allowJs": true,