Skip to content

Implementing Vue LSP #3

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

Closed
tommasongr opened this issue Sep 16, 2020 · 21 comments
Closed

Implementing Vue LSP #3

tommasongr opened this issue Sep 16, 2020 · 21 comments
Labels
help wanted Extra attention is needed

Comments

@tommasongr
Copy link
Owner

tommasongr commented Sep 16, 2020

I'm trying to implement the Vue Language Server, unfortunately I didn't get that far.

First of all the custom Completions for Vue and the standard Completions for html and css are not shown anymore. Javascript syntax has improved a little bit but not significantly improvements to vue. For example this doesn't offer intellisense as it should. I have no clue on how to implement a correct version of this 😕

If anyone can help me, I'd really appreciate it 🙏

@apexskier I've seen that you worked on a similar thing for typescript. Would you mind taking a look at it?

@tommasongr tommasongr added the help wanted Extra attention is needed label Sep 16, 2020
@apexskier
Copy link

Hey, happy to help out and take a look. Sounds like you've tried something so far - can you share the branch you're working off of?

@tommasongr
Copy link
Owner Author

tommasongr commented Sep 16, 2020

Thank you so much! Here it is: https://github.com/tommasongr/nova-vue/tree/vue-lsp

@apexskier
Copy link

The first thing I see is

Vue[17:01:15.944000] Error: Could not find an executable for process: /Users/cameronlittle/Dev/nova-vue/Vue.novaextension/node_modules/vls/bin/vls

because the extension's not running a self-install, like mine does. (I use shrinkwrapping, which I'd recommend over a second package-lock.json, since it's intended for publishing like this. There's no effective difference, but I feel it makes it more obvious what's going on) (looks like your language server has a ton of dependencies, which is a bit annoying)

After installing, it looks like the language server starts up with no issues. I'd recommend naming it something different than "Vue" to differentiate extension console output between your extension and the language server. (I don't get any functionality off the bat because a .vue file isn't automatically recognized as using Vue syntax - I needed to change it from plain text manually. I think this is because I'd opened the file before loading the extension,)

Screen Shot 2020-09-16 at 17 09 38

It looks like the language server is doing something... this suggestion isn't provided without it.
Screen Shot 2020-09-16 at 17 11 59


For example this doesn't offer intellisense as it should.

