monacopilot 0.10.6 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
- [Register Completion Options](#register-completion-options)
|
|
20
20
|
- [Get Completions in Real-Time](#get-completions-in-real-time)
|
|
21
21
|
- [Manually Trigger Completions](#manually-trigger-completions)
|
|
22
|
+
- [Trigger Completions with a Keyboard Shortcut](#trigger-completions-with-a-keyboard-shortcut)
|
|
23
|
+
- [Trigger Completions with an Editor Action](#trigger-completions-with-an-editor-action)
|
|
22
24
|
- [External Context](#external-context)
|
|
23
25
|
- [Filename](#filename)
|
|
24
26
|
- [Completions for Specific Technologies](#completions-for-specific-technologies)
|
|
@@ -121,7 +123,6 @@ The `trigger` option determines when the completion service provides code comple
|
|
|
121
123
|
|
|
122
124
|
```javascript
|
|
123
125
|
registerCompletion(monaco, editor, {
|
|
124
|
-
// ...other options
|
|
125
126
|
trigger: 'onTyping',
|
|
126
127
|
});
|
|
127
128
|
```
|
|
@@ -151,11 +152,12 @@ completion.trigger();
|
|
|
151
152
|
|
|
152
153
|
To set up manual triggering, configure the `trigger` option to `'onDemand'`. This disables automatic completions, allowing you to call the `completion.trigger()` method explicitly when needed.
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
#### Trigger Completions with a Keyboard Shortcut
|
|
156
|
+
|
|
157
|
+
You can set up completions to trigger when the `Ctrl+Shift+Space` keyboard shortcut is pressed.
|
|
155
158
|
|
|
156
159
|
```javascript
|
|
157
160
|
const completion = registerCompletion(monaco, editor, {
|
|
158
|
-
// ...other options
|
|
159
161
|
trigger: 'onDemand',
|
|
160
162
|
});
|
|
161
163
|
|
|
@@ -167,13 +169,36 @@ monaco.editor.addCommand(
|
|
|
167
169
|
);
|
|
168
170
|
```
|
|
169
171
|
|
|
172
|
+
#### Trigger Completions with an Editor Action
|
|
173
|
+
|
|
174
|
+
You can add a custom editor action to trigger completions manually.
|
|
175
|
+
|
|
176
|
+

|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
const completion = registerCompletion(monaco, editor, {
|
|
180
|
+
trigger: 'onDemand',
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
monaco.editor.addEditorAction({
|
|
184
|
+
id: 'monacopilot.triggerCompletion',
|
|
185
|
+
label: 'Complete Code',
|
|
186
|
+
contextMenuGroupId: 'navigation',
|
|
187
|
+
keybindings: [
|
|
188
|
+
monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.Space,
|
|
189
|
+
],
|
|
190
|
+
run: () => {
|
|
191
|
+
completion.trigger();
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
170
196
|
### External Context
|
|
171
197
|
|
|
172
198
|
Enhance the accuracy and relevance of Copilot's completions by providing additional code context from your workspace.
|
|
173
199
|
|
|
174
200
|
```javascript
|
|
175
201
|
registerCompletion(monaco, editor, {
|
|
176
|
-
// ...other options
|
|
177
202
|
externalContext: [
|
|
178
203
|
{
|
|
179
204
|
path: './utils.js',
|
|
@@ -192,7 +217,6 @@ Specify the name of the file being edited to receive more contextually relevant
|
|
|
192
217
|
|
|
193
218
|
```javascript
|
|
194
219
|
registerCompletion(monaco, editor, {
|
|
195
|
-
// ...other options
|
|
196
220
|
filename: 'utils.js', // e.g., "index.js", "utils/objects.js"
|
|
197
221
|
});
|
|
198
222
|
```
|
|
@@ -205,7 +229,6 @@ Enable completions tailored to specific technologies by using the `technologies`
|
|
|
205
229
|
|
|
206
230
|
```javascript
|
|
207
231
|
registerCompletion(monaco, editor, {
|
|
208
|
-
// ...other options
|
|
209
232
|
technologies: ['react', 'next.js', 'tailwindcss'],
|
|
210
233
|
});
|
|
211
234
|
```
|
|
@@ -220,7 +243,6 @@ For example, if there's a chance that the code in your editor may exceed `500+ l
|
|
|
220
243
|
|
|
221
244
|
```javascript
|
|
222
245
|
registerCompletion(monaco, editor, {
|
|
223
|
-
// ...other options
|
|
224
246
|
maxContextLines: 80,
|
|
225
247
|
});
|
|
226
248
|
```
|
|
@@ -312,7 +334,6 @@ You can add custom headers to the provider's completion requests. For example, i
|
|
|
312
334
|
```javascript
|
|
313
335
|
copilot.complete({
|
|
314
336
|
options: {
|
|
315
|
-
// ...other options
|
|
316
337
|
headers: {
|
|
317
338
|
'X-Custom-Header': 'custom-value',
|
|
318
339
|
},
|