aboutsummaryrefslogtreecommitdiff
path: root/docs/dev
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/lsp-extensions.md36
-rw-r--r--docs/dev/style.md38
2 files changed, 69 insertions, 5 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index 8fcd72d5d..3c4eacfeb 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -1,5 +1,5 @@
1<!--- 1<!---
2lsp_ext.rs hash: 6e57fc1b345b00e9 2lsp_ext.rs hash: 10a8988e6893e6b2
3 3
4If you need to change the above hash to make the test pass, please check if you 4If you need to change the above hash to make the test pass, please check if you
5need to adjust this doc as well and ping this issue: 5need to adjust this doc as well and ping this issue:
@@ -650,3 +650,37 @@ export const enum Direction {
650 Down = "Down" 650 Down = "Down"
651} 651}
652``` 652```
653
654## Workspace Symbols Filtering
655
656**Issue:** https://github.com/rust-analyzer/rust-analyzer/pull/7698
657
658**Experimental Server Capability:** `{ "workspaceSymbolScopeKindFiltering": boolean }`
659
660Extends the existing `workspace/symbol` request with ability to filter symbols by broad scope and kind of symbol.
661If this capability is set, `workspace/symbol` parameter gains two new optional fields:
662
663
664```typescript
665interface WorkspaceSymbolParams {
666 /**
667 * Return only the symbols defined in the specified scope.
668 */
669 searchScope?: WorkspaceSymbolSearchScope;
670 /**
671 * Return only the symbols of specified kinds.
672 */
673 searchKind?: WorkspaceSymbolSearchKind;
674 ...
675}
676
677const enum WorkspaceSymbolSearchScope {
678 Workspace = "workspace",
679 WorkspaceAndDependencies = "workspaceAndDependencies"
680}
681
682const enum WorkspaceSymbolSearchKind {
683 OnlyTypes = "onlyTypes",
684 AllSymbols = "allSymbols"
685}
686```
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::`.
638use super::{} 638use super::{}
639
640// Re-exports are treated as item definitions rather than imports, so they go
641// after imports and modules. Use them sparingly.
642pub use crate::x::Z;
639``` 643```
640 644
641**Rationale:** consistency. 645**Rationale:** consistency.
@@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports.
694Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. 698Prefer `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
701By 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
699Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. 706Optimize 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.
784We use mangled names instead of `r#ident` syntax: 791We use mangled names instead of `r#ident` syntax:
785 792
786``` 793```
787struct -> strukt
788crate -> krate 794crate -> krate
789impl -> imp
790trait -> trait_
791fn -> func
792enum -> enum_ 795enum -> enum_
796fn -> func
797impl -> imp
793mod -> module 798mod -> module
799struct -> strukt
800trait -> trait_
801type -> 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
955Style inline code comments as proper sentences.
956Start with a capital letter, end with a dot.
957
958```rust
959// GOOD
960
961// Only simple single segment paths are allowed.
962MergeBehavior::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
969MergeBehavior::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.
975It tricks you into writing down more of the context you keep in your head while coding.
976
947For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. 977For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.
948If the line is too long, you want to split the sentence in two :-) 978If the line is too long, you want to split the sentence in two :-)
949 979