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

neovim: support clicking targets #2405

Open
fidgetingbits opened this issue Jun 12, 2024 · 3 comments
Open

neovim: support clicking targets #2405

fidgetingbits opened this issue Jun 12, 2024 · 3 comments
Labels
app-neovim Issues related to neovim support good first issue Good for newcomers

Comments

@fidgetingbits
Copy link
Contributor

If I have a URL in the terminal and target it with click second paint row <blah> it doesn't open the link, like it would in vscode. It prints the openLink Not implemented error. This would be useful for instance if you git push and then get a PR link listed like this:

❯ git push --set-upstream origin cleanup-utils
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 20 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 868 bytes | 868.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
remote: 
remote: Create a pull request for 'cleanup-utils' on GitHub by visiting:
remote:      https://github.com/hands-free-vim/talon.nvim/pull/new/cleanup-utils
remote: 
To ssh://github.com/hands-free-vim/talon.nvim
 * [new branch]      cleanup-utils -> cleanup-utils
branch 'cleanup-utils' set up to track 'origin/cleanup-utils'.
@pokey
Copy link
Member

pokey commented Jun 12, 2024

note that it should also jump to definition if you use it to target an identifier

@saidelike saidelike added the good first issue Good for newcomers label Jun 12, 2024
@saidelike
Copy link
Collaborator

I think it should be easy to implement as long as we have a way to open the default browser that works on linux/windows/osx.

Maybe using something like https://github.com/chrishrb/gx.nvim?

@saidelike saidelike added the app-neovim Issues related to neovim support label Jun 12, 2024
@fidgetingbits
Copy link
Contributor Author

I think it should be easy to implement as long as we have a way to open the default browser that works on linux/windows/osx.

Maybe using something like https://github.com/chrishrb/gx.nvim?

The gx mapping is already a default builtin that is cross-platform. In t and nt mode we could just have cursorless issue a gx on the target and it's up to the user to manually install gx.nvim or not if they want something fancier. Could be listed as a recommended plugin or something.

From :help gx:

gx			Opens the current filepath or URL (decided by
			|<cfile>|, 'isfname') at cursor using the system
			default handler, by calling |vim.ui.open()|.

							*v_gx*
{Visual}gx		Opens the selected text using the system default
			handler, by calling |vim.ui.open()|.

From :help vim.ui.open():

vim.ui.open({path})                                            *vim.ui.open()*
    Opens `path` with the system default handler (macOS `open`, Windows
    `explorer.exe`, Linux `xdg-open`, …), or returns (but does not show) an
    error message on failure.

    Expands "~/" and environment variables in filesystem paths.

    Examples: >lua
        -- Asynchronous.
        vim.ui.open("https://neovim.io/")
        vim.ui.open("~/path/to/file")
        -- Synchronous (wait until the process exits).
        local cmd, err = vim.ui.open("$VIMRUNTIME")
        if cmd then
          cmd:wait()
        end
<

    Parameters: ~
      • {path}  (`string`) Path or URL to open

    Return (multiple): ~
        (`vim.SystemObj?`) Command object, or nil if not found.
        (`string?`) Error message on failure, or nil on success.

    See also: ~
      • |vim.system()|

For being able to jump to definition (which is outside the scope of terminal side I think?) you'd have to do some more complicated target pre-parsing to see if it is a URL, path, or a follow-able symbol I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app-neovim Issues related to neovim support good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants