Skip to content

Commit

Permalink
HTML1 for request forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Apr 7, 2020
1 parent 538bef4 commit adddb55
Show file tree
Hide file tree
Showing 5 changed files with 2,667 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lsp-embedded-request-forwarding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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:
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
- Completions for CSS in `<style>` tag

Expand Down
2 changes: 1 addition & 1 deletion lsp-embedded-request-forwarding/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function activate(context: ExtensionContext) {
});

let clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'html' }],
documentSelector: [{ scheme: 'file', language: 'html1' }],
middleware: {
provideCompletionItem: async (document, position, context, token, next) => {
const originalUri = document.uri.toString();
Expand Down
20 changes: 18 additions & 2 deletions lsp-embedded-request-forwarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lsp-embedded-request-forwarding/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit adddb55

Please sign in to comment.