rust-lang / rust-lang/rust-analyzer

Using a different language server for code inside a proc macro

Open
#17,186 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I would like to write a language server for SQLite sql that will also work for SQL written in a particular proc macro:

// ...rust code
let users = my_proc_macro_for_sql! {
    SELECT * FROM User
};
// ...rust code

Before I venture further, I wanted to ask if something like is even possible in a non-invasive manner.

Some approaches I thought of:

  • Using https://code.visualstudio.com/api/language-extensions/embedded-languages
    • This seems to indicate that rust-analyzer may need to add some kind of support for this. If so, is this something rust-analyzer interested in supporting? Maybe this is already supported? If not, I can attempt to make this contribution.
  • A language server that targets .rs files but only "activates" when there is a specific .toml file in the workspace and the .rs file contains the proc macro my_proc_macro_for_sql!
    • This seems like it could potentially clash with rust analyzer and/or slow down ide needlessly

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 VS Code embedded-languages documentation and the issue's two proposed approaches. Investigate whether rust-analyzer can support SQLite SQL embedded in a proc macro without conflicting with another language server or adding needless activation overhead; done would require a clearly agreed implementation path and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.