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: migrate to TS plugin and deprecate takeover mode #3788

Merged
merged 34 commits into from
Dec 26, 2023
Merged

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Dec 7, 2023

Feedback: #3789

close #2467, close #3423, close #3186, close #2746, close #2731, close #2721, close #1245, close #2361, close #2442, close #2490, close #2612, close #2603, close #2534, close #2747, close #3232, close #1277, close #918, close #3229, close #3482, close #3355, close #3545, close #3508, close #3680, close #3678, close #3741, close #3192, close #3740, close #3776, close #3391, close #3329, close #3788, close #3231, close #3788, close #3801

Commands

  • TypeScript: Restart TS Server
  • TypeScript: Reload Project
  • TypeScript: Go to Project Configuration (tsconfig)

Editor Features

Bug Fixes

  • Avoid TS Plugin Outline for .vue
  • Avoid TS Plugin Formatting for .vue

Optimize

Regressions

  • Support .md files for Vitepress
  • Support .html files for petite-vue

@johnsoncodehk johnsoncodehk linked an issue Dec 10, 2023 that may be closed by this pull request
Comment on lines +186 to +200
try {
const tsExtension = vscode.extensions.getExtension('vscode.typescript-language-features')!;
const readFileSync = fs.readFileSync;
const extensionJsPath = require.resolve('./dist/extension.js', { paths: [tsExtension.extensionPath] });

// @ts-expect-error
fs.readFileSync = (...args) => {
if (args[0] === extensionJsPath) {
// @ts-expect-error
let text = readFileSync(...args) as string;

// patch jsTsLanguageModes
text = text.replace('t.$u=[t.$r,t.$s,t.$p,t.$q]', s => s + '.concat("vue")');

// patch isSupportedLanguageMode
text = text.replace('s.languages.match([t.$p,t.$q,t.$r,t.$s]', s => s + '.concat("vue")');

return text;
}
// @ts-expect-error
return readFileSync(...args);
};
Copy link
Collaborator

@rchl rchl Dec 10, 2023

Choose a reason for hiding this comment

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

Have you tried submitting some fix for that in VSCode repo? This looks like something that nobody should be allowed to do ;)

I suppose it would likely make sense if vscode would also consider languages declared by a plugin when showing the status field?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave it to VSCode team to decide how to implement it, please track microsoft/vscode#200511

@johnsoncodehk johnsoncodehk changed the title feat(language-server): migrate to TS plugin and deprecate takeover mode feat: migrate to TS plugin and deprecate takeover mode Dec 11, 2023
@johnsoncodehk johnsoncodehk linked an issue Dec 14, 2023 that may be closed by this pull request
@johnsoncodehk johnsoncodehk force-pushed the ts-plugin branch 3 times, most recently from 0055fb1 to cb09244 Compare December 20, 2023 07:00
@johnsoncodehk johnsoncodehk force-pushed the master branch 2 times, most recently from f1ce889 to 9f1950d Compare December 21, 2023 17:08
@johnsoncodehk
Copy link
Member Author

Since the parallel development of three branches (v1, master, ts-plugin) is almost impossible to maintain, I will first merge the ts-plugin branch to master and develop 2.0 on the master branch. 1.x is still maintained by the v1 branch and rebased to master when needed.

@chaozwn
Copy link

chaozwn commented Feb 7, 2024

Since the parallel development of three branches (v1, master, ts-plugin) is almost impossible to maintain, I will first merge the ts-plugin branch to master and develop 2.0 on the master branch. 1.x is still maintained by the v1 branch and rebased to master when needed.

Does this commit suggest that we should not use the takeover mode in the future?

@so1ve
Copy link
Member

so1ve commented Feb 8, 2024

There will be no takeover mode in the future :)

@WhyNotHugo
Copy link
Contributor

WhyNotHugo commented Mar 4, 2024

EDIT: I found a fix. You can disregard my cry for help.

I'm trying to upgrade my setup to account for this change, but I'm a bit stuck.

The only relevant documentation that I've found it this single line in the changelog:

- TypeScript language support has been moved from Vue language server to TypeScript plugin (#3788)

The plugin mentioned here is a plugin for volar or a plugin for tsserver? My initial impression is that it was a plugin for volar, but some comments lead to to understand that it's a plugin for`tsserver instead.

Does @vue/typescript-plugin need to be installed alongside tsserver, or do I need to install it inside the project's node_modules?

I've tried various approaches, but none seemed to work for me. There's ongoing discussion in #3925, and feedback from those familiar with how this is intended to be used would be most useful.

@johnsoncodehk
Copy link
Member Author

@WhyNotHugo Thanks for your help in the thread. ❤️ (I can't actually help, I have no idea about nvim.)

@WhyNotHugo
Copy link
Contributor

@gegoune: Fix working solution is in this comment: #3925 (comment)

The issue was in how plugins are configured for typescript-language-server. The location field MUST be defined (but can by any random value if the plugin is installed in node_modules). The languages field MUST include file types where the plugin applies.

@johnsoncodehk The above hints are not neovim-specific; they are relevant for people setting up the plugin on any LSP client (the exact syntax will vary a bit from one to another).

@johnsoncodehk
Copy link
Member Author

@WhyNotHugo It would be great if you are willing to open a PR to add configuration methods to the readme of @vue/typescript-vue and @vue/language-server.

@WhyNotHugo
Copy link
Contributor

Docs for the plugin here: #3974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment