Hpmason / retour-utils

Other
4 stars 2 forks source link

Macro confuses lsp autofill #6

Closed Hpmason closed 1 year ago

Hpmason commented 1 year ago

There's a number of situations where rust-analyzer's code completion ends up where it is not supposed to be (definitely to the fault of #[hook_module]'s macro code generation).

Auto-importing of hook_module puts the import inside of the module, instead of above it. Using rust-analyzer to change the visibility of the crate (such as adding pub in front of the module) puts it in a completely different spot.

Issue is probably due to not using applying spans to whole tokens, but I have not tested that yet

Hpmason commented 1 year ago

Looks like a good way to handle this is to use syn's fold feature. We can change the function signature from there, possibly using fold_signature.

Should make code more readable, faster, and play nicer with rust-analyzer.