Commit Graph

1471 Commits

Author SHA1 Message Date
Jake Heinz a965161dce [editors/vscode] cleaer status bar bg color / command when server status returns to OK 2022-06-01 06:58:16 +00:00
Lukas Wirth 3e25c853cf fix: Fix VSCode config patching incorrectly patching some configs 2022-05-31 13:38:48 +02:00
harpsword 55509548e8 fix: add an option to show inlay hint for return type of closures without block 2022-05-28 22:12:30 +08:00
Hofer-Julian 2916cd2a86 Fix typo 2022-05-26 19:12:49 +02:00
Lukas Wirth 02c2377229 internal: Use statusBarItem colors for status item in VSCode 2022-05-26 12:31:07 +02:00
Lukas Wirth f02c915eb5 internal: Make autoclosing angle brackets configurable, disabled by default 2022-05-25 12:42:07 +02:00
Jake Heinz b8ee992b57 prettier 2022-05-24 03:11:30 +00:00
Jake Heinz d1aa6d3216 vscode: fix extraEnv handling numeric values 2022-05-24 03:00:29 +00:00
Laurențiu Nicola 1e617f4fc6 Fix broken async callback in join lines 2022-05-21 18:38:10 +03:00
Jonas Schievink c99a5ae312 Add "cargo clippy" task preset 2022-05-20 15:25:37 +02:00
andylizi 2b1c1a934c feat: hide type inlay hints for initializations of closures 2022-05-20 17:42:56 +08:00
Equinox 7197042ac4 remove duplicate 'to' in cachePriming.numThreads option description 2022-05-20 02:05:48 +12:00
Andrei Listochkin e87e1bc33d "Show implementations" link display error fix
While VSCode [uses it's own implementation for URIs](https://github.com/microsoft/vscode-uri)
which notably doesn't have any limits of URI size, the renderer itself
relies on Web platform engine, that limits the length of the URLs and
bails out when the attribute length of an `href` inside `a` tag is too
long.

Command URIs have a form of `command:command-name?arguments`, where
`arguments` is a percent-encoded array of data we want to pass along to
the command function. For "Show References" this is a list of all file
URIs with locations of every reference, and it can get quite long.

This PR introduces another intermediary `linkToCommand` command. When
we render a command link, a reference to a command with all its arguments
is stored in a map, and instead a `linkToCommand` link is rendered
with the key to that map.

For now the map is cleaned up periodically (I've set it to every
10 minutes). In general case we'll probably need to introduce TTLs or
flags to denote ephemeral links (like these in hover popups) and
persistent links and clean those separately. But for now simply keeping
the last few links in the map should be good enough. Likewise, we could
add code to remove a target command from the map after the link is
clicked, but assuming most links in hover sheets won't be clicked anyway
this code won't change the overall memory use much.

Closes #9926
2022-05-18 14:12:23 +01:00
Andrei Listochkin 00a97272f2 automate braceless return substitution for long lines
Per [bjorn3][https://github.com/bjorn3] suggestion resolves cases where
an early return is moved to a separate line due to line width formatting.

This setting changes
```
if (a very long condition) return;
```
to
```
if (a very long
    condition) {
  return;
}
```
while keeping
```
if (short) return;
```
as is.

In pathological cases this may cause `npm run fix` not to fix formatting
in one go and may require running it twice.
2022-05-17 18:31:51 +01:00
Andrei Listochkin e0df2c9bee remove tsfmt from dependencies 2022-05-17 18:16:04 +01:00
Andrei Listochkin f247090558 prettier run 2022-05-17 18:15:06 +01:00
Andrei Listochkin 8e9f54f238 use prettier to format the code 2022-05-17 18:14:28 +01:00
Andrei Listochkin 4fcdb0fea0 prettier config
[Prettier][1] is an up-to date code formatter for JavaScript ecosystem.

For settings we rely on [EditorConfig][2] for things like tab style and
size (with added bonus that the code editor with an EditorConfig plugin
does some automated code formatting on file save for you). Unfortunately,
Prettier's Glob handling isn't great:
 1. `*.{ts,js,json}` has no effect
 2. Similarly, in a list of globs `*.ts,*.js,*.json` only the first glob
has an effect, the rest are ignored.
That's why the file looks the way it does.

The only other setting we change is line width. [Lukas][3] suggested we
use 100 instead of 80, because that's what Rustfmt is using.

[1]: https://prettier.io
[2]: https://editorconfig.org
[3]: https://github.com/Veykril
2022-05-17 18:12:49 +01:00
Jonas Schievink 21b6ce8b8e Bump extension version 2022-05-17 16:02:07 +02:00
Lukas Wirth d43b9dae56 Fix incorrect config key in client config update
Closes https://github.com/rust-lang/rust-analyzer/issues/12288
2022-05-17 14:56:08 +02:00
Jonas Schievink 867a7dc7a0 Show inlay hints after a } to indicate the closed item 2022-05-16 14:55:47 +02:00
bors 1dc25e51a0 Auto merge of #12253 - Veykril:bm, r=Veykril
feat: Add binding mode inlay hints

![image](https://user-images.githubusercontent.com/3757771/168427387-2f299438-a0cc-496b-a9a5-d689ef6a2b55.png)
2022-05-16 11:16:22 +00:00
bors ac4ce4259b Auto merge of #12242 - flodiebold:extension-description, r=flodiebold
Improve extension description and README
2022-05-15 18:11:32 +00:00
Lukas Wirth 977f0ba968 Update package.json 2022-05-14 15:18:18 +02:00
Lukas Wirth 622defb373 internal: Make VSCode config more GUI edit friendly 2022-05-14 13:53:41 +02:00
Florian Diebold 3dcf9e0f2e Change description 2022-05-13 22:13:23 +02:00
Lukas Wirth 8496633c87 Don't make r-a fail to initialize if updating the config fails 2022-05-13 21:20:37 +02:00
Lukas Wirth 8ac429dad9 fix: Fix incorrect hover actions config keys 2022-05-13 21:17:03 +02:00
Florian Diebold 85fe9391d3 Improve extension description and README 2022-05-13 18:15:33 +02:00
Lukas Wirth 99a51dfe9b Update package description 2022-05-13 14:11:09 +02:00
Lukas Wirth a8133680af fix: Fix typo in publisher field 2022-05-13 14:10:37 +02:00
Lukas Wirth e47f4597d4 feat: Change VSCode extension publisher to rust-lang 2022-05-13 13:21:52 +02:00
Lukas Wirth d57beac7e6 fix: Fix vscode config descriptions not recognizing all valid values 2022-05-12 18:15:48 +02:00
bors 135164f547 Auto merge of #12226 - Veykril:reborrow-inlay-hints, r=Veykril
feat: Allow reborrow inlay hints to be restricted to mutable reborrows only
2022-05-12 12:21:06 +00:00
Lukas Wirth c2190ad87c feat: Allow reborrow inlay hints to be restricted to mutable reborrows only 2022-05-12 14:00:06 +02:00
bors 927ef0ce7e Auto merge of #12215 - listochkin:Support-variable-substitution-in-vscode-settings, r=Veykril
feat: Support variable substitution in VSCode settings

Currently support a subset of [variables provided by VSCode](https://code.visualstudio.com/docs/editor/variables-reference) in `server.extraEnv` section of Rust-Analyzer settings:

  * `workspaceFolder`
  * `workspaceFolderBasename`
  * `cwd`
  * `execPath`
  * `pathSeparator`

Also, this PR adds support for general environment variables resolution. You can declare environment variables and reference them from other variables like this:

```JSON
"rust-analyzer.server.extraEnv": {
    "RUSTFLAGS": "-L${env:OPEN_XR_SDK_PATH}",
    "OPEN_XR_SDK_PATH": "${workspaceFolder}\\..\\OpenXR-SDK\\build\\src\\loader\\Release"
},
```
The order of variable declaration doesn't matter, you can reference variables before defining them. If the variable is not present in `extraEnv` section, VSCode will search for them in your environment. Missing variables will be replaced with empty string. Circular references won't be resolved and will be passed to rust-analyzer server process as is.

Closes #9626, but doesn't address use cases where people want to use values provided by `rustc` or `cargo`, such as `${targetTriple}` proposal #11649
2022-05-12 11:05:21 +00:00
Lukas Wirth 84176f6b24 internal: Rename primeCaches config keys 2022-05-12 12:30:00 +02:00
Luna Razzaghipour 23ec7cfec4 Fix character semantic token type definition 2022-05-12 18:15:39 +10:00
Andrei Listochkin 33d2c8a3f9 Enable variable substitutions before passing them over to R-A server 2022-05-11 15:53:28 +01:00
Andrei Listochkin 684fa2794f VSCode variables support for substitutions
Tests now open Rust-Analyzer extension code in order to populate
VSCode variables.
2022-05-11 15:50:59 +01:00
Andrei Listochkin 6c769ac00d handle references to external environment variables
use cross-env to enable env variables on Windows
2022-05-11 15:50:25 +01:00
Andrei Listochkin a86db5d0d1 iterative dependency solver
First, we go through every environment variable key and record all cases
where there are reference to other variables / dependencies.

We track two sets of variables - resolved and yet-to-be-resolved.
We pass over a list of variables over and over again and when all
variable's dependencies were resolved during previous passes we perform
a replacement for that variable, too.

Over time the size of `toResolve` set should go down to zero, however
circular dependencies may prevent that. We track the size of `toResolve`
between iterations to avoid infinite looping.

At the end we produce an object of the same size and shape as
the original, but with the values replace with resolved versions.
2022-05-11 15:05:41 +01:00
Andrei Listochkin 18d2fb81a7 search for test files instead of explicitly name them 2022-05-11 15:03:34 +01:00
bors 94fa8a6534 Auto merge of #12213 - Veykril:config-fix, r=Veykril
fix: Fix incorrect config patching for runBuildScripts
2022-05-11 10:38:56 +00:00
Lukas Wirth e68352a9f5 fix: Fix incorrect config patching for runBuildScripts 2022-05-11 12:38:21 +02:00
Elliot Roberts 2298a76222 fix typo in inlayHints.renderColons option description 2022-05-10 19:15:07 -07:00
bors 460e389f54 Auto merge of #12010 - Veykril:r-a-config, r=Veykril
Config revamp

Fixes https://github.com/rust-lang/rust-analyzer/issues/11790
Fixes https://github.com/rust-lang/rust-analyzer/issues/12115

This PR changes a lot of config names, and a few ones are being merged or split apart. The reason for this is that our configuration names currently are rather inconsistent and some where poorly chosen in regards to extensability. This PR plans to fix that.

We still allow the old config names by patching them to the new ones before deserializing to keep backwards compatability with other clients (the VSCode client will auto update the config) but ideally we will get rid of that layer in the future.

Here is a list of the changes:

These are simple renames `old_name | alias1 | alias2 ... -> new_name` (the vscode client will fix these up automagically):
```
assist_allowMergingIntoGlobImports -> imports_merge_glob
assist_exprFillDefault -> assist_expressionFillDefault
assist_importEnforceGranularity -> imports_granularity_enforce
assist_importGranularity | assist_importMergeBehavior | assist_importMergeBehaviour -> imports_granularity_group
assist_importGroup -> imports_group_enable
assist_importPrefix -> imports_prefix

cache_warmup -> primeCaches_enable

cargo_loadOutDirsFromCheck -> cargo_buildScripts_enable
cargo_runBuildScripts | cargo_runBuildScriptsCommand -> cargo_runBuildScripts_overrideCommand
cargo_useRustcWrapperForBuildScripts -> cargo_runBuildScripts_useRustcWrapper

completion_snippets -> completion_snippets_custom

diagnostics_enableExperimental -> diagnostics_experimental_enable

experimental_procAttrMacros -> procMacro_attributes_enable

highlighting_strings -> semanticHighlighting_strings_enable

highlightRelated_breakPoints -> semanticHighlighting_breakPoints_enable
highlightRelated_exitPoints -> semanticHighlighting_exitPoints_enable
highlightRelated_yieldPoints -> semanticHighlighting_yieldPoints_enable
highlightRelated_references -> semanticHighlighting_references_enable

hover_documentation -> hover_documentation_enable
hover_linksInHover | hoverActions_linksInHover -> hover_links_enable
hoverActions_debug -> hoverActions_debug_enable
hoverActions_enable -> hoverActions_enable_enable
hoverActions_gotoTypeDef -> hoverActions_gotoTypeDef_enable
hoverActions_implementations -> hoverActions_implementations_enable
hoverActions_references -> hoverActions_references_enable
hoverActions_run -> hoverActions_run_enable

inlayHints_chainingHints -> inlayHints_chainingHints_enable
inlayHints_closureReturnTypeHints -> inlayHints_closureReturnTypeHints_enable
inlayHints_hideNamedConstructorHints -> inlayHints_typeHints_hideNamedConstructorHints
inlayHints_parameterHints -> inlayHints_parameterHints_enable
inlayHints_reborrowHints -> inlayHints_reborrowHints_enable
inlayHints_typeHints -> inlayHints_typeHints_enable

lruCapacity -> lru_capacity

runnables_cargoExtraArgs -> runnables_extraArgs
runnables_overrideCargo -> runnables_command

rustcSource -> rustc_source

rustfmt_enableRangeFormatting -> rustfmt_rangeFormatting_enable
```

These are configs that have been merged or split apart, which have to be manually updated by the user:

```
callInfo_full -> signatureInfo_detail, signatureInfo_documentation_enable

cargo_allFeatures, cargo_features -> cargo_features
checkOnSave_allFeatures, checkOnSave_features -> checkOnSave_features
completion_addCallArgumentSnippets completion_addCallParenthesis -> completion_callable_snippets
```
2022-05-10 12:07:24 +00:00
bors 9e10d4b717 Auto merge of #12093 - nico-abram:uwu, r=Veykril
Reload project on .cargo/config[.toml] changes

Fixes #11024

Not adding tests as discussed in the issue
2022-05-02 12:21:42 +00:00
Lukas Wirth 291f94e22e Fix up config docs 2022-05-01 19:57:09 +02:00
Lukas Wirth d6dba1c97c auto update old configurations to newer ones 2022-05-01 19:57:09 +02:00