diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/lsp-extensions.md | 90 |
1 files changed, 88 insertions, 2 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 0e3a0af1c..158d3c599 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md | |||
@@ -5,7 +5,9 @@ It's a best effort document, when in doubt, consult the source (and send a PR wi | |||
5 | We aim to upstream all non Rust-specific extensions to the protocol, but this is not a top priority. | 5 | We aim to upstream all non Rust-specific extensions to the protocol, but this is not a top priority. |
6 | All capabilities are enabled via `experimental` field of `ClientCapabilities`. | 6 | All capabilities are enabled via `experimental` field of `ClientCapabilities`. |
7 | 7 | ||
8 | ## `SnippetTextEdit` | 8 | ## Snippet `TextEdit` |
9 | |||
10 | **Issue:** https://github.com/microsoft/language-server-protocol/issues/724 | ||
9 | 11 | ||
10 | **Client Capability:** `{ "snippetTextEdit": boolean }` | 12 | **Client Capability:** `{ "snippetTextEdit": boolean }` |
11 | 13 | ||
@@ -36,7 +38,9 @@ At the moment, rust-analyzer guarantees that only a single edit will have `Inser | |||
36 | * Where exactly are `SnippetTextEdit`s allowed (only in code actions at the moment)? | 38 | * Where exactly are `SnippetTextEdit`s allowed (only in code actions at the moment)? |
37 | * Can snippets span multiple files (so far, no)? | 39 | * Can snippets span multiple files (so far, no)? |
38 | 40 | ||
39 | ## `joinLines` | 41 | ## Join Lines |
42 | |||
43 | **Issue:** https://github.com/microsoft/language-server-protocol/issues/992 | ||
40 | 44 | ||
41 | **Server Capability:** `{ "joinLines": boolean }` | 45 | **Server Capability:** `{ "joinLines": boolean }` |
42 | 46 | ||
@@ -84,3 +88,85 @@ fn main() { | |||
84 | * What is the position of the cursor after `joinLines`? | 88 | * What is the position of the cursor after `joinLines`? |
85 | Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets. | 89 | Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets. |
86 | However, it then becomes unclear how it works with multi cursor. | 90 | However, it then becomes unclear how it works with multi cursor. |
91 | |||
92 | ## Structural Search Replace (SSR) | ||
93 | |||
94 | **Server Capability:** `{ "ssr": boolean }` | ||
95 | |||
96 | This request is send from client to server to handle structural search replace -- automated syntax tree based transformation of the source. | ||
97 | |||
98 | **Method:** `experimental/ssr` | ||
99 | |||
100 | **Request:** | ||
101 | |||
102 | ```typescript | ||
103 | interface SsrParams { | ||
104 | /// Search query. | ||
105 | /// The specific syntax is specified outside of the protocol. | ||
106 | query: string, | ||
107 | /// If true, only check the syntax of the query and don't compute the actual edit. | ||
108 | parseOnly: bool, | ||
109 | } | ||
110 | ``` | ||
111 | |||
112 | **Response:** | ||
113 | |||
114 | ```typescript | ||
115 | WorkspaceEdit | ||
116 | ``` | ||
117 | |||
118 | ### Example | ||
119 | |||
120 | SSR with query `foo($a:expr, $b:expr) ==>> ($a).foo($b)` will transform, eg `foo(y + 5, z)` into `(y + 5).foo(z)`. | ||
121 | |||
122 | ### Unresolved Question | ||
123 | |||
124 | * Probably needs search without replace mode | ||
125 | * Needs a way to limit the scope to certain files. | ||
126 | |||
127 | ## `CodeAction` Groups | ||
128 | |||
129 | **Issue:** https://github.com/microsoft/language-server-protocol/issues/994 | ||
130 | |||
131 | **Client Capability:** `{ "codeActionGroup": boolean }` | ||
132 | |||
133 | If this capability is set, `CodeAction` returned from the server contain an additional field, `group`: | ||
134 | |||
135 | ```typescript | ||
136 | interface CodeAction { | ||
137 | title: string; | ||
138 | group?: string; | ||
139 | ... | ||
140 | } | ||
141 | ``` | ||
142 | |||
143 | All code-actions with the same `group` should be grouped under single (extendable) entry in lightbulb menu. | ||
144 | The set of actions `[ { title: "foo" }, { group: "frobnicate", title: "bar" }, { group: "frobnicate", title: "baz" }]` should be rendered as | ||
145 | |||
146 | ``` | ||
147 | 💡 | ||
148 | +-------------+ | ||
149 | | foo | | ||
150 | +-------------+-----+ | ||
151 | | frobnicate >| bar | | ||
152 | +-------------+-----+ | ||
153 | | baz | | ||
154 | +-----+ | ||
155 | ``` | ||
156 | |||
157 | Alternatively, selecting `frobnicate` could present a user with an additional menu to choose between `bar` and `baz`. | ||
158 | |||
159 | ### Example | ||
160 | |||
161 | ```rust | ||
162 | fn main() { | ||
163 | let x: Entry/*cursor here*/ = todo!(); | ||
164 | } | ||
165 | ``` | ||
166 | |||
167 | Invoking code action at this position will yield two code actions for importing `Entry` from either `collections::HashMap` or `collection::BTreeMap`, grouped under a single "import" group. | ||
168 | |||
169 | ### Unresolved Questions | ||
170 | |||
171 | * Is a fixed two-level structure enough? | ||
172 | * Should we devise a general way to encode custom interaction protocols for GUI refactorings? | ||