diff --git a/editors/vscode/CHANGELOG.md b/editors/vscode/CHANGELOG.md index 148b403..877e5b3 100644 --- a/editors/vscode/CHANGELOG.md +++ b/editors/vscode/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to the "super" extension will be documented in this file. + +## [v0.3.0] +Now the LSP server is bundled in the extension, no need for a separate download anymore. + +## [v0.2.0] +Introduced correct syntax highlighting grammar. + ## [v0.1.3] Add 'path' setting for this extension to allow specifying location of the Super CLI executable manually. diff --git a/editors/vscode/README.md b/editors/vscode/README.md index 1c2a507..5398ddc 100644 --- a/editors/vscode/README.md +++ b/editors/vscode/README.md @@ -1,11 +1,12 @@ -# SuperHTML LSP VSCode Extension - -This extension gives you diagnostics and autoformatting for HTML files. +# SuperHTML VSCode LSP +Language Server for HTML and SuperHTML Templates. ![](../../.github/vscode-autoformat.gif) -**NOTE: you will need to get the `superhtml` CLI tool and have it available in your PATH (or set the path manually in your VSCode settings)!** +# NOTE: This extension bundles the full language server + +But you can optionally also get the CLI tool so that you can access it outside of VSCode. For prebuilt binaries and more info: https://github.com/kristoff-it/superhtml diff --git a/editors/vscode/package-lock.json b/editors/vscode/package-lock.json index d09c98f..4ceb30e 100644 --- a/editors/vscode/package-lock.json +++ b/editors/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "super", - "version": "0.1.4", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "super", - "version": "0.1.4", + "version": "0.2.0", "dependencies": { "@vscode/vsce": "^2.24.0", "@vscode/wasm-wasi-lsp": "^0.1.0-pre.7", @@ -15,13 +15,13 @@ "lodash-es": "^4.17.21", "lodash.debounce": "^4.0.8", "mkdirp": "^2.1.3", - "vscode-languageclient": "^10.0.0-next.13", + "vscode-languageclient": "^10.0.0-next.12", "which": "^3.0.0" }, "devDependencies": { "@types/mocha": "^2.2.48", "@types/node": "^18.0.0", - "@types/vscode": "^1.68.0", + "@types/vscode": "^1.92.0", "@types/which": "^2.0.1", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", @@ -29,7 +29,7 @@ "vscode-test": "^1.4.0" }, "engines": { - "vscode": "^1.87.0" + "vscode": "^1.92.0" } }, "node_modules/@azure/abort-controller": { @@ -466,9 +466,9 @@ "license": "MIT" }, "node_modules/@types/vscode": { - "version": "1.91.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.91.0.tgz", - "integrity": "sha512-PgPr+bUODjG3y+ozWUCyzttqR9EHny9sPAfJagddQjDwdtf66y2sDKJMnFZRuzBA2YtBGASqJGPil8VDUPvO6A==", + "version": "1.92.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.92.0.tgz", + "integrity": "sha512-DcZoCj17RXlzB4XJ7IfKdPTcTGDLYvTOcTNkvtjXWF+K2TlKzHHkBEXNWQRpBIXixNEUgx39cQeTFunY0E2msw==", "dev": true, "license": "MIT" }, @@ -4054,35 +4054,35 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "9.0.0-next.6", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-9.0.0-next.6.tgz", - "integrity": "sha512-KCSvUNsFiVciG9iqjJKBZOd66CN3ZKohDlYRmoOi+pd8l15MFLZ8wRG4c+wuzePGba/8WcCG2TM+C/GVlvuaeA==", + "version": "9.0.0-next.5", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-9.0.0-next.5.tgz", + "integrity": "sha512-Sl/8RAJtfF/2x/TPBVRuhzRAcqYR/QDjEjNqMcoKFfqsxfVUPzikupRDQYB77Gkbt1RrW43sSuZ5uLtNAcikQQ==", "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageclient": { - "version": "10.0.0-next.13", - "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-10.0.0-next.13.tgz", - "integrity": "sha512-KLsOMJoYpkk36PIgcOjyZ4AekOfzp4kdWdRRbVKeVvSIrwrn/4RSZr0NlD6EvUBBJSsJW4WDrYY7Y3znkqa6+w==", + "version": "10.0.0-next.12", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-10.0.0-next.12.tgz", + "integrity": "sha512-q7cVYCcYiv+a+fJYCbjMMScOGBnX162IBeUMFg31mvnN7RHKx5/CwKaCz+r+RciJrRXMqS8y8qpEVGgeIPnbxg==", "license": "MIT", "dependencies": { "minimatch": "^9.0.3", "semver": "^7.6.0", - "vscode-languageserver-protocol": "3.17.6-next.11" + "vscode-languageserver-protocol": "3.17.6-next.10" }, "engines": { "vscode": "^1.91.0" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.6-next.11", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.6-next.11.tgz", - "integrity": "sha512-GeJxEp1TiLsp79f8WG5n10wLViXfgFKb99hU9K8m7KDWM95/QFEqWkm79f9LVm54tUK74I91a9EeiQLCS/FABQ==", + "version": "3.17.6-next.10", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.6-next.10.tgz", + "integrity": "sha512-KOrrWn4NVC5jnFC5N6y/fyNKtx8rVYr67lhL/Z0P4ZBAN27aBsCnLBWAMIkYyJ1K8EZaE5r7gqdxrS9JPB6LIg==", "license": "MIT", "dependencies": { - "vscode-jsonrpc": "9.0.0-next.6", + "vscode-jsonrpc": "9.0.0-next.5", "vscode-languageserver-types": "3.17.6-next.5" } }, diff --git a/editors/vscode/package-old.json b/editors/vscode/package-old.json deleted file mode 100644 index 281922b..0000000 --- a/editors/vscode/package-old.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "name": "super", - "displayName": "SuperHTML", - "description": "HTML Language Server", - "repository": "https://github.com/kristoff-it/superhtml/", - "publisher": "LorisCro", - "version": "0.1.5", - "engines": { - "vscode": "^1.87.0" - }, - "categories": [ - "Formatters" - ], - "activationEvents": [ - "onLanguage:html" - ], - "contributes": { - "configurationDefaults": { - "[html]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "LorisCro.super", - "files.eol": "\n" - }, - "[superhtml]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "LorisCro.super", - "files.eol": "\n" - } - }, - "languages": [ - { - "id": "superhtml", - "aliases": [ - "SuperHTML", - "Super HTML", - "superhtml", - "shtml" - ], - "extensions": [ - ".shtml" - ], - "configuration": "./superhtml.language-configuration.json" - } - ], - "grammars": [ - { - "language": "superhtml", - "scopeName": "text.superhtml", - "path": "./syntaxes/superhtml.tmLanguage.json" - } - ], - "configuration": { - "type": "object", - "title": "SuperHTML", - "properties": { - "super.path": { - "scope": "machine-overridable", - "default": "superhtml", - "type": "string", - "description": "Set a custom path to the superhtml binary. The string \"superhtml\" means serarching for it in PATH." - } - } - } - }, - "main": "./out/extension", - "devDependencies": { - "@types/mocha": "^2.2.48", - "@types/node": "^18.0.0", - "@types/vscode": "^1.68.0", - "@types/which": "^2.0.1", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "eslint": "^8.49.0", - "vscode-test": "^1.4.0" - }, - "dependencies": { - "@vscode/vsce": "^2.24.0", - "camelcase": "^7.0.1", - "esbuild": "^0.12.1", - "lodash-es": "^4.17.21", - "lodash.debounce": "^4.0.8", - "mkdirp": "^2.1.3", - "vscode-languageclient": "^9.0.1", - "which": "^3.0.0" - }, - "scripts": { - "vscode:prepublish": "npm run build-base -- --minify", - "build-base": "esbuild --bundle --external:vscode src/extension.ts --outdir=out --platform=node --format=cjs", - "build": "npm run build-base -- --sourcemap", - "watch": "npm run build-base -- --sourcemap --watch", - "lint": "eslint . --ext .ts" - } -} diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 10e2947..25af3c9 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -1,12 +1,12 @@ { "name": "super", "displayName": "SuperHTML", - "description": "Actually Functional Language Server for HTML Files", + "description": "Language Server for HTML and SuperHTML Templates.", "repository": "https://github.com/kristoff-it/superhtml/", "publisher": "LorisCro", - "version": "0.1.4", + "version": "0.3.0", "engines": { - "vscode": "^1.87.0" + "vscode": "^1.92.0" }, "categories": [ "Formatters" @@ -40,7 +40,7 @@ "extensions": [ ".shtml" ], - "configuration": "./superhtml1.language-configuration.json" + "configuration": "./superhtml.language-configuration.json" } ], "grammars": [ @@ -71,19 +71,7 @@ "meta.tag string.quoted": "other" } } - ], - "configuration": { - "type": "object", - "title": "Super", - "properties": { - "super.path": { - "scope": "machine-overridable", - "default": "super", - "type": "string", - "description": "Set a custom path to the super binary. The string \"super\" means lookup Super in PATH." - } - } - } + ] }, "main": "./out/extension", "extensionDependencies": [ @@ -92,7 +80,7 @@ "devDependencies": { "@types/mocha": "^2.2.48", "@types/node": "^18.0.0", - "@types/vscode": "^1.68.0", + "@types/vscode": "^1.92.0", "@types/which": "^2.0.1", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", @@ -107,7 +95,7 @@ "lodash-es": "^4.17.21", "lodash.debounce": "^4.0.8", "mkdirp": "^2.1.3", - "vscode-languageclient": "^10.0.0-next.13", + "vscode-languageclient": "^10.0.0-next.12", "which": "^3.0.0" }, "scripts": { diff --git a/editors/vscode/src/extension-old.ts b/editors/vscode/src/extension-old.ts deleted file mode 100644 index 0764419..0000000 --- a/editors/vscode/src/extension-old.ts +++ /dev/null @@ -1,76 +0,0 @@ -import * as path from 'path'; -import { workspace, ExtensionContext, window, languages } from 'vscode'; -import { SuperFormatProvider } from './formatter'; - -import { - LanguageClient, - LanguageClientOptions, - ServerOptions -} from 'vscode-languageclient/node'; -import { getSuperPath } from './util'; - -let client: LanguageClient; - -const logChannel = window.createOutputChannel("SuperHTML"); - -export function activate(context: ExtensionContext) { - - // If the extension is launched in debug mode then the debug server options are used - // Otherwise the run options are used - const serverOptions: ServerOptions = { - command: getSuperPath(), - args: ["lsp"], - }; - - // Options to control the language client - const clientOptions: LanguageClientOptions = { - // Register the server for plain text documents - documentSelector: [ - { scheme: "file", language: 'html' }, - { scheme: "file", language: 'superhtml' }, - ], - outputChannel: logChannel, - // synchronize: { - // // Notify the server about file changes to '.clientrc files contained in the workspace - // fileEvents: workspace.createFileSystemWatcher('**/.zgy') - // } - }; - - // Create the language client and start the client. - const client = new LanguageClient( - "superhtml", - "SuperHTML Language Server", - serverOptions, - clientOptions - ); - - client.start().catch(reason => { - window.showWarningMessage(`Failed to run SuperHTML Language Server: ${reason}`); - }); - - context.subscriptions.push( - languages.registerDocumentFormattingEditProvider( - [{ scheme: "file", language: "html" }], - new SuperFormatProvider(client), - ), - languages.registerDocumentRangeFormattingEditProvider( - [{ scheme: "file", language: "html" }], - new SuperFormatProvider(client), - ), - languages.registerDocumentFormattingEditProvider( - [{ scheme: "file", language: "superhtml" }], - new SuperFormatProvider(client), - ), - languages.registerDocumentRangeFormattingEditProvider( - [{ scheme: "file", language: "superhtml" }], - new SuperFormatProvider(client), - ), - ); -} - -export function deactivate(): Thenable | undefined { - if (!client) { - return undefined; - } - return client.stop(); -} diff --git a/editors/vscode/src/extension.ts b/editors/vscode/src/extension.ts index 53b8130..8d0c017 100644 --- a/editors/vscode/src/extension.ts +++ b/editors/vscode/src/extension.ts @@ -47,9 +47,6 @@ export async function activate(context: ExtensionContext) { channel.append(decoder.decode(data)); }); - // process.stdin!.write("banana".repeat(10000)); - // process.stdin!.write("cake"); - return startServer(process); }; diff --git a/editors/vscode/syntaxes/superhtml.tmLanguage.json b/editors/vscode/syntaxes/superhtml.tmLanguage.json index 05039f0..a22e041 100644 --- a/editors/vscode/syntaxes/superhtml.tmLanguage.json +++ b/editors/vscode/syntaxes/superhtml.tmLanguage.json @@ -2054,6 +2054,29 @@ } ] }, + { + "begin": "(?i)(<)(super|extend)(?=\\s|/?>)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.html" + }, + "2": { + "name": "keyword.control" + } + }, + "end": "/?>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.html" + } + }, + "name": "meta.tag.metadata.$2.void.html", + "patterns": [ + { + "include": "#attribute" + } + ] + }, { "begin": "(?i)(<)(noscript|title)(?=\\s|/?>)", "beginCaptures": { diff --git a/src/wasm.zig b/src/wasm.zig index be763b5..7e52c68 100644 --- a/src/wasm.zig +++ b/src/wasm.zig @@ -5,6 +5,5 @@ const lsp_exe = @import("cli/lsp.zig"); pub fn main() !void { const gpa = std.heap.wasm_allocator; - std.debug.print("yep new build 2", .{}); try lsp_exe.run(gpa, &.{}); }