mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
HTML1
This commit is contained in:
@ -4,8 +4,11 @@ Heavily documented sample code for https://code.visualstudio.com/api/language-ex
|
||||
|
||||
## Functionality
|
||||
|
||||
This Language Server works for HTML file. It has the following language features:
|
||||
- Completions for HTML
|
||||
This extension contributes a new language, `html1`. The new language is for illustration purpose and has basic syntax highlighting.
|
||||
|
||||
This Language Server works for `html1` file. HTML1 is like HTML file but has file extension `.html1`. You can create a `test.html1` file to play with below functionaltiies:
|
||||
|
||||
- Completions for HTML tags
|
||||
- Completions for CSS in `<style>` tag
|
||||
- Diagnostics for CSS
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ export function activate(context: ExtensionContext) {
|
||||
// Options to control the language client
|
||||
let clientOptions: LanguageClientOptions = {
|
||||
// Register the server for plain text documents
|
||||
documentSelector: [{ scheme: 'file', language: 'html' }]
|
||||
documentSelector: [{ scheme: 'file', language: 'html1' }]
|
||||
};
|
||||
|
||||
// Create the language client and start the client.
|
||||
|
||||
@ -15,10 +15,26 @@
|
||||
"vscode": "^1.43.0"
|
||||
},
|
||||
"activationEvents": [
|
||||
"onLanguage:html"
|
||||
"onLanguage:html1"
|
||||
],
|
||||
"main": "./client/out/extension",
|
||||
"contributes": {},
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "html1",
|
||||
"extensions": [
|
||||
".html1"
|
||||
]
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "html1",
|
||||
"scopeName": "text.html1.basic",
|
||||
"path": "./syntaxes/html1.tmLanguage.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "cd client && npm install && cd .. && npm run compile",
|
||||
"compile": "tsc -b",
|
||||
|
||||
@ -63,7 +63,7 @@ async function validateTextDocument(textDocument: TextDocument) {
|
||||
try {
|
||||
const version = textDocument.version;
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
if (textDocument.languageId === 'html') {
|
||||
if (textDocument.languageId === 'html1') {
|
||||
const modes = languageModes.getAllModesInDocument(textDocument);
|
||||
const latestTextDocument = documents.get(textDocument.uri);
|
||||
if (latestTextDocument && latestTextDocument.version === version) {
|
||||
|
||||
2643
lsp-embedded-language-service/syntaxes/html1.tmLanguage.json
Normal file
2643
lsp-embedded-language-service/syntaxes/html1.tmLanguage.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user