Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete in IntelliJ IDEA #11

Open
lukas-shawford opened this issue Apr 12, 2020 · 4 comments
Open

Autocomplete in IntelliJ IDEA #11

lukas-shawford opened this issue Apr 12, 2020 · 4 comments

Comments

@lukas-shawford
Copy link

lukas-shawford commented Apr 12, 2020

Hey, I'm following your excellent tutorial series. Thank you for writing these!

Towards the end of lesson 6, there is a suggestion about how to get autocomplete to work, which involves copying the auto-generated bindings.rs from the output directory back into the project. That didn't actually work for me (maybe I wasn't copying it to the right place, not sure - I'm completely new to Rust).

But regardless, it seems there is now a better way, at least for IntelliJ. I thought it might be worth updating the lesson with these instructions, since AutoComplete is so immensely helpful for someone who is learning Rust and OpenGL (the target audience of this blog series).

There is an experimental feature of the intellij-rust plugin which allows for auto-completion to work when using:

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

To enable it, open the Maintenance Menu using Ctrl+Shift+Alt+/, select "Experimental Features", then enable the following feature:

org.rust.cargo.fetch.out.dir

intellij_rust_out_dir

Then restart the IDE.

Worked beautifully for me. There is some discussion here as to why the feature is designated as Experimental and disabled by default:

intellij-rust/intellij-rust#4573

And the original issue from intellij-rust is here:

intellij-rust/intellij-rust#1908

@Nercury
Copy link
Owner

Nercury commented Apr 13, 2020

Thank you, this looks really useful!

@Trikzon
Copy link

Trikzon commented Jul 27, 2020

@Nercury
I'm using neovim with coc-rust-analyzer, so the above change doesn't work for me.

Could you specify where you would copy bindings.rs to?

I'm relatively new to rust, so it would be helpful instead of the vague explanation currently in the tutorial

@Nercury
Copy link
Owner

Nercury commented Jul 27, 2020

You could copy-paste the contents of the generated file to where the include! macro is, this is what the include macro basically does.

@FakeDomi
Copy link

FakeDomi commented Jul 8, 2021

You need to tick org.rust.cargo.evaluate.build.scripts in newer versions of the plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants