sublimelsp / LSP-rust-analyzer

Convenience package for rust-analyzer
MIT License
70 stars 11 forks source link

feat: support custom command to move item up/down #111

Closed rchl closed 9 months ago

rchl commented 9 months ago

Implement handling for custom request to move item up and down.

Tested with simple case like:

fn two() {
    println!("Hello, world1!");
}

fn main() {
    println!("Hello, world!");
}

and moving fns around.

Note that rust-analyzer returns custom "snippet" text edits. That means that one or more of the edits (in this case one) will include a snippet like $0 or ${0:foo}. I'm implementing opt-in support for that in LSP which this change depends on.

The point of the snippet is that the cursor position is moved together with moved function/item which otherwise would just stay in the old place.

Based on rust-analyzer extension code:

Fixes #28