diff options
author | Aleksey Kladov <[email protected]> | 2019-03-20 10:19:46 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-03-20 10:19:46 +0000 |
commit | dbed0f0e9960904193fd56327201b91bf585e016 (patch) | |
tree | 86af65e221e8671da3c88d3ccaa5c83ed8d05fd2 /docs | |
parent | 07a9e5c0e1c20f66730f608647e96ce29359b91d (diff) |
document some nice things
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/features.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/user/features.md b/docs/user/features.md index aa3bf5157..90f182f35 100644 --- a/docs/user/features.md +++ b/docs/user/features.md | |||
@@ -321,3 +321,39 @@ use algo:<|>:visitor::{Visitor, visit}; | |||
321 | //after: | 321 | //after: |
322 | use algo::{<|>visitor::{Visitor, visit}}; | 322 | use algo::{<|>visitor::{Visitor, visit}}; |
323 | ``` | 323 | ``` |
324 | |||
325 | ### Magic Completions | ||
326 | |||
327 | In addition to usual reference completion, rust-analyzer provides some ✨magic✨ | ||
328 | completions as well: | ||
329 | |||
330 | Keywords like `if`, `else` `while`, `loop` are completed with braces, and cursor | ||
331 | is placed at the appropriate position. Even though `if` is easy to type, you | ||
332 | still want to complete it, to get ` { }` for free! `return` is inserted with a | ||
333 | space or `;` depending on the return type of the function. | ||
334 | |||
335 | When completing a function call, `()` are automatically inserted. If function | ||
336 | takes arguments, cursor is positioned inside the parenthesis. | ||
337 | |||
338 | There are postifx completions, which can be triggerd by typing something like | ||
339 | `foo().if`. The word after `.` determines postifx completion, possible variants are: | ||
340 | |||
341 | - `expr.if` -> `if expr {}` | ||
342 | - `expr.match` -> `match expr {}` | ||
343 | - `expr.while` -> `while expr {}` | ||
344 | - `expr.ref` -> `&expr` | ||
345 | - `expr.refm` -> `&mut expr` | ||
346 | - `expr.not` -> `!expr` | ||
347 | - `expr.dbg` -> `dbg!(expr)` | ||
348 | |||
349 | There also snippet completions: | ||
350 | |||
351 | #### Inside Expressions | ||
352 | |||
353 | - `pd` -> `println!("{:?}")` | ||
354 | - `ppd` -> `println!("{:#?}")` | ||
355 | |||
356 | #### Inside Modules | ||
357 | |||
358 | - `tfn` -> `#[test] fn f(){}` | ||
359 | |||