Add Forgejo custom Gitlens Remote in VS Code
Gitlens in VS Code can be linked to a Forgejo instance. I find this very useful, as it enables:
- Open a selected line (or lines) of code in VS Code and open it in Forgejo (right-click on the selected code and select βOpen on Remote (Web)β)
- Open current branch on Forgejo
- Open commit on Forgejo
- Open repository on Forgejo
All these commands are available in the Command Palette (cmd+shift+p) in VS Code.
Add this config to settings.json in VS Code (cmd+shift+p -> Preferences: Open User Settings (JSON)) (replace all <PLACEHOLDERS>
with your Forgejo host details):
"gitlens.remotes": [
{
"regex": "ssh://(forgejo@<HOSTNAME>)/<PATH>/(.+)",
"type": "Custom",
"name": "Grooovingers Forgejo",
"urls": {
"repository": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}",
"branches": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}/branches",
"branch": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}/src/branch/${branch}",
"commit": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}/commit/${id}",
"file": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}/src/branch/main/${file}${line}",
"fileInBranch": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}/src/branch/${branch}/${file}${line}",
"fileInCommit": "https://<URL-TO-FORGEJO>/<ORGANISATION>/${repo}/src/commit/${id}/${file}${line}",
"fileLine": "#L${line}",
"fileRange": "#L${start}-L${end}"
}
}
]
More information about the possible configuration fields on Gitkraken GitLens Settings page.