-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(language-server): simplify startServer
abstraction
#113
Conversation
Please note that this is still not a stable API... 😅 we may randomly discover API improvements in alpha releases. |
I understand the reasons for wanting to use a TypeScript plugin, but when trying mdx-js/mdx-analyzer#371, I found it to not be very stable yet. Can we keep using the TypeScript service with this new abstraction? Also what would the registration of other language plugins / service plugins look like? I.e. https://github.com/mdx-js/mdx-analyzer/blob/31f1912328a688d2e5c943f3f8923c7fee75cc98/packages/language-server/lib/language-server-plugin.js#L46-L52 Also I suppose these changes make #109 obsolete? |
Sure you can! That PR is just a reference for implementation but not a request. Please feel free to decide whether to migrate it. On the other hand, I can also change that PR to support both, just expose an IDE option to let users choose to use LSP or TS Plugin. The implementation is very simple, just decide whether to pass in createTypeScriptProjectProvider or createSimpeProjectProvider according to the client init options. connection.onInitialize(params => {
- return server.initialize(params, createTypeScriptProjectProvider, {
+ return server.initialize(params, params.initializationOptions.yourOption ? createTypeScriptProjectProvider : createSimpleProjectProvider, {
It's looks like this: async getServerCapabilitiesSetup() {
return {
servicePlugins: [
createMarkdownService(),
createMdxServicePlugin(),
createTypeScriptService(server.modules.typescript),
],
};
},
async getProjectSetup(serviceEnv, projectContext) {
const plugins = await loadPlugins(
projectContext.typescript?.configFileName,
server.modules.typescript
)
return {
languagePlugins: [
createMdxLanguagePlugin(plugins),
],
servicePlugins: [
createMarkdownService(),
createMdxServicePlugin(),
createTypeScriptService(server.modules.typescript),
],
};
}
Yes, as |
Does this mean it’s not possible to resolve plugins based on tsconfig if TypeScript isn’t used? |
Yes, actually Vue has the same problem ( |
In the proposed refactor of my snippet I can see: getServerCapabilitiesSetup: getProjectSetup,
getProjectSetup: getProjectSetup, but |
@Andarist my mistake, it's updated now. 👌 |
Removed
ServerPlugin
abstraction: TheServerPlugin
abstraction, which was previously used for implementing Monoserver. Monoserver is now replaced by Hybrid Mode (TS Plugin + LSP Server), making the Plugin API unnecessary.Removed
volar.config.js
support: The convention of using a config file (volar.config.js) is no longer needed for the framework. If a server config file is required, it should be implemented by the tool itself.API refactoring: The naming convention for server creation functions has been changed from start*Server to createServer.
For example, consider the server plugin in [v2] request handlers and context access in
ServerPlugin
#110. The previous implementation:It should now be refactored to the following implementation: