locatorjs icon indicating copy to clipboard operation
locatorjs copied to clipboard

feat: Option to copy custom path to clipboard for vim instead of opening link on click

Open mistercanderson opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

I can't use the "click to component" feature with neovim as my primary editor since the default click behavior is set to open links, it would be nice to have an alternative option to copy the link path to the clipboard on click.

I found that by setting up a custom path of e +${line} ${filePath} in the project settings, I can copy the link preview in the bottom of the settings popup and enter it as a vim command that takes me to the correct location/line of the component being inspected. However, it's difficult to use because with the preview settings open, the "link preview" result changes to the last hovered item.

Describe the solution you'd like to see

It would be great to have an alternative option to copy the link path on click instead of the default behavior to open a link. I would specifically not want anything open on click when this option is selected.

Desribe alternate solutions

I've tried adjusting different configurations of the custom path to try and automatically open the file through my terminal and neovim, but nothing I've tried has worked.

Additional information

Using Neovim 0.8.0 and Chrome 107.0.5304.110

mistercanderson avatar Nov 23 '22 23:11 mistercanderson

I would love to have a copy path on click too

gaetan-puleo avatar Aug 28 '23 10:08 gaetan-puleo

Would be great to have this feature 👍

If not, has somebody looked into either forking this extension or hijacking the vscode url scheme and/or using https://github.com/dandavison/open-in-editor to open the file in Vim?

andys8 avatar Sep 06 '23 22:09 andys8

Update

I think I got it working with a bit of fiddling.

LocatorJS

vim-open://${projectPath}${filePath}:${line}

image

vim-open.sh

Executable and in bin / on PATH.

#!/usr/bin/env bash
if [[ "$1" == "vim-open:"* ]]; then
    ref=${1#vim-open://}
    file=""${ref%:*}
    line=${ref#*:}
    st -e vim +$line $file
fi

Create a script to open a terminal, open vim with the current file and line. I'm using st but it can be changed to adapted or changed to copying something in the clipboard, if you prefer.

vim-open.desktop

Create a file in e.g. ~/.local/share/applications.

[Desktop Entry]
Type=Application
Name=VimOpen
GenericName=Open File in Vim
Icon=text-editor
Exec=vim-open.sh %u
Categories=Utility;Core;
MimeType=x-scheme-handler/vim-open
Terminal=true

Register URL scheme

xdg-mime default vim-open.desktop x-scheme-handler/vim-open

andreas-vivenu avatar Sep 08 '23 09:09 andreas-vivenu

To me it's not a viable solution, I would love to have an universal option like copy to the clipboard path to be able to use any editor. But thanks for the workaround

Update

I think I got it working with a bit of fiddling.

LocatorJS

vim-open://${projectPath}${filePath}:${line}

image

vim-open.sh

Executable and in bin / on PATH.

#!/usr/bin/env bash
if [[ "$1" == "vim-open:"* ]]; then
    ref=${1#vim-open://}
    file=""${ref%:*}
    line=${ref#*:}
    st -e vim +$line $file
fi

Create a script to open a terminal, open vim with the current file and line. I'm using st but it can be changed to adapted or changed to copying something in the clipboard, if you prefer.

vim-open.desktop

Create a file in e.g. ~/.local/share/applications.

[Desktop Entry]
Type=Application
Name=VimOpen
GenericName=Open File in Vim
Icon=text-editor
Exec=vim-open.sh %u
Categories=Utility;Core;
MimeType=x-scheme-handler/vim-open
Terminal=true

Register URL scheme

xdg-mime default vim-open.desktop x-scheme-handler/vim-open

gaetan-puleo avatar Nov 13 '23 12:11 gaetan-puleo