Commit Graph

1016 Commits

Author SHA1 Message Date
Ddystopia
b74b9797bc
Update hash in lsp-extensions.md 2023-05-02 17:08:54 +02:00
Ddystopia
da0ffe79d0
Change signature of externalDocs in lsp-extensions 2023-05-02 17:06:39 +02:00
Bruno Ortiz
ecfe7c0488 last fixes after rebase 2023-05-02 11:24:08 -03:00
Bruno Ortiz
66fe84d936 accepting review suggestions 2023-05-02 11:01:41 -03:00
Bruno Ortiz
1b8288ff96 Fixing naming from graph to list 2023-05-02 10:59:29 -03:00
Bruno Ortiz
e2535926e9 Fixing tests 2023-05-02 10:56:50 -03:00
Lukas Wirth
a64626d99e Highlight closure captures when cursor is on pipe 2023-05-02 08:59:40 +02:00
hkalbasi
6312fbf521 MIR episode 4 2023-05-01 23:23:10 +03:30
wtj
c533ac3573 minor: fix typos 2023-04-28 18:49:05 +08:00
Lukas Wirth
c21860bd6a Remove proc-macro server command from the rust-analyzer binary 2023-04-26 08:19:28 +02:00
Josh Soref
bc7d84c3ce Spelling
* a rule
* access
* after
* amount
* annotations
* assignment
* assist
* associated
* attribute
* borrowed
* built-in type
* clarification
* command
* const
* constructor
* corresponding
* counterparts
* curlies
* dependencies
* deterministic
* diagnostic
* duplicates
* edge
* edited
* efficient
* elsewhere
* execution
* expression
* extensions
* extracted
* fill
* github
* helper
* heuristic
* incomplete
* indent end
* inlay
* invocation
* lifetime
* looking
* maybe
* move
* mutability
* mutable
* necessarily
* necessary
* negative
* nonexistent
* occurred
* offsets
* offsetted
* overridden
* parameters
* params
* params_and_where_preds_in_scope
* paredit
* parent
* parentheses
* prepended if
* punctuation
* receive
* receiver
* referring
* repeated
* representing
* semantically
* separately
* shouldnot
* siblings
* similar
* something's
* statement
* struct
* structure
* surprise
* the
* this
* transparent
* unimplemented
* unnamed
* unnecessary
* unneeded
* unreachable
* unterminated
* utilities
* variant
* variants
* visibility
* work around (v)
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-19 09:45:55 -04:00
Lukas Wirth
0286e46e5f internal: Skip code lens resolution for mismatched document versions 2023-04-13 10:55:28 +02:00
hkalbasi
59b6f2d9f2 Compute closure captures 2023-04-10 23:04:34 +03:30
bors
fc8c5139fa Auto merge of #14410 - Veykril:query-lru-capacities, r=Veykril
internal: Add config to specifiy lru capacities for all queries

Might help figuring out what queries should be limited by LRU by default, as currently we only limit `parse`, `parse_macro_expansion` and `macro_expand`.
2023-03-30 12:20:24 +00:00
Lukas Wirth
5616d91b73 internal: Add config to specifiy lru capacities for all queries 2023-03-30 12:52:28 +02:00
Lukas Wirth
ee02213e65 Handle proc macro fetching via OpQueue 2023-03-26 09:33:41 +02:00
Lukas Wirth
586db0790c minor: Add user facing command for reloading proc-macros in VSCode 2023-03-25 20:54:24 +01:00
Lukas Wirth
607375dc20 Load proc-macros asynchronously 2023-03-25 18:06:06 +01:00
Laurențiu Nicola
c3864eb511 Add and use rust-analyzer.cargo.extraArgs setting 2023-03-12 13:04:24 +02:00
hkalbasi
ac04bfd7a7 Add View Mir command and fix some bugs 2023-03-06 21:09:09 +03:30
bors
a0be16b0b2 Auto merge of #14040 - HKalbasi:mir, r=HKalbasi
Beginning of MIR

