This commit is contained in:
Pine Wu
2020-04-07 12:45:21 -07:00
parent 864892d0dd
commit 538bef48c4
5 changed files with 2668 additions and 6 deletions

View File

@ -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

View File

@ -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.

View File

@ -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",

View File

@ -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) {

File diff suppressed because one or more lines are too long