about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2022-05-20Auto merge of #12325 - jonas-schievink:clear-check-diags, r=jonas-schievinkbors-0/+1
fix: Clear `cargo check` diagnostics when flycheck is turned off Previously stale diagnostics were left over indefinitely when turning off "Check on Save" while diagnostics are present.
2022-05-20Clear `cargo check` diagnostics when flycheck is turned offJonas Schievink-0/+1
2022-05-20Auto merge of #12324 - jonas-schievink:rm-attribute, r=jonas-schievinkbors-226/+158
feat: Revert the "Add attribute" assist Reverts https://github.com/rust-lang/rust-analyzer/pull/12296, as the added indirection and "assist noise" (the assist has to trigger inside the body of an item to match what the "Add `#[derive]`" does) makes this not really pull its weight over just using attribute completions. Keeps the changes to "Add getter". `#[must_use]` can be applied using the attribute completions.
2022-05-20Auto merge of #12315 - matklad:update, r=Veykrilbors-107/+93
:arrow_up: deps
2022-05-20Revert the "Add attribute" assistJonas Schievink-226/+158
2022-05-20Auto merge of #12263 - andylizi:hide-type-hint-closure, r=Veykrilbors-5/+90
feat: hide type inlay hints for initializations of closures ![hide_closure_initialization](https://user-images.githubusercontent.com/12008103/168470158-6cb77b18-068e-4431-a8b5-e2b22d50d263.gif) This PR adds an option to hide the inlay hints for `let IDENT_PAT = CLOSURE_EXPR;`, which is a somewhat common coding pattern. Currently the inlay hints for the assigned variable and the closure expression itself are both displayed, making it rather repetitive. In order to be consistent with closure return type hints, only closures with block bodies will be hid by this option. Personally I'd feel comfortable making it always enabled (or at least when closure return type hints are enabled), but considering the precedent set in #10761, I introduced an off-by-default option for this. changelog feature: option to hide type inlay hints for initializations of closures
2022-05-20Auto merge of #12301 - harpsword:fix_for_crlf_cargo_range_map, r=jonas-schievinkbors-22/+5
fix: calculate correct postion for Dos line ending in mapping rustc range to ls… fix #12293
2022-05-20feat: hide type inlay hints for initializations of closuresandylizi-5/+90
2022-05-19Auto merge of #12320 - NotWearingPants:patch-1, r=Veykrilbors-0/+4
Hide closure ret hints if ret type is specified Fixes #12319
2022-05-20hide closure ret hints if ret type is specifiedNotWearingPants-0/+4
fixes #12319
2022-05-19Auto merge of #12316 - jonas-schievink:closure-param-hints, r=jonas-schievinkbors-22/+77
feat: Show parameter inlay hints for closure invocations Fixes https://github.com/rust-lang/rust-analyzer/issues/12268
2022-05-19Teach `Callable` about closures properlyJonas Schievink-22/+77
2022-05-19:arrow_up: depsAleksey Kladov-107/+93
2022-05-19Auto merge of #12314 - jonas-schievink:proc-macro-load, r=jonas-schievinkbors-15/+11
minor: simplify
2022-05-19Auto merge of #12313 - equinox:typo-fix, r=lnicolabors-3/+3
Removed duplicate 'to' in `cachePriming.numThreads` option description One 'to' too many!
2022-05-20remove duplicate 'to' in `cachePriming.numThreads` option descriptionEquinox-3/+3
2022-05-19Auto merge of #12311 - Veykril:inlay-hints-tips, r=Veykrilbors-95/+195
internal: Improve inlay hint tooltips
2022-05-19Hide more unnecessary parameter hints for constructorsLukas Wirth-9/+34
2022-05-19simplifyJonas Schievink-15/+11
2022-05-19Update test fixturesLukas Wirth-27/+73
2022-05-19Enable hovering function parameter inlay hintsLukas Wirth-13/+28
2022-05-19internal: Improve inlay hint tooltipsLukas Wirth-57/+71
2022-05-19Auto merge of #12309 - Veykril:completion, r=Veykrilbors-2/+42
fix: Fix incorrect expected type in completions for trailing match arms Fixes https://github.com/rust-lang/rust-analyzer/issues/12264
2022-05-19fix: Fix incorrect expected type in completions for match armsLukas Wirth-2/+42
2022-05-18Auto merge of #12304 - jonas-schievink:more-doc-gen-improvements, ↵bors-17/+39
r=jonas-schievink minor: Include self type in generated getter/setter docs
2022-05-18Include self type in generated getter/setter docsJonas Schievink-17/+39
2022-05-18Auto merge of #12303 - jonas-schievink:improve-generate-docs-assist, ↵bors-371/+248
r=jonas-schievink feat: Improve docs generation assist - Split into 2 assists: one generates basic docs structure, but no example, one generates an example - Fix section ordering (the example comes last) - Allow generating docs for private functions - Expand `len` to `length` when generating an intro sentence
2022-05-18Improve docs generation assistJonas Schievink-371/+248
2022-05-18Auto merge of #12277 - listochkin:show-implementations-display-error, ↵bors-3/+48
r=listochkin "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"Show implementations" link display error fixAndrei Listochkin-3/+48
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-18fix: calculate right range for Dos line ending in mapping rustc range to lsp ↵harpsword-22/+5
range
2022-05-17Auto merge of #12130 - weirane:let-else-let-match, r=weiranebors-0/+519
Turn let-else statements into let and match Fixes #11906.
2022-05-17Auto merge of #12294 - listochkin:prettier, r=Veykrilbors-974/+1263
Switch to Prettier for TypeScript Code formatting ## Summary of changes: 1. Added [`.editorconfig` file](https://editorconfig.org) to dictate general hygienic stuff like character encoding, no trailing whitespace, new line symbols etc. for all files (e.g. Markdown). Install an editor plugin to get this rudimentary formatting assistance automatically. Prettier can read this file and, for example, use it for indentation style and size. 2. Added a minimal prettier config file. All options are default except line width, which per [Veykril](https://github.com/Veykril) suggestion is set to 100 instead of 80, because [that's what `Rustfmt` uses](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#max_width). 3. Change `package.json` to use Prettier instead of `tsfmt` for code formatting. 4. Performed initial formatting in a separate commit, per [bjorn3](https://github.com/bjorn3) suggestion added its hash to a `.git-blame-ignore-revs` file. For it to work you need to add a configuration to your git installation: ```Shell git config --global blame.ignoreRevsFile .git-blame-ignore-revs ``` 5. Finally, removed `typescript-formatter` from the list of dependencies. ---- What follows below is summary of the discussion we had on Zulip about the formatter switch: ## Background For the context, there are three reasons why we went with `tsfmt` originally: * stick to vscode default/built-in * don't add extra deps to package.json.lock * follow upstream (language server node I think still uses `tsfmt`) And the meta reason here was that we didn't have anyone familiar with frontend, so went for the simplest option, at the expense of features and convenience. Meanwhile, [**Prettier**](https://prettier.io) became a formatter project that JS community consolidated on a few years ago. It's similar to `go fmt` / `cargo fmt` in spirit: minimal to no configuration to promote general uniformity in the ecosystem. There are some options, that were needed early on to make sure the project gained momentum, but by no means it's a customizable formatter that is easy to adjust to reduce the number of changes for adoption. ## Overview of changes performed by Prettier Some of the changes are acceptable. Prettier dictates a unified string quoting style, and as a result half of our imports at the top are changed. No one would mind that. Some one-line changes are due to string quotes, too, and although these a re numerous, the surrounding lines aren't changed, and git blame / GitLens will still show relevant context. Some are toss ups. `trailingComma` option - set it to `none`, and get a bunch of meaningless changes in half of the code. set it to `all` and get a bunch of changes in the other half of the code. Same with using parentheses around single parameters in arrow functions: `x => x + 1` vs `(x) => x + 1`. Perrier forces one style or the other, but we use both in our code. Like I said, the changes above are Ok - they take a single line, don't disrupt GitLens / git blame much. **The big one is line width**. Prettier wants you to choose one and stick to it. The default is 80 and it forces some reformatting to squish deeply nested code or long function type declarations. If I set it to 100-120, then Prettier finds other parts of code where a multi-line expression can be smashed into a single long line. The problem is that in both cases some of the lines that get changed are interesting, they contain somewhat non-trivial logic, and if I were to work on them in future I would love to see the commit annotations that tell me something relevant. Alas, we use some of that. ## Project impact Though Prettier is a mainstream JS project it has no dependencies. We add another package so that it and ESLint work together nicely, and that's it.
2022-05-17Simplify const reference checkweirane-1/+1
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-05-17Auto merge of #12296 - jonas-schievink:add-attribute-assist, r=jonas-schievinkbors-178/+227
feat: add a "Add attribute" assist This generalizes the "Add `#[derive]`" assist and supports adding `#[must_use]` and `#[inline]`. Removes `#[must_use]` from the "Generate getter/setter" assist, addressing the last point in https://github.com/rust-lang/rust-analyzer/issues/12273. Closes https://github.com/rust-lang/rust-analyzer/issues/12273.
2022-05-17Add a "Add attribute" assistJonas Schievink-178/+227
2022-05-17automate braceless return substitution for long linesAndrei Listochkin-2/+5
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-17remove tsfmt from dependenciesAndrei Listochkin-157/+2
2022-05-17add prettier format commit to ignored revisionsAndrei Listochkin-0/+8
2022-05-17prettier runAndrei Listochkin-816/+1177
2022-05-17use prettier to format the codeAndrei Listochkin-2/+2
2022-05-17prettier configAndrei Listochkin-0/+72
[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-17Auto merge of #12292 - jonas-schievink:bump-extension-version, r=jonas-schievinkbors-4/+11
internal: Bump extension version
2022-05-17Bump extension versionJonas Schievink-4/+11
2022-05-17Auto merge of #12285 - Veykril:inlay-hints, r=Veykrilbors-60/+224
feat: Implement inlay hint tooltips Currently this just delegates to hover request for some things, and otherwise fallsback to the label. ![image](https://user-images.githubusercontent.com/3757771/168816520-e015726f-53e1-4dac-a76e-8f1312f145d7.png) ![image](https://user-images.githubusercontent.com/3757771/168802753-43749b75-866c-40db-b106-aeaa542b87a3.png) ![image](https://user-images.githubusercontent.com/3757771/168816579-da2050f0-f198-4b3a-a9a1-53199fcaab61.png) ![image](https://user-images.githubusercontent.com/3757771/168818804-d4400ffe-0e6c-48a0-a872-f054e5f550fa.png)
2022-05-17Update test outputLukas Wirth-0/+66
2022-05-17Auto merge of #12289 - rust-lang:Veykril-patch-1, r=Veykrilbors-1/+1
fix: Fix incorrect config key in client config update Closes https://github.com/rust-lang/rust-analyzer/issues/12288
2022-05-17Fix incorrect config key in client config updateLukas Wirth-1/+1
Closes https://github.com/rust-lang/rust-analyzer/issues/12288
2022-05-17Update lsp-extensions hashLukas Wirth-1/+1
2022-05-17Allow inlay hint tooltips to trigger hoversLukas Wirth-60/+80