rust-lang / rust-lang/rust-analyzer
Complete statement command for Rust Analyzer
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
IntelliJ Rust has a very useful command called "complete statement". How it works:
- If current line is a well-formed statement, e.g
let a = 2then move cursor to the end of line and add a semicolon. - If the line is in the middle of a function name, e.g
fn func_namethen transform it to
fn func_name(){
}
and move cursor to inside function body. Same for struct, enum, trait
- If we are in the middle of a well formed if clause, i.e:
if x > 2, then transform it to:
if x > 2 {
}
and move cursor inside the curly brackets. Same for while, for, match, loop (this one is not in IntelliJ Rust but in Typescript and Kotlin on IntelliJ platform.)
- Any other cases, move cursor to the end of line. (or add more smarter behaviors, basically we try to complete the statement if it make senses)
It would be nice if Rust Analyzer can also have that. I normally bind this command to Shift + Enter key. That way I can end statements with one key combination. It's really convenient.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named in the issue. Start by locating the existing editor-command handling for Rust Analyzer, then compare the requested function, struct, enum, trait, conditional, loop, and statement cases with the current behavior; done means the command handles the listed transformations and cursor placement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100