Skip to content

Conversation

@cormacrelf
Copy link
Contributor

@cormacrelf cormacrelf commented Sep 4, 2024

This is a prerequisite to using workspace_discoverConfig at all, since if it isn't present in the initialization RPC, then rust-analyzer just discovers a cargo project and never looks at workspace_discoverConfig ever again. The discoverConfig stuff is pretty unstable but this at least gets things going.

Note that VSCode does it this way as well. I think at this point we may be sending too many didChangeConfiguration RPCs, but at least stuff works!

Example config -- using rust-project from the buck2 project

(Put this in a rust-analyzer.json file for rustaceanvim to find. The rust-analyzer.toml support in R-A itself is still incapable of reading the file at startup... :/)

{
  "rust-analyzer.workspace.discoverConfig": {
    "command": [
      "rust-project",
      "develop-json",
      "--use-clippy",
      "false",
      "{arg}"
    ],
    "progressLabel": "buck2/rust-project",
    "filesToWatch": ["BUCK", "BUCK.v2"]
  }
}

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2024

Review Checklist

Does this PR follow the Contribution Guidelines? Following is a partial checklist:

Proper conventional commit scoping:

  • For example, fix(lsp): some lsp-related bugfix

  • Pull request title has the appropriate conventional commit prefix.

If applicable:

  • Tested
    • Tests have been added.
    • Tested manually (Steps to reproduce in PR description).
  • Updated documentation.
  • Updated CHANGELOG.md

@cormacrelf cormacrelf changed the title Copy settings to init_options when starting the server fix(lsp): copy settings to init_options when starting the server to match VSCode Sep 4, 2024
Copy link
Owner

@mrcjkb mrcjkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙏

LGTM.

The rust-analyzer.toml support in R-A itself is still incapable of reading the file at startup... :/)

I will probably deprecate rustaceanvim's rust-analyzer.json feature in favour for rust-analyzer's rust-analyzer.toml feature soon.

@mrcjkb mrcjkb merged commit 1e4d10d into mrcjkb:master Sep 4, 2024
@cormacrelf
Copy link
Contributor Author

At this rate, not only will it be a long time before the TOML support is functional, there is apparently a list of configs you cannot ever use TOML to configure, which are reserved for the LSP client to send as JSON as it's assumed they would never be configured beyond a single person's editor. And these lists are very much in flux. So please don't deprecate the feature! It's the only thing that works.

@mrcjkb
Copy link
Owner

mrcjkb commented Sep 4, 2024

rustaceanvim now also supports ~/.vscode/settings.json (with a "rust-analyzer": key). So there should be no need for rust-analyzer.json anymore.

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

Successfully merging this pull request may close these issues.

2 participants