Skip to content

Completion not working with the gl crate #3467

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

Closed
kotatsuyaki opened this issue Mar 5, 2020 · 14 comments
Closed

Completion not working with the gl crate #3467

kotatsuyaki opened this issue Mar 5, 2020 · 14 comments

Comments

@kotatsuyaki
Copy link

The problem

I'm recently trying to write OpenGL related code with the gl crate, and found out that completion doesn't work with it. Typing gl:: and triggering completion shows nothing.

From this issue from gl-rs, it seems that this is due to the gl::* functions being generated by a build script. Is there any workarounds to make completions work with this crate?

Environment

  • version: rust-analyzer 9090c45, automatically downloaded by the coc-rust-analyzer plugin for coc.nvim
  • OS: Manjaro Linux, kernel 5.4.18
  • Editor: vim 8.2
@edwin0cheng
Copy link
Member

From this issue from gl-rs, it seems that this is due to the gl::* functions being generated by a build script. Is there any workarounds to make completions work with this crate?
Environment

As i know, there is no easy workarounds for builds script completions yet. However, since rust-lang/cargo#7622 are landed in stable, we are ready to implement all the machinery macros (which are on my high priority task list):

So please stay tuned :)

Closed in flavor of #1964

@TimVanDyke
Copy link

For a workaround until then,
https://nercury.github.io/rust/opengl/tutorial/2018/02/12/opengl-in-rust-from-scratch-06-gl-generator.html
See the note at the bottom about autocomplete (It is working for functions but not for enums when you use this workaround)

@matklad
Copy link
Member

matklad commented Mar 19, 2020

It works in master (and will be released next monday):

image

@TimVanDyke
Copy link

TimVanDyke commented Mar 19, 2020

Thank you so much for all the work you're doing!

Can you test it with an enum such as gl::TEXTURE_2D?
#3648

@matklad
Copy link
Member

matklad commented Mar 19, 2020

image

@Mershl
Copy link

Mershl commented Jul 20, 2021

As this is the top entry when searching for this issue I'll add my feedback here. With default settings the rust-analyzer plugin for VSCode currently does not show auto completions for gl. @matklad Was the necessary optional cargo feature renamed?

@memoryruins
Copy link
Contributor

@Mershl the option was renamed to rust-analyzer.cargo.runBuildScripts, which is enabled by default these days. Testing the above screenshots works for me after the project is indexed. Double-check that the option is enabled and that completions are working for other crates/modules. Some troubleshooting steps in https://rust-analyzer.github.io/manual.html#troubleshooting

@CodesOtakuYT
Copy link

As of 18 July 2022, nothing worked for me but I figured out myself:
Step 1: Ctrl + Shift + P to open up vscode pallete then search for "Preferences: Open Settings (JSON)" and press Enter.
A JSON settings file will popup in vscode.
Step 2: add a comma and then this line:
"rust-analyzer.cargo.buildScripts.enable": true
Here is how mine looks like:

{
    "workbench.editor.untitled.hint": "hidden",
    "editor.fontSize": 20,
    "rust-analyzer.cargo.buildScripts.enable": true
}

Step 3: Reload vscode.
Step 4: Enjoy the ride!

@flodiebold
Copy link
Member

rust-analyzer.cargo.buildScripts.enable is true by default.

@CodesOtakuYT
Copy link

@flodiebold I just installed windows 11, vscode and rustanalyzer plugin and it wasn't there by default.

@flodiebold
Copy link
Member

@CodesOtakuYT try removing the option again, and see if anything changes.

@CodesOtakuYT
Copy link

@flodiebold I just removed it and it still works, but it didn't work before adding the option in the first place.

@flodiebold
Copy link
Member

There was probably some other temporary error. I can pretty much guarantee that adding that setting does not help, since it's already the default value.

@Davidos533
Copy link

Davidos533 commented Dec 29, 2024

In my way, cargo clean and cargo build again, solve problem

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

No branches or pull requests

9 participants