Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Gitea Open with IDE support #11

Open
snoweuph opened this issue Jun 1, 2024 · 3 comments
Open

[Feature Request] Gitea Open with IDE support #11

snoweuph opened this issue Jun 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@snoweuph
Copy link

snoweuph commented Jun 1, 2024

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

@moyiz
Copy link
Owner

moyiz commented Jun 2, 2024

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-dev for the sake of this example since it is already in my PATH).
#!/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-open now supports git-dev URI 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 🙂

@moyiz moyiz added the enhancement New feature or request label Jun 2, 2024
@snoweuph
Copy link
Author

snoweuph commented Jun 3, 2024

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
image

Also, it doesn't work with git@ URLs:
image

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

@snoweuph
Copy link
Author

I just forked the project, and I gonna work on adding the needed code, to handle registering x-schemes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants