feat: support user defined macro snippet for completion - #23058
Open
A4-Tacks wants to merge 1 commit into
Open
Conversation
This feature can improve the completion details of macros
And this feature can be utilized to implement excellent DSL completion
Example
---
```rust
#[rust_analyzer::macro_style(snippet = "${path}!($1, $2)")]
macro_rules! assert_eq { ($($t:tt)*) => {} }
fn main() { a$0 }
```
**Before this PR**
```rust
fn main() { assert_eq!() }
```
**After this PR**
```rust
fn main() { assert_eq!($1, $2) }
```
---
```rust
macro_rules! html {
(<div>$($t:tt)*) => {
/* ... */
};
($($t:tt)*) => {{
#[rust_analyzer::macro_style(snippet = "<div>\n $1\n</div>")]
macro_rules! div { () => {} }
$($t)*
}}
}
fn main() {
html! {
d$0
}
}
```
->
```rust
fn main() {
html! {
<div>
$1
</div>
}
}
```
Contributor
|
This feature needs design discussions. Theoretically, if we make it clear that there are absolutely no stability guarantees, it wouldn't, but I suspect people will still complain, so I don't want that. |
Member
Author
On zulip? or this PR? |
Contributor
|
Zulip is better. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This feature can improve the completion details of macros
And this feature can be utilized to implement excellent DSL completion
Example
Before this PR
After this PR
->