Skip to content

Commit

Permalink
Merge branch 'main' into php-service
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/ace-linters/types/language-service.d.ts
#	packages/demo/webworker-lsp/demo.ts
#	packages/demo/webworker-lsp/webworker.ts
  • Loading branch information
mkslanc committed Jan 31, 2023
2 parents b81f4c5 + b2ebf05 commit 25336b8
Show file tree
Hide file tree
Showing 16 changed files with 493 additions and 23 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Ace linters supports the following languages by default with webworkers approach
- Typescript, Javascript, JSX, TSX *powered by* [Typescript](https://github.com/Microsoft/TypeScript)
- Lua *powered by* [luaparse](https://github.com/fstirlitz/luaparse)
- YAML *powered by* [Yaml Language Server](https://github.com/redhat-developer/yaml-language-server)
- XML *powered by* [XML-Tools](https://github.com/SAP/xml-tools)

For WebSockets you could connect any of your Language Server folowing LSP

Expand Down
174 changes: 174 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions packages/ace-linters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Ace linters supports the following languages by default with webworkers approach
- Typescript, Javascript, JSX, TSX *powered by* [Typescript](https://github.com/Microsoft/TypeScript)
- Lua *powered by* [luaparse](https://github.com/fstirlitz/luaparse)
- YAML *powered by* [Yaml Language Server](https://github.com/redhat-developer/yaml-language-server)
- XML *powered by* [XML-Tools](https://github.com/SAP/xml-tools)

For WebSockets you could connect any of your Language Server folowing LSP

Expand All @@ -45,20 +46,30 @@ editor and an instance of LanguageProvider.

```javascript
import * as ace from "ace-code";
import {Mode as JsonMode} from "ace-code/src/mode/json";
import {Mode as TypescriptMode} from "ace-code/src/mode/typescript";
import {registerStyles, LanguageProvider} from "ace-linters";
import {ScriptTarget, JsxEmit} from "ace-linters/type-converters/typescript-converters";

// Create a web worker
let worker = new Worker(new URL('./webworker.js', import.meta.url));

// Create an Ace editor
let editor = ace.edit("container", {
mode: new JsonMode() // Set the mode of the editor to JSON
mode: new TypescriptMode() // Set the mode of the editor to Typescript
});

// Create a language provider for web worker
let languageProvider = LanguageProvider.for(worker);

// Set global options for the Typescript service
languageProvider.setGlobalOptions("typescript", {
compilerOptions: {
allowJs: true,
target: ScriptTarget.ESNext,
jsx: JsxEmit.Preserve
}
});

// Register the editor with the language provider
languageProvider.registerEditor(editor);

Expand Down
8 changes: 7 additions & 1 deletion packages/ace-linters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@
"vscode-json-languageservice": "4.2.1",
"vscode-languageserver-protocol": "^3.17.2",
"vscode-languageserver-textdocument": "^1.0.8",
"vscode-languageserver-types": "^3.17.2",
"showdown": "latest",
"luaparse": "latest",
"vscode-ws-jsonrpc": "^2.0.1",
"htmlhint": "^1.1.4"
"htmlhint": "^1.1.4",
"@xml-tools/constraints": "^1.1.1",
"@xml-tools/parser": "^1.0.11",
"@xml-tools/ast": "^5.0.5",
"@xml-tools/simple-schema": "^3.0.5"

},
"main": "build/ace-linters.js",
"types": "types/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/ace-linters/services/json/json-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class JsonService extends BaseService<JsonServiceOptions> implements AceL
}

private $getJsonSchemaUri(sessionID): string | undefined {
return this.getOption(sessionID, "jsonSchemaUri");
return this.getOption(sessionID, "schemaUri");
}

addDocument(document: TextDocumentItem) {
Expand All @@ -37,7 +37,7 @@ export class JsonService extends BaseService<JsonServiceOptions> implements AceL
}

private $configureService(sessionID: string) {
let schemas = this.getOption(sessionID, "jsonSchemas");
let schemas = this.getOption(sessionID, "schemas");
schemas?.forEach((el) => {
if (el.uri === this.$getJsonSchemaUri(sessionID)) {
el.fileMatch ??= [];
Expand All @@ -59,7 +59,7 @@ export class JsonService extends BaseService<JsonServiceOptions> implements AceL

removeDocument(document: TextDocumentIdentifier) {
super.removeDocument(document);
let schemas = this.getOption(document.uri, "jsonSchemas");
let schemas = this.getOption(document.uri, "schemas");
schemas?.forEach((el) => {
if (el.uri === this.$getJsonSchemaUri(document.uri)) {
el.fileMatch = el.fileMatch?.filter((pattern) => pattern != document.uri);
Expand Down
Loading

0 comments on commit 25336b8

Please sign in to comment.