3 ms·
It's a somewhat-supported thing; https://code.visualstudio.com/api/language-extensions/embedded-languages https://code.visualstudio.com/api/language-extensions/
by morelisp 4y ago
It's a somewhat-supported thing; https://code.visualstudio.com/api/language-extensions/embedded-languages https://code.visualstudio.com/api/language-extensions/embedd... has some introduction to how it's often done.
My (limited, from trying to hack a language server for a custom C preprocessor I have and reading a few others) experience is that language servers are not very good at true arbitrary composition but even the most monolithic ones are at least somewhat "wrappable". So a normal Java LSP wrapped in something that recognizes `executeQuery` and knows how to run additional checks on its string argument is possible. However, that thing running the additional checks on the string could not itself easily be an arbitrary SQL language server unless it was expressly designed for doing so.
The bigger issue is that you usually want some kind of semantic knowledge to cross the boundary! For example in HTML If I look for the definition of a string '#foo' in JS I want to jump to the element with ID foo; if I want to find uses of a .foo CSS selector I want to find the HTML documents with class="foo" and the JSX components with className="foo", etc. Isolating the servers misses most of the potential. You need a language-server-protocol-server protocol that can pass typed identifiers between each other; and now you've got not just programming problems but ontological problems which are the worst kind to have.
- mdaniel 4y agoThat was a super interesting link, thank you. For the ontological problem, I presume you're referring to how there are so many differing ideas of how to represent ASTs (apologies for mixing languages, these URLs were just handy): * https://lisperator.net/uglifyjs/ast#nodes https://lisperator.net/uglifyjs/ast#nodes * https://github.com/estree/estree#the-estree-spec https://github.com/estree/estree#the-estree-spec * ... likely others which makes it hard for ls1 to ask ls2 about "the for-of iteration variable Node" because ls2 could be using UglifyJS or ESTree or their own(!) AST nomenclature? And all of this is made worse by (e.g.) Java1.3 versus Java19 because languages are rarely static