Skip to content

Commit f5f566d

Browse files
committed
Doc for xml.javaExtensions
Signed-off-by: azerr <azerr@redhat.com>
1 parent d2dd551 commit f5f566d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@ Since 0.9.1:
8080
* `xml.validation.disallowDocTypeDecl`: Enable/disable if a fatal error is thrown if the incoming document contains a DOCTYPE declaration. Default is `false`.
8181
* `xml.validation.resolveExternalEntities`: Enable/disable resolve of external entities. Default is `false`.
8282

83+
## Custom XML Extensions
84+
85+
The [LSP4XML Language Server](https://github.com/angelozerr/lsp4xml) can be extended to support custom completion, hover, validation, rename, etc by using the Java SPI feature. vscode-xml gives the capability to start the XML language server with your custom JAR which provides your custom XML support.
86+
87+
To do that:
88+
89+
* create a Java project which provides a custom XML extension providing your custom completion, hover, validation, rename, etc:
90+
* create the XML extension like [MavenPlugin](https://github.com/angelozerr/lsp4xml-extensions-maven/blob/master/org.eclipse.lsp4xml.extensions.maven/src/main/java/org/eclipse/lsp4xml/extensions/maven/MavenPlugin.java).
91+
* register your custom completion in the XML extension like [MavenCompletionParticipant](https://github.com/angelozerr/lsp4xml-extensions-maven/blob/master/org.eclipse.lsp4xml.extensions.maven/src/main/java/org/eclipse/lsp4xml/extensions/maven/MavenCompletionParticipant.java#L28)
92+
* register your custom XML extension with SPI in the [/META-INF/services/org.eclipse.lsp4xml.services.extensions.IXMLExtension](https://github.com/angelozerr/lsp4xml-extensions-maven/blob/master/org.eclipse.lsp4xml.extensions.maven/src/main/resources/META-INF/services/org.eclipse.lsp4xml.services.extensions.IXMLExtension) file.
93+
* build a JAR `your-custom-xml-extension.jar`.
94+
95+
* create a `vscode extension` which embeds the `your-custom-xml-extension.jar` JAR and declares this JAR path in the `package.json`:
96+
97+
```json
98+
"contributes": {
99+
"xml.javaExtensions": [
100+
"./jar/your-custom-xml-extension"
101+
]
102+
}
103+
```
104+
105+
You can see the [vscode-xml-maven](https://github.com/angelozerr/vscode-xml-maven) sample which registers custom maven completion [MavenCompletionParticipant](https://github.com/angelozerr/lsp4xml-extensions-maven/blob/master/org.eclipse.lsp4xml.extensions.maven/src/main/java/org/eclipse/lsp4xml/extensions/maven/MavenCompletionParticipant.java#L28) for scope:
106+
107+
![VScode XML Maven](images/vscode-xml-maven.gif)
108+
83109
## Contributing
84110

85111
This is an open source project open to anyone. Contributions are extremely welcome!

images/vscode-xml-maven.gif

44.7 KB
Loading

0 commit comments

Comments
 (0)