This pull request introduces the initial implementation of MIR lowering and interpreting in Rust Analyzer.

The implementation of MIR has potential to bring several benefits:
- Executing a unit test without compiling it: This is my main goal. It can be useful for quickly testing code changes and print-debugging unit tests without the need for a full compilation (ideally in almost zero time, similar to languages like python and js). There is a probability that it goes nowhere, it might become slower than rustc, or it might need some unreasonable amount of memory, or we may fail to support a common pattern/function that make it unusable for most of the codes.
- Constant evaluation: MIR allows for easier and more correct constant evaluation, on par with rustc. If r-a wants to fully support the type system, it needs full const eval, which means arbitrary code execution, which needs MIR or something similar.
- Supporting more diagnostics: MIR can be used to detect errors, most famously borrow checker and lifetime errors,  but also mutability errors and uninitialized variables, which can be difficult/impossible to detect in HIR.
- Lowering closures: With MIR we can find out closure capture modes, which is useful in detecting if a closure implements the `FnMut` or `Fn` traits, and calculating its size and data layout.

But the current PR implements no diagnostics and doesn't support closures. About const eval, I removed the old const eval code and it now uses the mir interpreter. Everything that is supported in stable rustc is either implemented or is super easy to implement. About interpreting unit tests, I added an experimental config, disabled by default, that shows a `pass` or `fail` on hover of unit tests (ideally it should be a button similar to `Run test` button, but I didn't figured out how to add them). Currently, no real world test works, due to missing features including closures, heap allocation, `dyn Trait` and ... so at this point it is only useful for me selecting what to implement next.

The implementation of MIR is based on the design of rustc, the data structures are almost copy paste (so it should be easy to migrate it to a possible future stable-mir), but the lowering and interpreting code is from me.
2023-02-28 09:12:19 +00:00
hkalbasi
cd67589f63 beginning of MIR 2023-02-27 23:45:54 +03:30
Laurențiu Nicola
563bd9c24a Try to improve the rustfmt.overrideCommand docs 2023-02-21 12:43:22 +02:00
Ethan-000
936bac31d4
fix link 2023-02-16 21:45:56 +00:00
Aleksey Kladov
0da27376cf Support UTF-32 position encoding
Looks like this is a native encoding for Emacs at least!
2023-02-14 01:09:50 +00:00
bors
646f973857 Auto merge of #14134 - lnicola:clippy-manual, r=Veykril
feat: Add clippy configuration section to the manual and update some old keys

Closes #14132

I don't think this is supposed to be under `Diagnostics`, but it does make sense in a way 🤷 (it's probably where someone might look).
2023-02-12 09:53:15 +00:00
Laurențiu Nicola
8f617b55ce Update some old checkOnSave references 2023-02-12 11:35:44 +02:00
Laurențiu Nicola
cfeec8a705 Add clippy configuration section to the manual 2023-02-12 11:34:52 +02:00
Laurențiu Nicola
9d85161f30 Add Lapce section to the manual 2023-02-12 11:12:05 +02:00
bors
a05ce5a3e7 Auto merge of #13986 - MariaSolOs:limit-completions, r=Veykril
Add setting for limiting number of completions

For #13911.
2023-02-08 09:31:35 +00:00
Lukas Wirth
cb9a5b9549 Support sysroot library source being defined inside the workspace 2023-02-06 12:07:33 +01:00
bors
04850a192c Auto merge of #14049 - lnicola:flatpak, r=lnicola
internal: Add a manual section for Flatpak

Fixes #14042
2023-02-02 13:38:06 +00:00
Laurențiu Nicola
f112d3f756 Add a manual section for Flatpak 2023-02-02 15:37:52 +02:00
Eric Sink
24d3e937ca Expand section on Visual Studio to mention all three available rust-analyzer extensions for that IDE. 2023-02-01 09:48:22 -06:00
Michael Eliachevitch
18366145b0
Update documentation for emacs and split for LSP and Eglot modes
Emacs has now two LSP clients, the more minimalistic and lightweight Eglot and
the extensive though a bit bloated LSP-Mode. Eglot will soon be
shipped with Emacs29. Both have rust-analyzer enabled by default and require
no further setup then just being installed and enabled. `lsp-rust.el` is not
required anymore.

The base-installation for each of those modes is so easy now that I don't think
an enumerated list is necessary, both package can be installed via the standard
`M-x package-install` and the installation is a one-liner that I provide.

Configuration mostly comes into play for support the rust-analyzer extensions to
the LSP protocol, which are built into LSP mode and require an extension-package
for Eglot.

But for the configuration beyond the base configuration I link against official
documentation, quickstart guides and documentation for the lsp extensions, to
avoid showing outdated information here.

This commit is mostly a duplicate of a PR [1] that I made against the
rust-analyzer github project.

[1]: https://github.com/rust-analyzer/rust-analyzer.github.io/pull/197,
     7ff0113006

Spelling: Space before version number in Emacs 29 in manual

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-01-25 13:36:27 +01:00
Partha P. Das
f9bb947fa4
Adding VS IDE 2023-01-23 16:31:03 -05:00
Lukas Wirth
b9fe5afb30 Add a 'open server logs' button to the error notification 2023-01-23 13:24:42 +01:00
Maria José Solano
2ea703c659 Update VS Code settings 2023-01-19 18:34:19 -08:00
Lukas Wirth
f932d39945 Regen config 2023-01-16 17:02:30 +01:00
Lukas Wirth
f2444b2a40 Remove unnecessary Hint suffix on InlayKind variants 2023-01-14 13:08:45 +01:00
Ian Chamberlain
283dfc45dd
Add docs for colorDiagnosticOutput capability 2023-01-09 11:50:37 -05:00
Ian Chamberlain
65cf7abbe2
Use experimental capability to enable color codes 2023-01-09 11:50:35 -05:00
Ian Chamberlain
c3e4bc3136
Update docs to include note about ANSI diagnostics 2023-01-09 11:49:58 -05:00
bors
fd300eebc9 Auto merge of #13799 - Veykril:flycheck, r=Veykril
Rename `checkOnSave` settings to `check`

Now that flychecks can be triggered without saving the setting name doesn't make that much sense anymore. This PR renames it to just `check`, but keeps `checkOnSave` as the enabling setting.
2023-01-09 15:35:38 +00:00
Maybe Waffle
12b7f9f7bf Add an option to minimize parentheses for adjustment hints 2023-01-09 13:35:17 +00:00
Maybe Waffle
b89c4f0a05 Implement postfix adjustment hints
I'd say "First stab at implementing..." but I've been working on this
for a month already lol
2023-01-09 13:27:59 +00:00
Lukas Wirth
d2bb62b6a8 Rename checkOnSave settings to check 2023-01-09 14:17:13 +01:00
Lukas Wirth
87d57f51bc Rename checkOnSave settings to flycheck 2023-01-09 14:17:13 +01:00
bors
fe8ee9c43a Auto merge of #13744 - vtta:numthreads, r=Veykril
feat: add the ability to limit the number of threads launched by `main_loop`

## Motivation
`main_loop` defaults to launch as many threads as cpus in one machine. When developing on multi-core remote servers on multiple projects, this will lead to thousands of idle threads being created. This is very annoying when one wants check whether his program under developing is running correctly via `htop`.

<img width="756" alt="image" src="https://user-images.githubusercontent.com/41831480/206656419-fa3f0dd2-e554-4f36-be1b-29d54739930c.png">

## Contribution
This patch introduce the configuration option `rust-analyzer.numThreads` to set the desired thread number used by the main thread pool.
This should have no effects on the performance as not all threads are actually used.
<img width="1325" alt="image" src="https://user-images.githubusercontent.com/41831480/206656834-fe625c4c-b993-4771-8a82-7427c297fd41.png">

## Demonstration
The following is a snippet of `lunarvim` configuration using my own build.
```lua
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" })
require("lvim.lsp.manager").setup("rust_analyzer", {
  cmd = { "env", "RA_LOG=debug", "RA_LOG_FILE=/tmp/ra-test.log",
    "/home/jlhu/Projects/rust-analyzer/target/debug/rust-analyzer",
  },
  init_options = {
    numThreads = 4,
  },
  settings = {
    cachePriming = {
      numThreads = 8,
    },
  },
})

```

## Limitations
The `numThreads` can only be modified via `initializationOptions` in early initialisation because everything has to wait until the thread pool starts including the dynamic settings modification support.
The `numThreads` also does not reflect the end results of how many threads is actually created, because I have not yet tracked down everything that spawns threads.
2023-01-09 11:53:23 +00:00
bors
17cc78f169 Auto merge of #13832 - Veykril:discriminant-hints, r=Veykril
Enum variant discriminants hints

![image](https://user-images.githubusercontent.com/3757771/209320042-eced617a-9a47-4808-ac23-916f469dc90c.png)
2023-01-02 13:20:33 +00:00
Laurențiu Nicola
d96c489120 Rephrase clippy policy 2022-12-30 16:10:17 +02:00
Lukas Wirth
df8fc78ece Enum variant discriminants hints 2022-12-23 11:37:42 +01:00
bors
eb3963b22e Auto merge of #13817 - WaffleLapkin:hide_adjustment_hints_outside_of_unsafe, r=Veykril
feat: Add an option to hide adjustment hints outside of `unsafe` blocks and functions

As the title suggests: this PR adds an option (namely `rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe`) that allows to hide adjustment hints outside of `unsafe` blocks and functions:

![2022-12-21_23-11](https://user-images.githubusercontent.com/38225716/208986376-d607de62-8290-4e16-b7fe-15b762dc5f60.png)

Requested by `@BoxyUwU` <3
2022-12-22 09:37:00 +00:00
bors
271f7b44d3 Auto merge of #13699 - HKalbasi:inlaylink, r=Veykril
Implement location link for type inlay hints

fix #11701

This actually doesn't work due a problem in vscode: https://github.com/microsoft/vscode/issues/167564
2022-12-21 21:43:38 +00:00
Maybe Waffle
3bfe7040e8 Add an option to hide adjustment hints outside of unsafe blocks 2022-12-21 19:20:42 +00:00
bors
3c00b19b0a Auto merge of #13771 - noritada:feature/release-notes-on-github-releases, r=lnicola
Add xtask for publishing release notes in Markdown on GitHub Releases from a changelog in AsciiDoc

This PR provides `xtask publish-release-notes` to convert a changelog written in AsciiDoc to Markdown and update descriptions (release notes) of a corresponding entry on GitHub Releases.

This AsciiDoc parser is not capable of processing every AsciiDoc document, but I have surveyed a set of existing changelog entries and have confirmed that the following notations used can be converted properly. In the future, I would like to improve the parser to accept any AsciiDoc.  Alternatively, the parser could be moved out of the project.

Your feedback would be appreciated!

Closes #13191

### Supported AsciiDoc syntax

many occurrences
- [x] documentation header
- [x] section header
- [x] `*`-prefixed basic unordered single level list item
- [x] list continuation using `+`
- [x] block image macro `image::...[]` with empty alt
- [x] block image macro `image::...[]` with non-empty alt
- [x] block video marco `video::...[]` with `options=loop`
- [x] inline hard line break `+`
- [x] inline custom macro `commit:...[]`
- [x] inline custom macro `release:...[]`
- [x] inline custom macro `pr:...[]`
- [x] inline unconstrained bold text `**...**`
- [x] inline constrained monospace ``` `...`  ```

[thisweek/_posts/2019-07-24-changelog-0.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/tree/src/thisweek/_posts#:~:text=2019%2D07%2D24%2Dchangelog%2D0.adoc)
- [x] paragraphs
- [x] mixture of `*` and `-` for unordered list item prefix
- [x] inline external link `https://...[]`

[thisweek/_posts/2020-01-13-changelog-7.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/tree/src/thisweek/_posts#:~:text=2020%2D01%2D13%2Dchangelog%2D7.adoc)
- [x] list item with multiline principal text with indent
- [x] inline image macro `image:...[]`

[thisweek/_posts/2020-03-02-changelog-14.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/blob/src/thisweek/_posts/2020-03-02-changelog-14.adoc)
- [x] empty lines between list items
- [x] nested unordered list item with `**`
- [x] inline macro `kbd:[...]`

[thisweek/_posts/2020-03-16-changelog-16.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/blob/src/thisweek/_posts/2020-03-16-changelog-16.adoc)
- [x] `[source]`-prefixed listing

[thisweek/_posts/2020-04-06-changelog-19.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/blob/src/thisweek/_posts/2020-04-06-changelog-19.adoc)
- [x] list item with multiline principal text without indent
- [x] `[source,lang]`-prefixed listing
- [x] `.`-prefiexed ordered list item
- [x] list item immediately after list continuation paragraph without an empty line in between

[thisweek/_posts/2020-04-20-changelog-21.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/blob/src/thisweek/_posts/2020-04-20-changelog-21.adoc)
- [x] title line for block image

[thisweek/_posts/2020-12-21-changelog-56.adoc](https://github.com/rust-analyzer/rust-analyzer.github.io/blob/src/thisweek/_posts/2020-12-21-changelog-56.adoc)
- [x] block video `video::...[]` with `options="autoplay,loop"`
2022-12-21 18:37:10 +00:00
hkalbasi
e1aa73ef40 Disable inlay hint location links on vscode < 1.76 2022-12-21 18:54:49 +03:30
Lukas Wirth
cf8d89e46b Add a command to clear flycheck diagnostics 2022-12-17 23:43:26 +01:00
Lukas Wirth
a04feb915a Add command for manually running flychecks 2022-12-16 22:47:19 +01:00
Noritada Kobayashi
97ec0ea698 Update the release process documentation to run xtask publish-release-notes 2022-12-12 02:09:31 +09:00
Junliang HU
9f5a547b3f Regenerate config 2022-12-09 21:36:35 +08:00
Jonas Schievink
32f59cf01d Update hash 2022-11-29 19:33:16 +01:00
Isobel Redelmeier
b116fe9be0
Fix: Handle empty checkOnSave/target values
This fixes a regression introduced by #13290, in which failing to set
`checkOnSave/target` (or `checkOnSave/targets`) would lead to an invalid
config.
2022-11-21 16:40:32 -05:00
bors
26562973b3 Auto merge of #13653 - VannTen:fix/doc-typo-vim-lsp, r=Veykril
Fix typo on 'configuration' anchor

https://rust-analyzer.github.io/manual.html#_configuration lands you at
the start of the page, while
https://rust-analyzer.github.io/manual.html#configuration correctly puts
you at the correct anchor
2022-11-20 19:59:43 +00:00
Max Gautier
ebbc5492f5 Fix typo on 'configuration' anchor
https://rust-analyzer.github.io/manual.html#_configuration lands you at
the start of the page, while
https://rust-analyzer.github.io/manual.html#configuration correctly puts
you at the correct anchor
2022-11-20 12:47:28 +01:00
ZZzzaaKK
e39d90a8e6 Improve grammar of architecture.md 2022-11-20 01:58:16 +01:00
Alexis (Poliorcetics) Bourget
0d4737adb6 feat: Support passing multiple targets to cargo (for Rust 1.64.0+) 2022-11-11 14:36:07 +01:00
bors
b0e56ef5e8 Auto merge of #13545 - Veykril:adjustment-hints, r=Veykril
Generalize reborrow hints as adjustment hints

Like reborrow hints, these are still mainly useful for teaching/learning

![image](https://user-images.githubusercontent.com/3757771/200073606-b5cd3b95-a9ad-454d-a3c4-d4d89bf45928.png)
2022-11-07 14:38:59 +00:00
Laurențiu Nicola
cff7ab1308 Fix typos 2022-11-07 12:54:12 +02:00
Rongjian Zhang
935eb3f634
docs: fix adoc links 2022-11-06 01:33:57 +08:00
Lukas Wirth
d841ad116a Fix up adjustment hints configurations 2022-11-04 22:59:07 +01:00
Rongjian Zhang
08c2b4557b docs: add crates section to the manual 2022-11-03 13:17:06 +08:00
bors
af1f48deab Auto merge of #13359 - feniljain:feat-must-use-option, r=Veykril
feat: add config for inserting must_use in `generate_enum_as_method`

Should fix #13312

Didn't add a test because I was not sure on how to add test for a specific configuration option, tried to look for the usages for other `AssistConfig` variants but couldn't find any in `tests`. If there is a way to test this, do point me towards it.

I tried to extract the formatting string as a common `template_string` and only have if-else for that, but it didn't compile :(

Also it seems these tests are failing:

```
test config::tests::generate_config_documentation ... FAILED
test config::tests::generate_package_json_config ... FAILED
```

Can you also point me to how to correct these 😅  ( I guess there is some command to automatically generate these? )
2022-11-02 10:50:08 +00:00
bors
8142d1f606 Auto merge of #13445 - notJoon:modify-dead-links, r=lnicola
fix) update broken links in guide.md

Hi, I Just fixed some broken links in `guide.md`.

In most cases, it is not connected by an old version (expecially `guide-2019-01`) of the link, so I made some modifications.

Thanks for your time :)
2022-10-31 06:55:11 +00:00
Laurențiu Nicola
05514d8233
Clarify feature policy 2022-10-27 16:35:07 +03:00
Laurențiu Nicola
956b96a19d Switch to upstream positionEncoding 2022-10-25 14:43:26 +03:00
feniljain
4bf9b9b003 refactor: remove repetitive string interpolation and doc changes 2022-10-24 21:12:31 +05:30
feniljain
c4bdb8e516 feat: add config for inserting must_use in generate_enum_as_method 2022-10-24 13:18:24 +05:30
Lukas Wirth
0f8904ec9c Implement invocation location config 2022-10-22 23:33:03 +02:00
not_joon
8ebc96a8a9 fix broken links in guide.md 2022-10-20 22:06:00 +09:00
Lukas Wirth
46732369f4 Remove simplistic interpolation for manifest-path 2022-10-19 23:53:00 +02:00
Lukas Wirth
7db50294a3 {manifest-path} interpolation 2022-10-19 23:21:34 +02:00
Lukas Wirth
4a287d2525 Implement invocation strategy config for checkOnSave
Note that due to how cargo works, none of the modes currently work for r-a
2022-10-19 23:21:34 +02:00
Lukas Wirth
7e2c41dbd6 Implement invocation strategy config for build scripts 2022-10-19 23:21:29 +02:00
bors
0531aab522 Auto merge of #13397 - zyctree:zyctree-patch-2, r=lnicola
fix link in syntax.md
2022-10-16 17:40:21 +00:00
zyctree
ea8b62f9b0 update link in syntax.md 2022-10-17 01:39:19 +08:00
zyctree
5df03c2c18 update link in syntax.md 2022-10-16 23:41:32 +08:00
Lukas Wirth
88d0efc243
Update guide.md to reflect support for proc-macros 2022-10-16 11:52:01 +02:00
zyctree
34977996c3
Update docs/dev/syntax.md
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2022-10-11 19:37:49 +08:00
zyctree
11a335d5e8
fix link in syntax.md 2022-10-11 14:05:04 +08:00
dvdsk
76be44eed5
Update manual now stable can be installed with rustup
`rustup` can now install `rust-analyzer` for the stable tool-chain. This commit removes the note that `rustup` can only install for the nightly branch and adjusts the command.

I also added a note on how to find the path to the `rust-analyzer` binary when installed using `rustup`, and suggestions on how to work around it not being placed in `~/.cargo/bin`.

I thought it would be ideal to point everyone to use `rustup run stable rust-analyzer` to start `rust-analyzer`. That would make it trivial to switch to nightly however I could not get this to work in `nvim` therefore I left it as a suggestion at the end.
2022-10-10 19:00:47 +02:00
Lukas Wirth
5424c51158 Add config for supplying sysroot path 2022-10-01 21:17:06 +02:00
Paul Delafosse
40e8f03e11 docs(guide): fix Analysis and AnalysisHost doc links 2022-09-22 05:17:47 +02:00
Lukas Wirth
a6c067c06d Simplify 2022-09-19 17:31:08 +02:00
bors
11bf2e7ffb Auto merge of #13058 - dpaoliello:extraenv, r=Veykril
Add a new configuration settings to set env vars when running cargo, rustc, etc. commands: cargo.extraEnv and checkOnSave.extraEnv

It can be extremely useful to be able to set environment variables when rust-analyzer is running various cargo or rustc commands (such as `cargo check`, `cargo --print cfg` or `cargo metadata`): users may want to set custom `RUSTFLAGS`, change `PATH` to use a custom toolchain or set a different `CARGO_HOME`.

There is the existing `server.extraEnv` setting that allows env vars to be set when the rust-analyzer server is launched, but using this as the recommended mechanism to also configure cargo/rust has some drawbacks:
- It convolutes configuring the rust-analyzer server with configuring cargo/rustc (one may want to change the `PATH` for cargo/rustc without affecting the rust-analyzer server).
- The name `server.extraEnv` doesn't indicate that cargo/rustc will be affected but renaming it to `cargo.extraEnv` doesn't indicate that the rust-analyzer server would be affected.
- To make the setting useful, it needs to be dynamically reloaded without requiring that the entire extension is reloaded. It might be possible to do this, but it would require the client communicating to the server what the overwritten env vars were at first launch, which isn't easy to do.

This change adds two new configuration settings: `cargo.extraEnv` and `checkOnSave.extraEnv` that can be used to change the environment for the rust-analyzer server after launch (thus affecting any process that rust-analyzer invokes) and the `cargo check` command respectively. `cargo.extraEnv` supports dynamic changes by keeping track of the pre-change values of environment variables, thus it can undo changes made previously before applying the new configuration (and then requesting a workspace reload).
2022-09-18 17:43:46 +00:00
Daniel Paoliello
c407cc554e Add cargo.extraEnv setting 2022-09-13 11:29:14 -07:00
bors
dbb8fedf8b Auto merge of #13221 - mdx97:mdx97/annotations-above-whole-item, r=Veykril
Allow configuration of annotation location.

I've added the ability to configure where lens annotations render relevant to the item they describe. Previously, these would render directly above the line the item is declared on. Now, there is the ability to render these annotations above the entire item (including doc comments, and attributes).

The names of the config options are up for debate, I did what seemed best to me but if anyone has better ideas let me know.

This is my first contribution so if I've missed anything please let me know.

Here's a preview of what the new option looks like:

<img width="577" alt="Screen Shot 2022-09-11 at 10 39 51 PM" src="https://user-images.githubusercontent.com/33100798/189570298-b4fcbf9c-ee49-4b79-aae6-1037ae4f26af.png">

closes https://github.com/rust-lang/rust-analyzer/issues/13218
2022-09-13 15:09:53 +00:00
Lukas Wirth
a8ecaa1979 Restructure find_path into a separate functions for modules and non-module items
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc
2022-09-13 15:15:27 +02:00
Mathew Horner
f57c15f3e9 Address comments and fix build. 2022-09-12 16:34:13 -05:00
bors
e38dfe5536 Auto merge of #13186 - enomado:master, r=Veykril
Filter imports on find-all-references

Attempt to #13184
2022-09-12 12:09:57 +00:00