-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Local LSP server that improves functionality like item completion #122
Conversation
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: )
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: )
Unfortunately i did not find an easy way to use our local LSP as proxy for the remote LSP without reimplementing the whole LSP protocol. The vscode-languageclient can not run within the server because it requires a module, that can only be used in the client: My idea was something like this: Instead i now run local and remote LSP server in parallel. In this screenshot you can see diagnostics from local and remote LSP. The green underlined part is from local LSP because its all uppercase (just a sample, no real diagnostics yet) and the red underlined parts are from openhab remote LSP: So we still can implement the item completions in out local LSP server, add diagnostics to the one we ge from the remote server and also do all the other stuff in our local LSP like jumpt to reference and so on... Its not as nice as extending the remote server, but its still better than nothing. Maybe later when i have more time i can look into how to write an own language client, but for now this should be enough. |
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: )
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
I will have a closer look at the implementation at the end of the week. It will also be necessary to do some modifications in the remote LSP because it currently announces to many capabilities which leads to context menu function that won't work. |
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
Items are taken from REST API at start and are getting cached in LSP Server. Their values are updated from SSE (/rest/events). When Items are added or removed the cache is updated. So now we have a very responsive completion list. Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
I added items completion now. Its just a proof of concept and i'm not sure if it is very stable. However now we get the items from rest in the beginning, cache them and update them based on SSE. So we also get new items and items that are removed. Will clean up the code and make it a bit nicer. I'm also open for ideas on how to improve the ItemsCompletion code in the server part. |
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Signed-off-by: Samuel Brucksch sasliga@freenet.de
I think i'm currently at a stage that reflects the functionality from before but with much faster completion. I can either continue on implementing LSP features, or wait for a review and merge and then add new PRs for new features, which would make more sense for working simultaniously on seperate features. |
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Maybe some remarks on what i did:
I think thats all. Maybe we need a utils package for code that is used in both modules like IItem.ts and Item.ts. Maybe more will follow. |
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Signed-off-by: Samuel Brucksch sasliga@freenet.de
Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
…g files Signed-off-by: Samuel Brucksch <sasliga@freenet.de>
9e709e4
to
4efc592
Compare
…to vscode-lsp Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: SamuelBrucksch)
Should i add changelog entries already or is this done seperately? The current changelog would look something like this: 0.5.0 -TBD
|
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: SamuelBrucksch)
There seems to be a problem with outline view. With the test vsix (#122 (comment)) I did not see any outline. After I went back to the marketplace version the outline was OK. |
Outline works for me (checked in sitemap, rules, items). Seems like outline items are provided by remote LSP so make sure it is enabled to see the outline. At least when i disabled remote lsp no outline was there, but when i enabled it, it was there... |
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: SamuelBrucksch)
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: SamuelBrucksch)
Latest vsix: |
Any more comments or reviews? |
Come on guys, this is important to work on other tasks as well. |
@SamuelBrucksch @Confectrician My runtime tests were OK. Did not find any problems. |
Hi, about the items view: i noticed that as well. I think we can also use the completion items from LSP for that. Behaviour did not change, it was like that from the start so i wanted to do this in a seperate PR later. Not sure ifwe actually need the values in completions at all, i thought about a hover provider that displays the values on hover of an item in code. |
In completions completion the item names and an information about the type are sufficient. |
Hi all, I finally had some time for (functional) testing and could not recognize any missbehavior for now. Sorry for the delay, but we are all doing this in our free time besides work/school/study/whatever. |
@SamuelBrucksch maybe you can squash your commits and add a sign off now? |
Also https://app.codacy.com/app/Confectrician/openhab-vscode/pullRequest?prid=2701365 shows some issues. Edit: |
Hi, whats the best way to squash them? I saw rebase -i works or reset soft and then merge --squash, but i guess all of them would result in a git push -f at the end so all the single commits are gone, is that right? Double quotes for JS does not make much sense as there are also other ways to create strings like
This does not work with double quotes. Also its easier to use quotings and so on in single quotes without disturbing escape characters. |
Yep but this doesn't matter in this state. We can leave it too, its just some cosmeticcal stuff to satisfy pullapprove . 🙂 |
@MHerbst or @kubawolanin any additional comments? |
serverJS/src/Server.js
Outdated
|
||
/* | ||
documentSaved (event) { | ||
// TODO can be used for format on save feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are minor things but since we're using version control, let's avoid checking in a commented out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, i just left it there so we can see faster how it works when we enhance LSP. But i can remove it, no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove them too.
Those are just empty functions.
We could open an issue instead, which reminds us that these functions (names written down) could be used later.
Signed-off-by: Samuel Brucksch <sasliga@freenet.de> (github: )
I removed the commented code. Do you still want me to squash everything even if is squashed anyways? |
Perfect, thanks!
I think we're good here, since you've signed off your first comment and committed all code with one git user :-) Thank you for your work. |
Yay! Thanks for reviewing. Now i will add a lot more PRs ;). |
Initial LSP impl with example from MS sample LSP:
https://github.com/Microsoft/vscode-extension-samples/tree/master/lsp-sample
To test:
Open a new file, and then select openhab as language or save as *.items/rules/...
This will fix #95 when all the work is done.
Signed-off-by: Samuel Brucksch sasliga@freenet.de