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

[Example request] Embedded lsp for typescript/javascript #283

Closed
Arthie opened this issue Apr 23, 2020 · 7 comments
Closed

[Example request] Embedded lsp for typescript/javascript #283

Arthie opened this issue Apr 23, 2020 · 7 comments
Assignees

Comments

@Arthie
Copy link

Arthie commented Apr 23, 2020

Hello, I am trying to create an embedded language extension for typescript/javascript.
The current lsp-embedded examples are useful but there is no typescript equivalent for "vscode-html-languageservice".

Is it possible to add an embedded language example targeting typescript?

@dbaeumer dbaeumer assigned aeschli and unassigned dbaeumer Apr 27, 2020
@dbaeumer
Copy link
Member

@aeschli assigning to you. Not sure who would be the right person for this.

@aeschli
Copy link
Contributor

aeschli commented Apr 27, 2020

JavaScript embedded in a other language?
You can look how this is done in the real html language server: https://github.com/microsoft/vscode/blob/master/extensions/html-language-features/server/src/modes/javascriptMode.ts

@Arthie
Copy link
Author

Arthie commented Apr 30, 2020

@aeschli Thanks for the reply! I am looking for an example that embeds another language into Javascript. Specifically embedded into javascript template tags.
Sorry, my first post wasn't that clear.

@aeschli
Copy link
Contributor

aeschli commented May 1, 2020

If you want to run inside the TypeScript/JavaScript language server:
The TypeScript language server has a feature called 'plugins' that allow you to participate in it's behavior:
https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
To contribute such a plugin to the TypeScript language extension in VSCode:
https://code.visualstudio.com/api/references/contribution-points#contributes.typescriptServerPlugins

@aeschli
Copy link
Contributor

aeschli commented May 1, 2020

Assigning to @mjbvz to decide if we want to a sample that shows how to extend the TypeScript language server.

@aeschli aeschli assigned mjbvz and unassigned aeschli May 1, 2020
@mjbvz
Copy link
Collaborator

mjbvz commented May 1, 2020

This is a pretty niche problem so it's probably best to look at what existing extensions do here. See https://github.com/mjbvz/vscode-lit-html for example

@mjbvz mjbvz closed this as completed May 1, 2020
@daKmoR
Copy link

daKmoR commented Mar 4, 2024

JavaScript embedded in a other language?
You can look how this is done in the real html language server: https://github.com/microsoft/vscode/blob/master/extensions/html-language-features/server/src/modes/javascriptMode.ts

that sort of works but it's not what I would have expected... it does not support any code that uses imports (which probably every meaningful code will do)

e.g. examples like this do not work in html-language-features

👉 foo.js

export const foo = { on: 'foo', off: 'baz' }

👉 index.html1 // it also doesn't work for the built in .html language service

<script type="module">
   import { foo } from './foo.js';
   foo.o // no autocomplete for on/off
</script>

an example how to get "real" javascript completion (like in a js file supporting imports) would be awesome 🤞

I have been reading through some issues and I am not sure if it's even possible? if it's currently not possible what would be needed to make it 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

No branches or pull requests

5 participants