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

refactor: rewrite lsp to use lspower #8727

Merged
merged 9 commits into from
Dec 21, 2020
Merged

refactor: rewrite lsp to use lspower #8727

merged 9 commits into from
Dec 21, 2020

Conversation

lucacasonato
Copy link
Member

@lucacasonato lucacasonato commented Dec 11, 2020

This PR investigates if we could use tower-lsp as our LSP server framework.

tower-lsp is an async LSP implementation written using tower (same framework hyper and tonic are built on). It uses the same underlying lsp_types crate for the protocol as lsp_server.

It has some nice usability benefits over lsp_server:

  • It is async out of the box.
  • It has built in notification and request routing.
  • It has a less verbose API than lsp_server.

TODO:

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

Overall, it feels like the right track but a couple of things:

  • renaming lsp to lsp2 just makes the PR infinitely more difficult to read and feels totally arbitrary. If we had to have two language servers running for a while, then we would want to use lsp2 but this PR fully removes lsp in lieu of lsp2.
  • some of the arbitrary renaming of things also makes it difficult to read, there is no problem with doing a rename PR as a seperate PR first.
  • I really think we should hold off on it until we a stable crate published to replace lsp server. There is no harm in waiting a little while to have the PRs accepted or the alternative crate published.

I know we landed the original LSP as a big ole PR, but it was hard to avoid that... I think we should really try to do things in smaller chunks now.

cli/Cargo.toml Outdated Show resolved Hide resolved
@lucacasonato
Copy link
Member Author

renaming lsp to lsp2 just makes the PR infinitely more difficult to read and feels totally arbitrary. If we had to have two language servers running for a while, then we would want to use lsp2 but this PR fully removes lsp in lieu of lsp2.

Yes - I am going to remove lsp 1 in and move to rename lsp2 to lsp. It was just easier to copy paste chunks in small batches rather than porting everything in the same commit :-)

Some of the arbitrary renaming of things also makes it difficult to read, there is no problem with doing a rename PR as a seperate PR first.

I dont think I did any major renames. Could you point me to what you mean?

I really think we should hold off on it until we a stable crate published to replace lsp server. There is no harm in waiting a little while to have the PRs accepted or the alternative crate published.

Yup - but mainly a chicken and egg problem. I can get this out to crates.io, but I am not going to unless we agree that we want to go with lsp-server. Don't want to push a new crate to cargo, just to determine we won't actually use it.

I know we landed the original LSP as a big ole PR, but it was hard to avoid that... I think we should really try to do things in smaller chunks now.

Agree - but I don't think that is possible with this PR. It completely replaces the core of the lsp. If you have ideas about how we could do this, I can split it up.

@kitsonk
Copy link
Contributor

kitsonk commented Dec 14, 2020

I dont think I did any major renames. Could you point me to what you mean?

- server_state
+ state_snapshot
- ServerStateSnapshot
+ StateSnapshot

I'm fine with the change, but there were a lot of lines in this PR that were just "noise" around those renames.

Yup - but mainly a chicken and egg problem.

How big would lspower be? How much of tower-lsp would we not be using? Does the server need to keep current with tokio? In my mind if it is small, there are parts of tower-lsp we would never use, and/or we have to keep it current with other parts of Deno like tokio, then we should consider just having our own thing (or building the server directly into the lsp).

@lucacasonato
Copy link
Member Author

How much of lspower would we not be using?

We are pretty much using all of lspower. We dont support all language server APIs, but there is no big feature we dont use.

Does the server need to keep current with tokio?

It needs to update to 0.3 when we do. I checked, and this is trivial. Only 3 lines change compared to 0.2.

cli/lsp/README.md Show resolved Hide resolved
Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

Looking good... the term "backend" is really bothering me though.

cli/lsp/backend.rs Outdated Show resolved Hide resolved
cli/lsp/lsp_extensions.rs Outdated Show resolved Hide resolved
cli/lsp/utils.rs Show resolved Hide resolved
Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

❤️

I guess it is just a decision about what we do about waiting for lspower. I will defer to @ry on that one.

cli/lsp/backend.rs Outdated Show resolved Hide resolved
@lucacasonato
Copy link
Member Author

lspower is published to crates now. Just need to switch the cargo toml line.

Also still need to fix the unit test in backend.rs and rename that file to language_server.rs.

@ry ry marked this pull request as ready for review December 21, 2020 12:55
@ry ry changed the title WIP refactor: rewrite lsp to use tower-lsp refactor: rewrite lsp to use tower-lsp Dec 21, 2020
@lucacasonato lucacasonato changed the title refactor: rewrite lsp to use tower-lsp refactor: rewrite lsp to use lspower Dec 21, 2020
@ry ry merged commit bd85d0e into denoland:master Dec 21, 2020
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.

None yet

3 participants