aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-03-20 10:19:46 +0000
committerAleksey Kladov <[email protected]>2019-03-20 10:19:46 +0000
commitdbed0f0e9960904193fd56327201b91bf585e016 (patch)
tree86af65e221e8671da3c88d3ccaa5c83ed8d05fd2 /docs
parent07a9e5c0e1c20f66730f608647e96ce29359b91d (diff)
document some nice things
Diffstat (limited to 'docs')
-rw-r--r--docs/user/features.md36
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:
322use algo::{<|>visitor::{Visitor, visit}}; 322use algo::{<|>visitor::{Visitor, visit}};
323``` 323```
324
325### Magic Completions
326
327In addition to usual reference completion, rust-analyzer provides some ✨magic✨
328completions as well:
329
330Keywords like `if`, `else` `while`, `loop` are completed with braces, and cursor
331is placed at the appropriate position. Even though `if` is easy to type, you
332still want to complete it, to get ` { }` for free! `return` is inserted with a
333space or `;` depending on the return type of the function.
334
335When completing a function call, `()` are automatically inserted. If function
336takes arguments, cursor is positioned inside the parenthesis.
337
338There 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
349There 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