rustyscreeps / screeps-starter-rust

Starter Rust AI for Screeps, the JavaScript-based MMO game
MIT License
121 stars 47 forks source link

Configuring RLS #17

Closed martsa1 closed 4 years ago

martsa1 commented 4 years ago

Hi Folks,

First off, thank you so much for providing this basis to get working with rust in screeps! It looks like a huge amount of work has been put into this and the various projects this sits on top of.

For the authors of this project, and those this sits on top of, has anyone managed to get RLS working with it? I'm currently trying to get RLS to provide appropriate diagnostics and the like, but I'm getting errors related to the target, or not finding crates etc.

Has anyone bumped into this kind of thing already? If so, perhaps we could add a settings.json file to the starter project, to help others get their RLS setup more quickly.

Thanks in advance for any advice,

martsa1 commented 4 years ago

After a fair amount of fiddling, The following settings seem to allow autocomplete to work from within neovim using the RLS Language client, which I pulled out of a debug VS Code...

in ./vim/settings.json:

{
  "rust": {
    "sysroot": null,
    "target": null,
    "rustflags": null,
    "clear_env_rust_log": true,
    "build_lib": null,
    "build_bin": null,
    "cfg_test": false,
    "unstable_features": false,
    "wait_to_build": 1500,
    "show_warnings": true,
    "crate_blacklist": [
      "cocoa",
      "gleam",
      "glium",
      "idna",
      "libc",
      "openssl",
      "rustc_serialize",
      "serde",
      "serde_json",
      "typenum",
      "unicode_normalization",
      "unicode_segmentation",
      "winapi"
    ],
    "build_on_save": false,
    "features": [],
    "all_features": false,
    "no_default_features": false,
    "racer_completion": true,
    "clippy_preference": "opt-in",
    "jobs": null,
    "all_targets": true,
    "target_dir": null,
    "rustfmt_path": null,
    "build_command": null,
    "full_docs": null,
    "show_hover_context": true
  }
}

I don't really know which of these settings seems to do the trick, but I think its enough for this issue to be closed (autocomplete worked out of the box on VS Code...).

For any other Vim masochists that see this, hope it helps...

ASalvail commented 4 years ago

If I were to venture a guess, I'd point to either the compile target (wasm, while better supported than in other language, is still in its infancy) or serde that is blacklisted in your new config.

Thank you for leaving this here for others to learn from!

martsa1 commented 4 years ago

Oddly, this evening I'm having more issues again,this time both in Nvim and VS Code. Out of curiosity, what is your experience like with these libraries, and what editor do you use?

Particularly trying to complete on things like Creep:: and creep.memory(). seem to struggle a lot, and the source code is often wrapped in macros, which I don't really want to delve into just yet...

The generated docs are reasonably helpful though which is good!

ASalvail commented 4 years ago

I'm using VSCode with the screeps rust API source code built from my computer, rather than in a crate. RLS is installed with mostly default values otherwise (other than using nightly).

Whether the RLS works is often a hit or miss situation. It has a lot of trouble with macros, as you mentioned. It keeps getting better however!

Feel free to reach out either here or on slack, there should be someone willing to help.