Skip to content
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

feat(language-service): migrate to named pipe server using TypeScript LanguageService #3908

Merged
merged 11 commits into from Feb 29, 2024

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Feb 29, 2024

After migrating to the TS Plugin, the LSP Server no longer provides the semantic functionality of the TypeScript LanguageService instance. It needs to communicate with tsserver to invoke its LanguageService instance.

The communication between LSP Server and tsserver is based on named pipes instead of websockets. This is to avoid occupying local ports and dependencies on the ws package.

The following features have been migrated to the named pipe server that uses the TypeScript LanguageService:

  • Component Extract CodeAction
  • Template Twoslash Queries
  • Auto Insert .value
  • Tag and Props Name Casing Detect / Convert
  • Detect Missing lang="ts" / "allowJs": true / jsconfig.json (No longer needed)
  • Missing Required Props InlayHints
  • Tag and Props Completion in Template

The "Show Component Meta" command is not supported in the absence of TypeScript LanguageService and has been removed.

import type * as vscode from 'vscode-languageserver-protocol';
import { getQuickInfoAtPosition } from 'typescript-vue-plugin/out/namedPipe/client';
Copy link
Collaborator

@rchl rchl Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not rely on internal package build paths?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. Just need to make sure that both node and esbuild can interpret the path.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just saying that /out/namedPipe/client path is an internal detail of the typescript-vue-plugin package and should not be hardcoded like that. But since you control both, I guess you can get away with it :)

export function startNamedPipeServer() {
if (started) return;
started = true;
const server = net.createServer(connection => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to communicate using node-ipc for example? At least that's what typescript-language-server is using to communicate with tsserver but not sure if that's relevant for this case...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my memory IPC communication requires obtaining a ChildProcess instance? Neither the LSP server nor the language client can obtain a process instance of tsserver so this may not be possible.

@johnsoncodehk johnsoncodehk merged commit 88eae78 into master Feb 29, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the named-pipe branch February 29, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants