Commit Graph

1683 Commits

Author SHA1 Message Date
Nagy Botond
36281e0745 using VSCode's native parameterHints.enabled setting 2023-04-20 22:13:33 +03:00
Nagy Botond
770734fdbb Automatic parameter hints trigger can be toggled on/off 2023-04-20 19:41:15 +03: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
34177d8552 minor: Allow copying the graphviz source from the view crategraph webview 2023-04-13 22:01:57 +02:00
Lukas Wirth
7a6d5c680c fix: Fix view crate graph being broken due to webworker usage 2023-04-13 17:38:12 +02:00
bors
208a74ca50 Auto merge of #14535 - davidbarsky:davidbarsky/use-parent-folder-for-discovery-cwd, r=Veykril
fix: when running the "discoverProjectCommand", use the Rust file's parent directory instead of the workspace folder

This is a quick fix to allow the `discoverProjectCommand` to run successfully when the user has a workspace that does not, e.g., have a `.buckconfig` defined.

(It's also probably _more correct_ to set the `pwd` of the command to the parent of the Rust file _anyways_ rather than relying on the workspace folders, which may be entirely unrelated.)
2023-04-11 07:22:40 +00:00
hkalbasi
59b6f2d9f2 Compute closure captures 2023-04-10 23:04:34 +03:30
David Barsky
b99c129b74 fix: when running the "discoverProjectCommand", use the Rust file's
parent directory instead of the workspace folder.
2023-04-10 09:36:38 -04:00
Lukas Wirth
98a673c4a8 fix: Fix project linking popup appearing for modules that can be linked to a crate 2023-04-09 10:17:58 +02:00
Lukas Wirth
7989a94391 fix: Fix relative path creation using the wrong path accessor 2023-04-04 08:20:35 +02:00
Lukas Wirth
4243eeeb2b fix: Fix vscode project linking popup buttons being swapped 2023-04-04 07:55:09 +02:00
Ryo Yoshida
613e008593
Don't append "!" to non-bang macro name 2023-04-02 20:13:34 +09:00
bors
d3b129f04f Auto merge of #14444 - zapkub:runable-debug-env-is-not-passing-properly, r=Veykril
Missing runnable env on debug target

Fix bug in Rust Analyzer VSCode where runnable debugging did not pass
environment variable from configuration to child process of Cargo on binary build stage

There is a missing env passing along to `cargo` in debug target which give an in-consistent result from debug and run target

For example
```json
{
    "rust-analyzer.runnableEnv": {
        "OUT_DIR": "/test/path2"
    }
}
```

## run
![image](https://user-images.githubusercontent.com/4373581/228749503-fa55f62c-13d3-4d3c-bee6-1cfbe042bdd0.png)
## debug
compiling binary is failed. Missing env
![image](https://user-images.githubusercontent.com/4373581/228749688-3fe42efb-b5ca-41be-862d-f2d97ecab7be.png)

## debug (after fix)
![image](https://user-images.githubusercontent.com/4373581/228750057-1db60051-3465-47db-8b18-4159ec58cfdb.png)
2023-03-30 13:38:36 +00:00
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
Rungsikorn Rungsikavarnich
fb9a1dd87e Missing runnable env on debug target
Fix bug in Rust Analyzer where runnable debugging did not pass
environment variable from configuration to child process of Cargo
on binary build stage
2023-03-30 15:39:49 +09:00
bors
5bba438c9c Auto merge of #14366 - Veykril:linked-proj, r=Veykril
feat: Pop a notification prompting the user to add a Cargo.toml of unlinked file to the linkedProjects

cc https://github.com/rust-lang/rust-analyzer/issues/13226 https://github.com/rust-lang/rust-analyzer/issues/9661
2023-03-28 07:05:43 +00:00
David Barsky
ef422406ef finish renaming rust-analyzer/reloadProcMacros to rust-analyzer/rebuildProcMacros 2023-03-26 15:12:25 -04: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
e9fb2ffe45 Add lsp command for rebuilding proc macros 2023-03-25 16:50:31 +01:00
Lukas Wirth
3622fb6456 Fix lints 2023-03-25 14:14:12 +01:00
x2cf
9745a25d57 Fix VS Code status message formatting error 2023-03-21 14:56:07 +08:00
Lukas Wirth
66636939a6 feat: Pop a notification prompting the user to add a Cargo.toml of unlinked file to the linkedProjects 2023-03-16 16:26:19 +01:00
bors
c15335c8b0 Auto merge of #14307 - davidbarsky:davidbarsky/add-cargo-style-project-discovery-for-buck-and-bazel-sickos, r=Veykril
Add Cargo-style project discovery for Buck and Bazel Users

This feature requires the user to add a command that generates a `rust-project.json` from a set of files. Project discovery can be invoked in two ways:

1. At extension activation time, which includes the generated `rust-project.json` as part of the linkedProjects argument in `InitializeParams`.
2. Through a new command titled "rust-analyzer: Add current file to workspace", which makes use of a new, rust-analyzer-specific LSP request that adds the workspace without erasing any existing workspaces. Note that there is no mechanism to _remove_ workspaces other than "quit the rust-analyzer server".

Few notes:
-  I think that the command-running functionality _could_ merit being placed into its own extension (and expose it via extension contribution points) to provide build-system idiomatic progress reporting and status handling, but I haven't (yet) made an extension that does this nor does Buck expose this sort of functionality.
-  This approach would _just work_ for Bazel. I'll try and get the tool that's responsible for Buck integration open-sourced soon.
- On the testing side of things, I've used this in around my employer's Buck-powered monorepo and it's a nice experience. That being said, I can't think of an open-source repository where this can be tested in public, so you might need to trust me on this one.

I'd love to get feedback on:
- Naming of LSP extensions/new commands. I'm not too pleased with how "rust-analyzer: Add current file to workspace" is named, in that it's creating a _new_ workspace. I think that this command being added should be gated on `rust-analyzer.discoverProjectCommand` on being set, so I can add this in sequent commits.
- My Typescript. It's not particularly good.
- Suggestions on handling folders with _both_ Cargo and non-Cargo build systems and if I make activation a bit better.

(I previously tried to add this functionality entirely within rust-analyzer-the-LSP server itself, but matklad was right—an extension side approach is much, much easier.)
2023-03-14 17:48:49 +00:00
David Barsky
6e7bc07cdf fix: don't override linkedProjects if no workspace was discovered. 2023-03-14 13:36:21 -04:00
David Barsky
bd545a1c10 Address review comments 2023-03-14 12:49:35 -04:00
bors
4cbb940cc4 Auto merge of #14337 - Veykril:vscode-status, r=lnicola
internal: Allow the status bar item to be clicked again

And give that the most useful action for the given state.
2023-03-14 07:23:17 +00:00
David Barsky
78aed305e1 rename "addProject" command 2023-03-13 15:37:58 -04:00
David Barsky
cb93c12c31 fmt 2023-03-13 13:33:39 -04:00
David Barsky
56273b3cf5 Remove rust-analyzer/addProject in favor of notifying r-a that configuration has changed 2023-03-13 13:30:19 -04:00
David Barsky
8d9bff0c74 Add a workspace config-based approach to reloading discovered projects. 2023-03-13 13:30:19 -04:00
David Barsky
91371494ee move rust-analyzer.discoverProjectCommand above $generated-start to avoid failing tests 2023-03-13 13:30:19 -04:00
David Barsky
68d3eaead4 fix typo in package.json. 2023-03-13 13:30:19 -04:00
David Barsky
1f5c535089 remove errant -- in executeDiscoverProject 2023-03-13 13:30:19 -04:00
David Barsky
46e022098f fmt 2023-03-13 13:30:19 -04:00
David Barsky
8af3d6367e This commit add Cargo-style project discovery for Buck and Bazel users.
This feature requires the user to add a command that generates a
`rust-project.json` from a set of files. Project discovery can be invoked
in two ways:

1. At extension activation time, which includes the generated
   `rust-project.json` as part of the linkedProjects argument in
    InitializeParams
2. Through a new command titled "Add current file to workspace", which
   makes use of a new, rust-analyzer specific LSP request that adds
   the workspace without erasing any existing workspaces.

I think that the command-running functionality _could_ merit being
placed into its own extension (and expose it via extension contribution
points), if only provide build-system idiomatic progress reporting and
status handling, but I haven't (yet) made an extension that does this.
2023-03-13 13:30:18 -04:00
Lukas Wirth
cf95322541 Allow the status bar item to be clicked again 2023-03-13 12:32:53 +01:00
Laurențiu Nicola
c3864eb511 Add and use rust-analyzer.cargo.extraArgs setting 2023-03-12 13:04:24 +02:00
Lukas Wirth
2cb60343ed Add fancy buttons to the vscode status message 2023-03-10 10:13:30 +01: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
Tomoki Nakagawa
e4b184a776 Respect $CARGO_HOME when looking up toolchains. 2023-02-26 15:37:04 +09:00
bors
f5401f6206 Auto merge of #14175 - jmviz:openDocs-context-menu, r=lnicola
add openDocs command to context menu in VS Code extension

This adds the `openDocs` command to the VS Code context menu. I believe there are probably many user who are unaware of this command existing in the rust analyzer extension, and that this should enhance the discoverability of the command. Additionally, even if people are aware of this capability, it's helpful to have this in the context menu anyway; for example, one might forget the name of the command, or the keybinding they have assigned to it. I think that opening docs is a common enough action to warrant the extra line added to the context menu.

This makes a few other small changes as well. There are two minor style changes to increase style consistency. First, it changes the titles of the two commands that the rust analyzer extension will contribute to the context menu to title case. All standard VS Code commands that appear in the context menu are in title case. Second, it shortens the title of the `openDocs` command from `Open docs under cursor` to `Open Docs`. The implicit assumption in the standard VS Code context menu command titles is that the action applies to the symbol under the cursor: `Go to Definition`, `Find All References`, etc. Note that since these are changes to the command titles, rather than the command names themselves, these changes will not break any users' existing keybindings for these commands.

Second, this adds further restrictions to the `where` clauses of the two commands that the rust analyzer extension will contribute to the context menu, so that the two commands will appear in the context menu only when in a Rust project **and** within a Rust file. Say you have a Python or bash script inside your Rust project. Having these commands appear in the context menu when you right click a symbol in such a non-Rust file is extraneous and potentially confusing.

![demonstration](https://user-images.githubusercontent.com/6609145/219976062-b46ab21b-5753-48f5-a1da-562566cae71c.gif)
2023-02-24 06:55:02 +00:00
Laurențiu Nicola
563bd9c24a Try to improve the rustfmt.overrideCommand docs 2023-02-21 12:43:22 +02:00
jmviz
2351875e6a change titles of commands in context menu to title case. shorten open docs command 2023-02-19 10:12:44 -05:00
jmviz
ed1f467aab add openDocs to context menu. add further restrictions to context menu when clauses to prevent irrelevant commands in non-rust files 2023-02-17 17:41:39 -05:00
Lukas Wirth
95fa278f30 Don't assume VSCode internal commands in the server 2023-02-14 14:45:48 +01:00
bors
8011029d3a Auto merge of #13975 - DropDemBits:on-enter-after-dot-chains, r=DropDemBits
fix: Suppress extra indent after the end of field and function chains

(spurred on by <https://github.com/rust-lang/rust-analyzer/issues/4182#issuecomment-671275652>)

Caveat that this doesn't work for after tail expressions, although there shouldn't be anything after those anyways.

This also complicates when to reload the language configuration by nature of now always having a language configuration applicable.

Examples of indentation fixes:

```rs
fn main() {
    println!("Hello!"); // < enter here!
    // ... indents down here

    fs::read_to_string("soup") // < enter here!
    // ... still indents down here :(
        .map(|_| ())
        .map(|_| ()) // < enter here!
        // ... still indents down here :D
        .map_err(|_| ())
        .unwrap(); // < enter here!
    // ... indents down here :D

    // ... and subsequent enters stay at the same indent

    0.0f64
        .to_radians()
        .to_radians()
        .to_radians() // force semi on a new line
        ; // < enter here!
    // ... indents down here :D
}

fn tail_end() -> i32 {
    0i32.wrapping_abs()
        .wrapping_abs()
        .wrapping_abs()
        .wrapping_abs() // < enter here!
        // ... still indents here 🤷
}
```
2023-02-10 20:10:54 +00:00