[Feature Request] Gitea Open with IDE support
I would love to see
Gitea open with <IDE>:
https://blog.gitea.com/release-of-1.22.0/#rocket-customizable-open-with-ide-menu-29320
Requirements
- #16
Cool!
I have yet to try this new Gitea feature, but I imagine something like this could work:
- Create a small script (I created it in
~/.local/bin/git-devfor the sake of this example since it is already in myPATH).
#!/bin/bash
# Strip 'git-dev://open/?repo='
nvim -c "GitDevOpen ${1/git-dev:\/\/open\/?repo=/}"
- Make it executable:
chmod +x ~/.local/bin/git-dev
- Create
~/.local/share/applications/gitdev.desktop:
[Desktop Entry]
Name=GitDev
Comment=Opens a Git URI in Neovim.
Exec=git-dev %u
Terminal=true
Type=Application
MimeType=x-scheme-handler/git-dev
- Register the new scheme:
xdg-mime default gitdev.desktop x-scheme-handler/git-dev
-
xdg-opennow supportsgit-devURI in this format:git-dev://open/?repo=<URL>. Example:
xdg-open git-dev://open/?repo=https://github.com/moyiz/git-dev.nvim
- Add it to Gitea configuration:
Neovim = git-dev://open/?repo={url}
It should work assuming Gitea does no escape url.
I will think about generating such handler via plugin options.
Let me know how it goes :slightly_smiling_face:
Summary
It works, when un-escaping the URL.
For my config, i changed it to nvim-gitdev for all files
Repository to try it out with: https://git.euph.dev/Snoweuph/Dotfiles
Also, it doesn't work with git@ URLs:
also for the script to work on my System (Kinoite), I had to wrap the nvim run with toolbx:
nvim-gitdev.sh
#!/bin/bash
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
git_url=$(urldecode $1)
# Strip 'git-dev://open/?repo='
toolbox run -- nvim -c "GitDevOpen ${git_url/nvim-gitdev:\/\/open\/?repo=/}"
In the .desktop file, I had to use absolute an PATH, because it does not have access to my users $PATH
nvim-gitdev.desktop
[Desktop Entry]
Name=Neovim GitDev Handler
Comment=Opens a Git URI in Neovim.
Exec=/home/snoweuph/.local/bin/nvim-gitdev.sh %u
Terminal=true
Type=Application
MimeType=x-scheme-handler/nvim-gitdev
I suggest an option like this:
opts = {
xdg_handler = {
wrapper = "toolbox run -- "
}
}
xdg-handler should be nil by default, and this way, its easy to expand it with more options, if needed
I just forked the project, and I gonna work on adding the needed code, to handle registering x-schemes