You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-51Lines changed: 67 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3

4
4
5
-
Copilot for Xcode is an Xcode Source Editor Extension that provides GitHub Copilot, Codeium and ChatGPT support for Xcode.
5
+
Copilot for Xcode is an Xcode Source Editor Extension that provides GitHub Copilot, Codeium and ChatGPT support for Xcode.
6
6
7
7
<ahref="https://www.buymeacoffee.com/intitni"target="_blank"><imgsrc="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png"alt="Buy Me A Coffee"style="height: 60px!important;width: 217px!important;" ></a>
8
8
@@ -20,10 +20,10 @@ Copilot for Xcode is an Xcode Source Editor Extension that provides GitHub Copil
20
20
-[Installation and Setup](#installation-and-setup)
21
21
-[Install](#install)
22
22
-[Enable the Extension](#enable-the-extension)
23
+
-[Granting Permissions to the App](#granting-permissions-to-the-app)
23
24
-[Setting Up GitHub Copilot](#setting-up-github-copilot)
24
25
-[Setting Up Codeium](#setting-up-codeium)
25
26
-[Setting Up OpenAI API Key](#setting-up-openai-api-key)
26
-
-[Granting Permissions to the App](#granting-permissions-to-the-app)
@@ -41,14 +41,16 @@ For development instruction, check [Development.md](DEVELOPMENT.md).
41
41
- Public network connection.
42
42
43
43
For suggestion features:
44
-
- For GitHub Copilot users:
44
+
45
+
- For GitHub Copilot users:
45
46
-[Node](https://nodejs.org/) installed to run the Copilot LSP.
46
47
- Active GitHub Copilot subscription.
47
48
- For Codeium users:
48
49
- Active Codeium account.
49
50
50
51
For chat and prompt to code features:
51
-
- Valid OpenAI API key.
52
+
53
+
- Valid OpenAI API key.
52
54
53
55
## Permissions Required
54
56
@@ -73,17 +75,29 @@ Open the app, the app will create a launch agent to setup a background running S
73
75
74
76
### Enable the Extension
75
77
76
-
Enable the extension in `System Settings.app`.
78
+
Enable the extension in `System Settings.app`.
77
79
78
80
From the Apple menu located in the top-left corner of your screen click `System Settings`. Navigate to `Privacy & Security` then toward the bottom click `Extensions`. Click `Xcode Source Editor` and tick `Copilot`.
79
-
81
+
80
82
If you are using macOS Monterey, enter the `Extensions` menu in `System Preferences.app` with its dedicated icon.
81
83
84
+
### Granting Permissions to the App
85
+
86
+
The first time the app is open and command run, the extension will ask for the necessary permissions.
87
+
88
+
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`.
89
+
90
+
- To grant permissions for the Accessibility API, click `Accessibility`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
95
+
82
96
### Setting Up GitHub Copilot
83
-
97
+
84
98
1. In the host app, switch to the service tab and click on GitHub Copilot to access your GitHub Copilot account settings.
85
99
2. Click "Install" to install the language server.
86
-
3. Optionally setup the path to Node. The default value is just `node`, Copilot for Xcode.app will try to find the Node from the PATH available in a login shell. If your Node is installed somewhere else, you can run `which node` from terminal to get the path.
100
+
3. Optionally setup the path to Node. The default value is just `node`, Copilot for Xcode.app will try to find the Node from the PATH available in a login shell. If your Node is installed somewhere else, you can run `which node` from terminal to get the path.
87
101
4. Click "Sign In", and you will be directed to a verification website provided by GitHub, and a user code will be pasted into your clipboard.
88
102
5. After signing in, go back to the app and click "Confirm Sign-in" to finish.
89
103
6. Go to "Feature - Suggestion" and update the feature provider to "GitHub Copilot".
@@ -106,33 +120,21 @@ The installed language server is located at `~/Library/Application Support/com.i
106
120
1. In the host app, click OpenAI to enter the OpenAI account settings.
107
121
2. Enter your api key to the text field.
108
122
109
-
### Granting Permissions to the App
110
-
111
-
The first time the app is open and command run, the extension will ask for the necessary permissions.
112
-
113
-
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`.
114
-
115
-
- To grant permissions for the Accessibility API, click `Accessibility`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
This app runs whenever you open `Copilot for Xcode.app` or `Xcode.app`. You can quit it with its menu bar item that looks like a steering wheel.
124
126
125
127
You can also set it to quit automatically when the above 2 apps are closed.
126
128
127
-
## Update
129
+
## Update
128
130
129
131
If the app was installed via Homebrew, you can update it by running:
130
132
131
133
```bash
132
134
brew upgrade --cask copilot-for-xcode
133
135
```
134
136
135
-
Alternatively, You can use the in-app updater or download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
137
+
Alternatively, You can use the in-app updater or download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
136
138
137
139
After updating, please restart Xcode to allow the extension to reload.
138
140
@@ -144,13 +146,13 @@ If you find that some of the features are no longer working, please first try re
144
146
145
147
### Suggestion
146
148
147
-
The app can provide real-time code suggestions based on the files you have opened. It's powered by GitHub Copilot and Codeium.
149
+
The app can provide real-time code suggestions based on the files you have opened. It's powered by GitHub Copilot and Codeium.
148
150
149
-
If you're working on a company project and don't want the suggestion feature to be triggered, you can globally disable it and choose to enable it only for specific projects.
151
+
If you're working on a company project and don't want the suggestion feature to be triggered, you can globally disable it and choose to enable it only for specific projects.
150
152
151
153
Whenever your code is updated, the app will automatically fetch suggestions for you, you can cancel this by pressing **Escape**.
152
154
153
-
*: If a file is already open before the helper app launches, you will need to switch to those files in order to send the open file notification.
155
+
\*: If a file is already open before the helper app launches, you will need to switch to those files in order to send the open file notification.
154
156
155
157
#### Commands
156
158
@@ -167,6 +169,7 @@ Whenever your code is updated, the app will automatically fetch suggestions for
167
169
This feature is powered by ChatGPT. Please ensure that you have set up your OpenAI account before using it.
168
170
169
171
The chat knows the following information:
172
+
170
173
- The selected code in the active editor.
171
174
- The relative path of the file.
172
175
- The error and warning labels in the active editor.
@@ -182,45 +185,48 @@ You can detach the chat panel by simply dragging it away. Once detached, the cha
182
185
183
186
#### Keyboard Shortcuts
184
187
185
-
| Shortcut | Description |
186
-
|:---:|---|
187
-
|`⌘W`| Close the chat. |
188
-
|`⌘M`| Minimize the chat, you can bring it back with any chat commands or by clicking the circular widget. |
|`⌘M`| Minimize the chat, you can bring it back with any chat commands or by clicking the circular widget. |
192
+
|`⇧↩︎`| Add new line.|
190
193
191
194
#### Chat Scope
192
195
193
196
The chat panel allows for chat scope to temporarily control the context of the conversation for the latest message. To use a scope, simply prefix the message with `@scope`.
|`@selection`| Inject the selected code from the active editor into the conversation. This scope will be applied to any message automatically. If you don't want this to be the default behavior, you can turn off the option `Use selection scope by default in chat context.`. |
198
-
|`@file`| Inject the content of the file into the conversation. Keep in mind that you may not have enough tokens to inject large files. |
201
+
|`@file`| Inject the content of the file into the conversation. Keep in mind that you may not have enough tokens to inject large files.|
199
202
200
203
#### Chat Plugins
201
204
202
-
The chat panel supports chat plugins that may not require an OpenAI API key. For example, if you need to use the `/run` plugin, you just type
205
+
The chat panel supports chat plugins that may not require an OpenAI API key. For example, if you need to use the `/run` plugin, you just type
206
+
203
207
```
204
208
/run echo hello
205
209
```
206
210
207
-
If you need to end a plugin, you can just type
211
+
If you need to end a plugin, you can just type
212
+
208
213
```
209
214
/exit
210
215
```
211
216
212
-
| Command | Description |
213
-
|:---:|---|
214
-
|`/run`| Runs the command under the project root. You can also use environment variable `PROJECT_ROOT` to get the project root and `FILE_PATH` to get the editing file path.|
215
-
|`/airun`| Creates a command with natural language. You can ask to modify the command if it is not what you want. After confirming, the command will be executed by calling the `/run` plugin. |
216
-
|`/math`| Solves a math problem in natural language |
217
-
|`/search`| Search on Bing and summarize the results. You have to setup the Bing Search API in the host app before using it. |
|`/run`| Runs the command under the project root. You can also use environment variable `PROJECT_ROOT` to get the project root and `FILE_PATH` to get the editing file path.|
220
+
|`/airun`| Creates a command with natural language. You can ask to modify the command if it is not what you want. After confirming, the command will be executed by calling the `/run` plugin. |
221
+
|`/math`| Solves a math problem in natural language|
222
+
|`/search`| Search on Bing and summarize the results. You have to setup the Bing Search API in the host app before using it. |
218
223
219
224
### Prompt to Code
220
225
221
226
Refactor existing code or write new code using natural language.
222
227
223
228
This feature is recommended when you need to update a specific piece of code. Some example use cases include:
229
+
224
230
- Improving the code's readability.
225
231
- Correcting bugs in the code.
226
232
- Adding documentation to the code.
@@ -241,21 +247,30 @@ You can create custom commands that run Chat and Prompt to Code with personalize
241
247
- Open Chat: Open the chat window and immediately send a message, if provided. You can provide more information through the extra system prompt field.
242
248
- Custom Chat: Open the chat window and immediately send a message, if provided. You can overwrite the entire system prompt through the system prompt field.
243
249
250
+
For Open Chat and Custom Chat commands, you can use the following template arguments:
|`{{selected_code}}`| The currently selected code in the editor. |
255
+
|`{{active_editor_language}}`| The programming language of the active editor. |
256
+
|`{{active_editor_file_url}}`| The URL of the active file in the editor. |
257
+
|`{{active_editor_file_name}}`| The name of the active file in the editor. |
258
+
244
259
## Key Bindings
245
260
246
261
It looks like there is no way to add default key bindings to commands, but you can set them up in `Xcode settings > Key Bindings`. You can filter the list by typing `copilot` in the search bar.
247
262
248
263
A [recommended setup](https://github.com/intitni/CopilotForXcode/issues/14) that should cause no conflict is
249
264
250
-
| Command | Key Binding |
251
-
| --- | --- |
252
-
| Get Suggestions |`⌥?`|
253
-
| Accept Suggestions |`⌥}`|
254
-
| Reject Suggestion |`⌥{`|
255
-
| Next Suggestion |`⌥>`|
256
-
| Previous Suggestion |`⌥<`|
257
-
| Open Chat |`⌥"`|
258
-
| Explain Selection |`⌥\|`|
265
+
| Command | Key Binding |
266
+
| -------------------|----------- |
267
+
| Get Suggestions |`⌥?`|
268
+
| Accept Suggestions |`⌥}`|
269
+
| Reject Suggestion |`⌥{`|
270
+
| Next Suggestion |`⌥>`|
271
+
| Previous Suggestion |`⌥<`|
272
+
| Open Chat |`⌥"`|
273
+
| Explain Selection |`⌥\|`|
259
274
260
275
Essentially using `⌥⇧` as the "access" key combination for all bindings.
261
276
@@ -281,6 +296,7 @@ fi
281
296
- The extension uses some dirty tricks to get the file and project/workspace paths. It may fail, it may be incorrect, especially when you have multiple Xcode windows running, and maybe even worse when they are in different displays. I am not sure about that though.
282
297
- The suggestions are presented as C-style comments in comment mode, they may break your code if you are editing a JSON file or something.
0 commit comments