pixix4 / ev3dev-lang-rust

Rust language bindings for http://ev3dev.org
MIT License
74 stars 14 forks source link

Make this lib more completion friendly #3

Closed playest closed 4 years ago

playest commented 4 years ago

Hello,

I tried to use completion with this library and I had a rough time (here is a summary what I tried to do).

Did you manage to use completion with the library without macro expansion?

Thanks.

pixix4 commented 4 years ago

Currently the code completion does not work. As you already figurer out, this is due to the use of proc macros. When creating the library I split the key functionality in traits to be as compatible as possible to the ev3dev specification and to reduce the code size. Until now I didn't know that this causes problems with code completion.

Apart from waiting for the rust-analyzer project to support proc marcos (PR) it is possible to lift the functional traits (TachoMotor, Sensor, Findable) to classic macros. This will fix this issue for rust-analyzer. I will try to restructure the mentioned traits to solve this within the next few days.

pixix4 commented 4 years ago

I created a branch feature/improve-lsp-support that removes most of the proc macros and some traits. With rust-analyzer the completion seems to work but for generated functions no inline doc is visible (it is generated for docs.rs but rust-analyzer and clion do not recognize this).

Changes with this branch:

You can try it locally and check if it brings improvements for you. I will do some test and try to fix the inline doc problem before merging.

pixix4 commented 4 years ago

rust-analyser now supports inline documentation for macro-generated functions. So I think this issue can now be marked as solved.