Maven pom file support in vscode-xml
There has been a lot of discussion on using vscode-xml (with lemminx-maven) to improve the pom.xml
editing experience. There were various concerns (eg. performance, size, benefit, support) . I wanted to follow up with a comment advocating for the use of vscode-xml but pretty soon my “comment” started to look more like an article, so here we are.
I’d like to attempt to summarize what I see as clear advantages to depending directly on vscode-xml from vscode-maven. These features are not just optional nice-to-haves but necessary to delivering a good user experience.
This will be split into support coming directly from vscode-xml, and support coming from lemminx-maven, which is an extension contribution into the language server (LemMinX) that is provided by vscode-xml.
vscode-xml (LemMinX)
The XML support for VS Code has its own documentation, but the examples are not pom file specific, so I thought I’d recreate some of the examples to drive the point.
Formatting
- Being able to easily format a pom file is an extremely useful feature, and the extension makes it very easy. It also provides a lot of ways to customize the formatting
Navigation
- pom files can be fairly large. Jumping to a particular element immediately is nice. (ctrl+o & start typing in the outline)
Typing related features
- Syntax validation
- XML Tag Auto Close
- Auto Rename Tag
- Context aware completion
- vscode-xml knows about the schema that backs pom files, so it can make suggestions about what elements are valid for use.
lemminx-maven extension
lemminx-maven still needs a nice way of integrating into vscode-xml. I got it working locally by cloning the repository, running mvn clean verify -Pgenerate-vscode-jars -DskipTests
, and then ensuring it’s detected by vscode-xml using :
"xml.extension.jars": [
"$HOME/git/lemminx-maven/lemminx-maven/target/vscode-lemminx-maven-jars/*.jar"
]
Hover for dependencies, configuration & properties
- A minor feature, but a convenient way to get documentation on particular elements
Go to definition on artifacts
Completions on phase, goals, & properties
Context aware completions
- lemminx-maven takes context aware completions a step further by using the plugin metadata to make correct suggestions (eg. goals and configuration elements)
Overall, the completion support seems very similar in vscode-maven & lemminx-maven. vscode-maven is slightly more polished in showing a bit more information in the descriptions. lemminx-maven on the other hand supports completion of an entire <dependency>..</dependency>
element even within <dependencies>
tags (same for plugins).
I hope this fairly brief post has highlighted the power of vscode-xml as well as its extensibility.