diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/style.md | 38 | ||||
-rw-r--r-- | docs/user/generated_config.adoc | 9 | ||||
-rw-r--r-- | docs/user/manual.adoc | 1 |
3 files changed, 44 insertions, 4 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index d24a5952e..96dd684b3 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -636,6 +636,10 @@ use crate::{} | |||
636 | 636 | ||
637 | // Finally, parent and child modules, but prefer `use crate::`. | 637 | // Finally, parent and child modules, but prefer `use crate::`. |
638 | use super::{} | 638 | use super::{} |
639 | |||
640 | // Re-exports are treated as item definitions rather than imports, so they go | ||
641 | // after imports and modules. Use them sparingly. | ||
642 | pub use crate::x::Z; | ||
639 | ``` | 643 | ``` |
640 | 644 | ||
641 | **Rationale:** consistency. | 645 | **Rationale:** consistency. |
@@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports. | |||
694 | Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. | 698 | Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. |
695 | **Rationale:** consistency, this is the style which works in all cases. | 699 | **Rationale:** consistency, this is the style which works in all cases. |
696 | 700 | ||
701 | By default, avoid re-exports. | ||
702 | **Rationale:** for non-library code, re-exports introduce two ways to use something and allow for inconsistency. | ||
703 | |||
697 | ## Order of Items | 704 | ## Order of Items |
698 | 705 | ||
699 | Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. | 706 | Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. |
@@ -784,13 +791,14 @@ Many names in rust-analyzer conflict with keywords. | |||
784 | We use mangled names instead of `r#ident` syntax: | 791 | We use mangled names instead of `r#ident` syntax: |
785 | 792 | ||
786 | ``` | 793 | ``` |
787 | struct -> strukt | ||
788 | crate -> krate | 794 | crate -> krate |
789 | impl -> imp | ||
790 | trait -> trait_ | ||
791 | fn -> func | ||
792 | enum -> enum_ | 795 | enum -> enum_ |
796 | fn -> func | ||
797 | impl -> imp | ||
793 | mod -> module | 798 | mod -> module |
799 | struct -> strukt | ||
800 | trait -> trait_ | ||
801 | type -> ty | ||
794 | ``` | 802 | ``` |
795 | 803 | ||
796 | **Rationale:** consistency. | 804 | **Rationale:** consistency. |
@@ -944,6 +952,28 @@ match p.current() { | |||
944 | 952 | ||
945 | ## Documentation | 953 | ## Documentation |
946 | 954 | ||
955 | Style inline code comments as proper sentences. | ||
956 | Start with a capital letter, end with a dot. | ||
957 | |||
958 | ```rust | ||
959 | // GOOD | ||
960 | |||
961 | // Only simple single segment paths are allowed. | ||
962 | MergeBehavior::Last => { | ||
963 | tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) | ||
964 | } | ||
965 | |||
966 | // BAD | ||
967 | |||
968 | // only simple single segment paths are allowed | ||
969 | MergeBehavior::Last => { | ||
970 | tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) | ||
971 | } | ||
972 | ``` | ||
973 | |||
974 | **Rationale:** writing a sentence (or maybe even a paragraph) rather just "a comment" creates a more appropriate frame of mind. | ||
975 | It tricks you into writing down more of the context you keep in your head while coding. | ||
976 | |||
947 | For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. | 977 | For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. |
948 | If the line is too long, you want to split the sentence in two :-) | 978 | If the line is too long, you want to split the sentence in two :-) |
949 | 979 | ||
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index f70558200..feba43ff1 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc | |||
@@ -179,6 +179,15 @@ Controls file watching implementation. | |||
179 | -- | 179 | -- |
180 | These directories will be ignored by rust-analyzer. | 180 | These directories will be ignored by rust-analyzer. |
181 | -- | 181 | -- |
182 | [[rust-analyzer.highlighting.strings]]rust-analyzer.highlighting.strings (default: `true`):: | ||
183 | + | ||
184 | -- | ||
185 | Use semantic tokens for strings. | ||
186 | |||
187 | In some editors (e.g. vscode) semantic tokens override other highlighting grammars. | ||
188 | By disabling semantic tokens for strings, other grammars can be used to highlight | ||
189 | their contents. | ||
190 | -- | ||
182 | [[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`):: | 191 | [[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`):: |
183 | + | 192 | + |
184 | -- | 193 | -- |
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index 797af3f75..f96c09a79 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc | |||
@@ -589,6 +589,7 @@ Here is a **non-exhaustive** list of ways to make rust-analyzer execute arbitrar | |||
589 | 589 | ||
590 | * proc macros and build scripts are executed by default | 590 | * proc macros and build scripts are executed by default |
591 | * `.cargo/config` can override `rustc` with an arbitrary executable | 591 | * `.cargo/config` can override `rustc` with an arbitrary executable |
592 | * `rust-toolchain.toml` can override `rustc` with an arbitrary executable | ||
592 | * VS Code plugin reads configuration from project directory, and that can be used to override paths to various executables, like `rustfmt` or `rust-analyzer` itself. | 593 | * VS Code plugin reads configuration from project directory, and that can be used to override paths to various executables, like `rustfmt` or `rust-analyzer` itself. |
593 | * rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety. | 594 | * rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety. |
594 | 595 | ||