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

Open URL under cursor #1472

Closed
matoous opened this issue Jan 10, 2022 · 7 comments · Fixed by #5820
Closed

Open URL under cursor #1472

matoous opened this issue Jan 10, 2022 · 7 comments · Fixed by #5820
Labels
A-gui Area: Helix gui improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@matoous
Copy link
Contributor

matoous commented Jan 10, 2022

Describe your feature request

Add functionality similar to vim's gx that opens URL under cursor. I am still unsure whether this should be included with Helix or better left for a plugin (cc @archseer)?

This can be further extended to open files, commits, etc.

@matoous matoous added the C-enhancement Category: Improvements label Jan 10, 2022
@archseer
Copy link
Member

I think we should support the hyperlink spec which makes terminal links clickable: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

crossterm doesn't seem to support this, but termwiz does (I've been hoping to switch over since it also supports bracketed paste and better render diffing): https://docs.rs/termwiz/latest/termwiz/hyperlink/index.html

Command-wise, we already support opening the file under cursor via gf: #1102

So something like gx could be doable if we amend the detection a bit. We'd shell out to $BROWSER

@kirawi kirawi added A-helix-term Area: Helix term improvements A-gui Area: Helix gui improvements labels Jan 10, 2022
@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Oct 6, 2022
@diktomat
Copy link
Contributor

diktomat commented Jan 4, 2023

So something like gx could be doable if we amend the detection a bit. We'd shell out to $BROWSER

Imho better than using $BROWSER for gx, which often isn't set, would be using the open (macOS) or xdg-open (Linux) commands. These are 1. using the user's default browser set in his/her desktop environment, and 2. apply to more than just websites, one could also open files, or different URL protocols (ftp:, mailto: etc). Only thing left to Helix internal would be finding begin and end of the path or URL string.

@ubitux
Copy link

ubitux commented Jan 4, 2023

So something like gx could be doable if we amend the detection a bit. We'd shell out to $BROWSER

Imho better than using $BROWSER for gx, which often isn't set, would be using the open (macOS) or xdg-open (Linux) commands. These are 1. using the user's default browser set in his/her desktop environment, and 2. apply to more than just websites, one could also open files, or different URL protocols (ftp:, mailto: etc). Only thing left to Helix internal would be finding begin and end of the path or URL string.

Note that the protocol might not be specified and would imply file:// (think ![img](path/to/image) in markdown)

@edrex
Copy link

edrex commented Feb 3, 2023

As it stands this issue is about two subtly-different things, both of which seem worth doing:

  1. implement an internal open-url-under-cursor mechanism.
  2. implement the hyperlink spec for detected URLs to support clickable terminal links

Since 2 depends on moving to / deciding about termwiz, and given 1 would make 2 much easier, maybe we should do an internal implementation first?

These are especially important now that virtual text/soft wrapping has landed, which will break terminal-based regex URL detection when enabled.

@edrex
Copy link

edrex commented Feb 3, 2023

Both implementations could benefit from LSP features such as Document Link.

matoous added a commit to matoous/helix that referenced this issue Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Mar 10, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Mar 31, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Mar 31, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue May 24, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
@thisizkp
Copy link

thisizkp commented Aug 9, 2023

There seems to be couple of PRs in flight for this with almost most of the required work already done. Is there anything pending that is required or waiting for (If so, would love to help/contribute) the PR to be merged?

matoous added a commit to matoous/helix that referenced this issue Nov 9, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this issue Nov 19, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
pascalkuthe pushed a commit that referenced this issue Nov 21, 2023
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: #1472
Superseds: #4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
matoous added a commit to matoous/helix that referenced this issue Nov 21, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
dgkf pushed a commit to dgkf/helix that referenced this issue Jan 30, 2024
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
mtoohey31 pushed a commit to mtoohey31/helix that referenced this issue Jun 2, 2024
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
Vulpesx pushed a commit to Vulpesx/helix that referenced this issue Jun 7, 2024
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
smortime pushed a commit to smortime/helix that referenced this issue Jul 10, 2024
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
@sdoerner
Copy link
Contributor

Not sure if I'm doing something wrong, but "gf" only seems to work right locally. Trying it on an ssh connection seems to get Helix into a very weird and non-reactive state where I have to kill the process.
Anyone else experiencing this?

Tested on Alacritty with Helix 24.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-gui Area: Helix gui improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
8 participants