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

rust-analyzer integration #38

Open
l2dy opened this issue Aug 25, 2024 · 0 comments
Open

rust-analyzer integration #38

l2dy opened this issue Aug 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@l2dy
Copy link
Owner

l2dy commented Aug 25, 2024

Features to keep:

  1. Cargo.toml and Cargo.lock syntax support, which is not covered by rust-analyzer.
  2. Run config, including main functions and tests.
    1. If we intend to keep the original version, we need to disable the LSP CodeLens.
    2. Otherwise, LSP4IJ does not provide rust-analyzer.runSingle and debugSingle commands, so you have to be implement it in language plugins.
  3. Run with coverage
    1. rust-analyzer issue 8881. We could hide the LSP CodeLens and keep our own version for an MVP.
  4. Commenter customizations.
    1. LSP4IJ uses fallback commenter, which adds // at start of line.
    2. LSP4IJ does not wrap the comments properly if a newline is inserted in the middle of a comment (or anywhere in a /// doc-comment).

Features to integrate with LSP4IJ:

  1. Project structure and file icons, e.g. tests and benches directories.
  2. rustup (prompt for or automatically install rust-analyzer, and configure the LSP4IJ language server)
  3. Cargo workspace detection and management. Read https://github.com/intellij-rust/intellij-rust/blob/master/ARCHITECTURE.md#project-model first.
    1. Question: What to do with a multi-workspace project has different toolchain versions defined in rust-toolchain.toml?
      • See intellij-rust's guessAndSetupRustProject function. The toolchain settings is per-project and stored in toolchain in Project.rustSettings, so we could reuse this level of the project model hierarchy for LSP4IJ language servers.
      • Language Servers in LSP4IJ are singletons. We cannot start multiple rust-analyzer processes.
  4. Show references (missing rust-analyzer.showReferences command)
    1. Hide the line if not appropriate.
  5. "Has implementations" sidebar icon and action (LSP4IJ has X implementations but not in sidebar)
  6. #hard Inline jump to referenced symbol and "Jump to Source" button in Quick Documentation.
    1. Might need to keep the buggy type inference code in intellij-rust if we could not fetch type information from the LSP server.
  7. Rendered comments in reader mode and Markdown syntax highlighting in comments in main editor.
    1. The latter might be solved by keeping the Psi parsing, we'll see.
  8. Syntax highlighting (in quick doc Markdown code blocks)

Features to implement in LSP4IJ:

  1. Code Inspection support (report errors in batch code inspection run, LSP4IJ issue 476)
  2. Reliable and performant semantic highlighting (see LSP4IJ's issue tracker)

and LSP4IJ is not mature yet, see list of issues at https://github.com/redhat-developer/lsp4ij/issues.

Features know to be sacrificed after transition to rust-analyzer:

  1. Syntax highlighting and code completion in #[cfg]-disabled code.
    This was a trade-off made in intellij-rust that could result in false positives of duplicate code. rust-analyzer chose otherwise.
  2. Clickable types in function signature of Quick Documentation. (see also point 5 above, but this is about function signature and traits)

rust-analyzer bugs:

  1. Quick Documentation issues with tokio's recv() and standard library's unwrap_or_else().
    1. Link to referenced tokio type opens a 404 page in browser.
    2. Link to other crate's symbol is not found and IntelliJ throws an error.
    3. Link to symbols in the same crate is not parsed correctly, instead shows the weird [xxx].
  2. Go to definition jumps to start of doc-comment, not the symbol itself.

@l2dy if you want to evaluate LSP4IJ with rust very quickly without developing an IJ plugin please read https://github.com/redhat-developer/lsp4ij/blob/main/docs%2Fuser-defined-ls%2Frust-analyzer.md

If you think the result is good, you should develop an IJ plugin to define lsp command and define the rust analyzer ls with lsp4ij extension point to embed the ls in the plugin. Please read https://github.com/redhat-developer/lsp4ij/blob/main/docs/DeveloperGuide.md

Originally posted by @angelozerr in #33 (comment)

@l2dy l2dy added enhancement New feature or request help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant