racer
racer copied to clipboard
include!() support
Hello,
It would be great to have racer work with capn proto generated Rust code. I think this is an include!() problem. You can test this for yourself like this:
- git clone https://github.com/dwrensha/capnpc-rust
- cd capnpc-rust
- cargo build (probably requires nightly rustc)
- cd example/addressbook
- cargo build
- vi addressbook.rs
- try to 'gd' on line 39 address_book.init_people(2) -> not found (init_people)
- try to type address_book.
-> not found
Does capnpc-rust write the addressbook generated source anywhere? Racer currently needs the source code to do completions / find definitions at the moment
It does, and this may be the tricky part because it relies on an OUT_DIR env var supplied by rustc.
For example, on my system the source file winds up here: target//debug/build/addressbook-20f8a45beadaa3ee/out/addressbook_capnp.rs
The include!() to find the file is: include!(concat!(env!("OUT_DIR"), "/addressbook_capnp.rs"));
This enhancement would also be great for working with gl-rs (which does something similar with OUT_DIR
).
Probably related to #693
Have the same problem with vulkan_rs
It would be great thing for those who use https://github.com/rust-lang-nursery/rust-bindgen and construction like:
include!(concat!(env!("OUT_DIR"), "/c_lib_include.rs"));
I don't think supporting include!
itself is difficult.
But other macros like concat!
and cargo environment variables like OUT_DIR
are major obstacles :fearful:
So... yeah I don't say we never support this, but we can't support this kind of feature immediately, sorry.
@kngwyu
But other macros like concat! and cargo environment variables like OUT_DIR are major obstacles fearful So... yeah I don't say we never support this, but we can't support this kind of feature immediately, sorry.
But what about this particular case:
include!(concat!(env!("OUT_DIR"), "/c_lib_include.rs"));
?
It is recommended way for code generation according to official cargo docs, is it hard to match such code with regexp and look for last modified file in: target/(debug|release)/build/${crate_name}-*/c_lib_include.rs
?
I suppose this heuristics will close 90% of code generation use cases.
I mean do not handle macroses at all just match string include!(concat!(env!("OUT_DIR"), "PATH"));
@Dushistov OK, I'll try it.
@kngwyu
Great! Thank you.
any update? thanks.
Hi, is anyone working on this, because I don't want to duplicate effort. EDIT: Ok, so If nobody is working on it I will try to fix, but it may took a while as I must take in the codebase.