Note that nova doesn't offer suggestions immediately after typing this.. It currently requires you to type at least one other character as well (https://dev.panic.com/panic/nova-issues/-/issues/1464, apexskier/nova-typescript#30). Also note that Nova doesn't yet support a bunch of LSP commands natively (although I think they're planning on improving this). Most of my typescript extensions's functionality is manually implemented.


First of all the custom Completions for Vue and the standard Completions for html and css are not shown anymore.

I'm not sure what the custom completions are supposed to be doing, but I definitely see new completions coming from the language server. I've only played with nova completions a tiny bit, but I wouldn't be entirely surprised if running a language server conflicted with other custom defined completions from the same extension.

Screen Shot 2020-09-16 at 17 33 48

@tommasongr
Copy link
Owner Author

Thank you so much for your time and feedback!

Thanks for the suggestions of using shrinkwrapper, i'll definitely merge your pull request #4


It looks like the language server is doing something... this suggestion isn't provided without it.

Yes I saw that, what I ment was that on vscode for example the suggestion for this includes a lot of stuff coming from the vue instance.


These are some completions that I defined specifically for the vue-html subsyntax.

Schermata 2020-09-16 alle 18 56 55

The LSP overtooks them and provides these instead

Schermata 2020-09-16 alle 18 59 30

Nothing wrong until you confirm and... it escapes and places $1 inside the brackets. I suppose this is the vscode syntax for placeholders in completions. This occurs not only in html but also in every other completions provided by the LSP.

Schermata 2020-09-16 alle 18 59 42


Also the standard completions for other things like css are gone

Expected:
Schermata 2020-09-16 alle 19 09 33

Actual:
Schermata 2020-09-16 alle 19 10 04

Maybe @panicinc can take a look on this?

@yoyo930021
Copy link
Contributor

yoyo930021 commented Sep 17, 2020

Hi, I'm a Vetur project contributor.

I work in this issue.
vuejs/vetur#2233
It can solve many dependencies problem.

Maybe you can wait this issue.
I will try to help when issue finished.

@tommasongr
Copy link
Owner Author

It would be great! Thanks for your contribution! @yoyo930021

@apexskier
Copy link

Nothing wrong until you confirm and... it escapes and places $1 inside the brackets. I suppose this is the vscode syntax for placeholders in completions. This occurs not only in html but also in every other completions provided by the LSP.

I see... I think this is something we'll need Panic to solve.

The LSP does have support for completion placeholders. It kind of looks like Vetur's language server is generating placeholders, but I'm not positive. That's something to confirm by inspecting the messages it's sending. If it does, my guess is that Panic hasn't yet added support for them from Nova's side.

@jonowells
Copy link

The LSP does have support for completion placeholders. It kind of looks like Vetur's language server is generating placeholders, but I'm not positive. That's something to confirm by inspecting the messages it's sending. If it does, my guess is that Panic hasn't yet added support for them from Nova's side.

From the Nova 1.2 Release Notes:

  • Extensions: Added support for the LSP Snippet format in completions

@tommasongr
Copy link
Owner Author

@jonowells I tried yesterday 1.2 updates with the already in place implementation of vls but it still autocomplete with e.g: v-if="$1"

@apexskier gives it a try too and found the same issue.

I reached out some folks at Panic and they are looking at it. Let's see

@tommasongr tommasongr added the bug Something isn't working label Sep 30, 2020
@laosb
Copy link

laosb commented Oct 24, 2020

Now Nova 2 has been released. Any improvements on this?

@tommasongr
Copy link
Owner Author

tommasongr commented Oct 24, 2020

@laosb I started looking at it yesterday evening! The LSP already works. The problem right now is that the LSP overrides the custom defined completions and their completions are not the best to be honest... I'm looking to a way to disable the LSP completion feature but I'm not sure on how VLS works.

The working branch is language-server. vls is there just for reference.

@yoyo930021 Can you help me on this?

@tommasongr tommasongr removed the bug Something isn't working label Oct 24, 2020
@yoyo930021
Copy link
Contributor

@laosb I started looking at it yesterday evening! The LSP already works. The problem right now is that the LSP overrides the custom defined completions and their completions are not the best to be honest... I'm looking to a way to disable the LSP completion feature but I'm not sure on how VLS works.

@yoyo930021 Can you help me on this?

I can add option for disable LSP completion.
But I don't think vls completion would be worse.
After all, we have TypeScript support.

@tommasongr
Copy link
Owner Author

I can add option for disable LSP completion.
But I don't think vls completion would be worse.
After all, we have TypeScript support.

@yoyo930021 sorry about that I guess I didn't explain myself correctly. Is not about what vls has but what it doesn't have. Take a look... This kind of completions are not available in vls and if an LSP is activated the custom completions are not shown.

ezgif com-video-to-gif

However I've been able to show them programmatically through the Nova API. I think I'll rewrite them this way

@tommasongr
Copy link
Owner Author

tommasongr commented Oct 24, 2020

Another option might be to add the completions to the LSP directly but I'm not sure if is it possible with VLS and eventually how to do that. In that case it would be possible to scope the completions to the export default only? and maybe customize them based on the lang type (js, ts, ...)?

@tommasongr
Copy link
Owner Author

Now Nova 2 has been released. Any improvements on this?

@laosb Vetur mode has finally landed on Nova! Slap that update button! 🥳

https://twitter.com/tommasongr/status/1320367367596183552

@tommasongr
Copy link
Owner Author

Since the LSP is implemented I'll close the issue. Thank you all guys!

@yoyo930021
Copy link
Contributor

Sorry it's a little late to reply.
I welcome you send a PR to vetur about that snippets.
For example, Javascript can be added here.
https://github.com/vuejs/vetur/blob/master/server/src/modes/script/javascript.ts#L141

It also appears that nova doesn't allow you to use both at the same time.
If two extensions are used, can this problem be solved?
Maybe a similar idea could be the solution.

@tommasongr
Copy link
Owner Author

@yoyo930021 Thanks! I'll take a look at both strategies!

Anyway can I ask you why intellisense works flawlessly inside script tag but when it comes to the template it doesn't seem to exist at all? I would love to fix that too, thanks

@yoyo930021
Copy link
Contributor

yoyo930021 commented Oct 29, 2020

@yoyo930021 Thanks! I'll take a look at both strategies!

Anyway can I ask you why intellisense works flawlessly inside script tag but when it comes to the template it doesn't seem to exist at all? I would love to fix that too, thanks

I'm not sure what part of intellisense you're referring to in the template.
There are five relevant sections here.

  1. HTML5 tag or attrs

This part is written directly in Vetur.

  1. Vue tag or attrs

This part is written directly in Vetur.

  1. External component data provided by library.

Vetur read package.json in project root.

  1. Vue components are defined in the file.

Vetur read components: {} in current file, and try to parse them.

  1. TypeScript is provided based on the current component.

When v-bind, v-if, v-for, {{ }} in template, Vetur transform template to js code. Provided via typescript.
This feature is disabled by default. please set { "vetur.experimental.templateInterpolationService": true } to open it.

@tommasongr
Copy link
Owner Author

tommasongr commented Oct 29, 2020

@yoyo930021

I'm not sure what part of intellisense you're referring to in the template.

As you can see inside the template directives intellisense is not working. This is the only problem I've found for now, everything else works well.

intellisense

If this is caused by { "vetur.experimental.templateInterpolationService": true } how can I set this command in Nova? And why in vscode I haven't had to set this command to have the feature? Thanks

@yoyo930021
Copy link
Contributor

yoyo930021 commented Oct 29, 2020

@yoyo930021

I'm not sure what part of intellisense you're referring to in the template.

As you can see inside the template directives intellisense is not working. This is the only problem I've found for now, everything else works well.

intellisense

If this is caused by { "vetur.experimental.templateInterpolationService": true } how can I set this command in Nova? And why in vscode I haven't had to set this command to have the feature? Thanks

This is a option in setting not a command.
In VSCode, it is same as editor config.
VScode will send setting to LSP.

Vetur can send setting when init.
https://github.com/vuejs/vetur/blob/70609ef531ccd1884410ac366b5a3ae08174ceb4/client/client.ts#L56
You can try to use this for test.
But understanding LSP and setting with nova is important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants