Sourcegraph extensions have been deprecated with the September 2022 Sourcegraph release. Learn more.
The repo and the docs below are kept to support older Sourcegraph versions.
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 Intellij.
This extension requires all git repos to be cloned and available on your local machine.
Please add the following options in your Sourcegraph's User Settings to configure the extension:
-
openInIntellij.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. 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 theopenInIntellij.replacements
option.- Note:
"/Users/yourusername/src"
is a valid absolute path, while"~/src"
is not.
- Note:
-
openInIntellij.useBuiltin
: [OPTIONAL] Boolean. Set option totrue
in your user settings if you would like to open files using the Intellij's built-in REST API, or if you are using this extension on Windows. -
openInIntellij.replacements
: [OPTIONAL] 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. For example, using"openInIntellij.replacements": {"(?<=Documents\/)(.*[\\\/])": "sourcegraph-$1"}
will addsourcegraph-
in front of the string that matches the(?<=Documents\/)(.*[\\\/])
RegExp pattern, while"openInIntellij.replacements": {"sourcegraph-": ""}
will removesourcegraph-
from the final URL. -
openInIntellij.osPaths
: [OPTIONAL] Takes 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 byopenInIntellij.basePath
.- Note: Currently support
"windows"
,"mac"
, and"linux"
as keys.
- Note: Currently support
The idea://
protocol handler that this extension is using to open files directly from a URL is currently not supported on Windows. As a workaround, Windows user can use the Intellij's built-in REST API to open files directly from a URL with extra configuration steps.
-
In the Intellij's Settings panel, go to
Build, Execution, Deployment
-
Click on the
Debugger
tab and mark the box next toAllow unsigned requests
as checked. This allows requests to be made to the built-in server from outside IntelliJ IDEA as stated in their docs -
Intellij must be remained open for this workaround to work.
To open repository files in your Documents directory:
{
"extensions": {
"sourcegraph/open-in-intellij": true,
},
"openInIntellij.basePath": "/Users/USERNAME/Documents/"
}
To open repository files in your user's IdeaProjects directory:
{
"extensions": {
"sourcegraph/open-in-intellij": true,
},
"openInIntellij.basePath": "/C:/Users/USERNAME/IdeaProjects/",
"openInIntellij.useBuiltin": true,
}
Uses the assigned path for the detected Operating System when available:
{
"extensions": {
"sourcegraph/open-in-intellij": true,
},
"openInIntellij.osPaths": {
// useBuiltin will automatically be set to true for windows
"windows": "/C:/Users/USERNAME/folder/",
"mac": "/Users/USERNAME/folder/",
"linux": "/home/USERNAME/folder/"
},
// set basePath as fallback path when no operating system is detected
"openInIntellij.basePath": "/Users/USERNAME/Documents/"
}
- Run
yarn && yarn run serve
and keep the Parcel bundler process running - Sideload the extension (at the URL http://localhost:1234 by default) on your Sourcegraph instance or Sourcegraph.com
When you edit a source file in your editor, Parcel will recompile the extension. Reload the Sourcegraph web page to use the updated extension.