rust-lang / rust-lang/rust-analyzer

Go to definition / open link for file path in `include_str` should work for non-Rust files

Open
#11,025 7 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-vfs C-enhancement
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Split off from #11019. See https://github.com/rust-analyzer/rust-analyzer/issues/11019#issuecomment-994966731.

Go to definition / open link for file paths in include, include_str, include_bytes does work already (https://github.com/rust-analyzer/rust-analyzer/issues/11019#issuecomment-994479218).

Sadly, this only works if the file extension is rs. My codebase on the other hand include_strs JS and CSS files and include_bytes WOFF files (just like librustdoc!). In such a case, this feature does not work.

I would say more often than not one doesn't include_str Rust files (contrary to include). I am not sure if that still counts as jump to definition in the LSP sense but it's reasonable to support (as open link or whatever other mechanism available) in my opinion. I am not familiar with the LSP though.

rust-analyzer version: rust-analyzer version: db2a7087b 2021-12-13 stable

rustc version: rustc 1.59.0-nightly (48a5999fc 2021-12-01)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing include/include_str/include_bytes handling discussed in #11019 and its linked comments. Reproduce the current behavior with non-Rust paths such as JS, CSS, and WOFF files; done means go-to-definition or open-link navigation works for those paths as it already does for Rust files.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.