Skip to content

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

Merged
johnsoncodehk merged 11 commits intomasterfrom
named-pipe
Feb 29, 2024
Merged

feat(language-service): migrate to named pipe server using TypeScript LanguageService#3908
johnsoncodehk merged 11 commits intomasterfrom
named-pipe

Conversation

@johnsoncodehk
Copy link
Copy Markdown
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 * as vue from '@vue/language-core';
import { Provide } from 'volar-service-typescript';
import type * as vscode from 'vscode-languageserver-protocol';
import { getQuickInfoAtPosition } from 'typescript-vue-plugin/out/namedPipe/client';
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
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.

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.

2 participants