Hi folks,
for openshift.io, I've been working on allowing to register
language servers to particular file names, not only extensions. I
would like to fold these changes in to the main branch and would
like your feedback on the following idea:
The code that registers language servers for particular
extensions lives in
org.eclipse.che.plugin.languageserver.ide.LanguageServerFileTypeRegister.
There are two problems with this code:
- It does not allow for registering a language server for single
file names like "pom.xml" or "package.json".
- It only registers that given mime types as a Orion content
type for the first extension given, not all of them. So if I had
a language server that handles xsd and xml files, I would have
no way to have different syntax highlighting, but the same
language server.
In che, two mechanisms are used to differentiate content types:
- org.eclipse.che.ide.api.filetypes.FileType is used to
determine which editor is opened. This implies most of the
language server behaviour, like content assist, etc.
- org.eclipse.che.ide.editor.orion.client.jso.OrionContentTypeOverlay
is used to determine syntax highlighting and to dispatch to
hover and occurrences implementations. Content types are
identified by a "mime type" like "text/xml"
In order to solve these problems, I would like to propose the
following: extension points:
- Language Descriptor: maps a file type descriptor to a
language: example:
{
"fileNames": ["pom.xml"],
"extensions:" [],
"languageId": "mavenpom",
"name:" "Maven Pom File",
"syntax highlighting": null,
"contentType": "application/x-pom",
"extends": "text/xml"
}
-> this descriptor would be used to generate both an Orion
content type and a file typ in a 1:1 fashion.
- Language Server: maps a language id to a particular language
server launcher.
I believe this change would both serve the immediate need of
openshift.io, and would be a nicer an more clear way to make
language servers to Che. In addition, it would be a first step
towards supporting multiple language servers per file type.
thx for your feedback:
/Thomas