|
1 | 1 | # Open in Sublime Sourcegraph extension
|
2 | 2 |
|
3 |
| -Adds a button at the top of files in both Sourcegraph app and code hosts like GitHub (when the Sourcegraph browser extension is installed) that will open the current file in Sublime Text. |
| 3 | +Adds a button to the Sourcegraph's extension panel and at the top of files in code hosts like GitHub (when the Sourcegraph browser extension is installed) that will open the current file in Sublime Text. |
| 4 | + |
| 5 | +**This extension requires all git repos to be cloned and available on your local machine.** |
4 | 6 |
|
5 | 7 | <picture>
|
6 |
| -<source srcset="https://user-images.githubusercontent.com/37420160/96816775-e9760400-13eb-11eb-812f-85046bd4db6d.png" media="(prefers-color-scheme: dark)" /> |
7 |
| -<source srcset="https://user-images.githubusercontent.com/37420160/96816847-0ad6f000-13ec-11eb-9ef8-b1c3b2009a4d.png" media="(prefers-color-scheme: light)" /> |
8 |
| -<img src="https://user-images.githubusercontent.com/37420160/96816847-0ad6f000-13ec-11eb-9ef8-b1c3b2009a4d.png" alt="Screenshot" /> |
| 8 | +<source srcset="https://user-images.githubusercontent.com/37420160/96816775-e9760400-13eb-11eb-812f-85046bd4db6d.png" width="100%" media="(prefers-color-scheme: dark)" /> |
| 9 | +<source srcset="https://user-images.githubusercontent.com/37420160/96816847-0ad6f000-13ec-11eb-9ef8-b1c3b2009a4d.png" width="100%" media="(prefers-color-scheme: light)" /> |
| 10 | +<img src="https://user-images.githubusercontent.com/37420160/96816847-0ad6f000-13ec-11eb-9ef8-b1c3b2009a4d.png" width="100%" alt="Screenshot" /> |
9 | 11 | </picture>
|
10 | 12 |
|
11 |
| -## Settings |
12 | 13 |
|
13 |
| -- `openInSublime.basePath`: The absolute path on your computer where your git repositories live. This extension requires all git repos to be already cloned under this path with their original names. `"/Users/yourusername/src"` is a valid absolute path, while `"~/src"` is not. |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- This extension requires all git repos to be cloned and available on your local machine. |
| 17 | + |
| 18 | +- Sublime Text requires a URL handler installed such as [this one for macOS](https://github.com/inopinatus/sublime_url). |
| 19 | + |
| 20 | +## Configurations |
| 21 | + |
| 22 | +- `openInSublime.basePath`: [REQUIRED] String. The absolute path on your computer where your git repositories live. The extension will try to open the file in a clone named by the last segment of the repository name in that folder. |
| 23 | + - This extension requires all git repos to be already cloned under this path with their original names, which the final path can later be altered using the `openInSublime.replacements` option. |
| 24 | + - `"/Users/yourusername/src"` is a valid absolute path, while `"~/src"` is not. |
| 25 | + |
| 26 | +- `openInSublime.replacements`: [OPTIONAL] Object. Set to an object that includes pairs of strings, where each key will be replaced by its value in the final url. The key can be a string or a RegExp, and the value must be a string. |
| 27 | + - Example: using `"openInSublime.replacements": {"(?<=Documents\/)(.*[\\\/])": "sourcegraph-$1"}` will add `sourcegraph-` in front of the string that matches the `(?<=Documents\/)(.*[\\\/])` RegExp pattern, while `"openInSublime.replacements": {"sourcegraph-": ""}` will remove `sourcegraph-` from the final URL. |
| 28 | + |
| 29 | +- `openInSublime.osPaths`: [OPTIONAL] Object. The extension uses the assigned path for the detected Operating System when available. If no platform is detected then we will keep using the basePath provided with `openInSublime.basePath`. |
| 30 | + - Note: Currently support `"windows"`, `"mac"`, and `"linux"` as keys. |
| 31 | + |
| 32 | +## Examples |
| 33 | + |
| 34 | +### Mac |
| 35 | + |
| 36 | +**Requires a URL handler installed such as [this one for macOS](https://github.com/inopinatus/sublime_url).** |
| 37 | + |
| 38 | +Opens repository files in your Documents directory: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "extensions": { |
| 43 | + "sourcegraph/open-in-sublime": true, |
| 44 | + }, |
| 45 | + // where the cloned git repositories are located |
| 46 | + "openInSublime.basePath": "/Users/USERNAME/Documents/" |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### Set basePath for multiple platforms |
| 51 | + |
| 52 | +**Requires a URL handler installed such as [this one for macOS](https://github.com/inopinatus/sublime_url).** |
| 53 | + |
| 54 | +Uses the assigned path for the detected Operating System when available: |
| 55 | + |
| 56 | +```json |
| 57 | +{ |
| 58 | + "extensions": { |
| 59 | + "sourcegraph/open-in-sublime": true, |
| 60 | + }, |
| 61 | + "openInSublime.osPaths": { |
| 62 | + "windows": "/C:/Users/USERNAME/folder/", |
| 63 | + "mac": "/Users/USERNAME/folder/", |
| 64 | + "linux": "/home/USERNAME/folder/" |
| 65 | + }, |
| 66 | + // set basePath as fallback path when no operating system is detected |
| 67 | + "openInSublime.basePath": "/Users/USERNAME/Documents/" |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Development |
| 72 | + |
| 73 | +1. Run `yarn && yarn run serve` and keep the Parcel bundler process running |
| 74 | +1. [Sideload the extension](https://docs.sourcegraph.com/extensions/authoring/local_development) (at the URL http://localhost:1234 by default) on your Sourcegraph instance or Sourcegraph.com |
14 | 75 |
|
15 |
| -Sublime Text requires a URL handler installed such as [this one for macOS](https://github.com/inopinatus/sublime_url). |
| 76 | +When you edit a source file in your editor, Parcel will recompile the extension. Reload the Sourcegraph web page to use the updated extension. |
0 commit comments