Hi There,
I’m trying to follow the documentation for a neovim plugin here. The section I want help with is as follows:
Configure the Point and Click
Easy (and quite robust) way
Install neovim-remote xdg-open is (for me) quite bloated and complicated to use for a simple resource opener.
The following configuration will bypass this software. It’s much simpler and more effective for me, but if you opt for a more classic configuration, go directly to the next section.
Option 1 : Add this lines to /usr/bin/xdg-open (e.g. line 36) : if [[ "$@" == textedit://*ly:* ]]; then tmp=${@#*://} tmp="${tmp%%:*}" attr=${@#*ly:} file="${tmp//%20/\\ }" line=${attr%:*:*} col=${attr##*:} nvr -s +:"dr $file | call cursor($line, $col)" exit fi
And that is all !
Option 2 : if you don’t want to modify xdg-open :
Create a file called xdg-open in $HOME/.local/bin/ containing this code :
tmp=${@#*://} tmp="${tmp%%:*}" attr=${@#*ly:}
file="${tmp//%20/\\ }"
line=${attr%:*:*}
col=${attr##*:}
nvr -s +:"dr $file | call cursor($line, $col)"
exit
fi
/usr/bin/xdg-open "$@"```
Make this file executable :
`chmod +x $HOME/.local/bin/xdg-open`
Add the folder to your path (in .bashrc) :
`export PATH="$HOME/.local/bin:$PATH"`
I can’t seem to find any easy ways to append code to the xdg-open file, which I’m guessing is kept somewhere in the Nix store? Help adapting either option to Nixos would be much appreciated!
Uh… so this plugin is written to call xdg-open, but then tells users to edit or replace xdg-open with their own script? Why does it not just ship with its own script with a different name?
You can write a wrapper script that calls the real xdg-open using a trivial builder like writeShellScriptBin, and you can add that to your profile the same way you would add any other package (declaratively). I’d recommend giving it its own name and patching vimPlugins.nvim-lilypond-suite to reference that name instead. But if you must, you can replace the xdg-open from xdg-utils by using lib.setPrio (or hiPrio) to give your script a higher (that is, a smaller number) priority than the default (5).
From that option, I assume you’re using Home Manager, in which case home.sessionVariables would be a better choice for setting LYEDITOR (not restricted just to Bash shells).
But yeah, if that works for you, it seems reasonable! I also saw mention of this pdf_viewer option, which might be a way to specify a custom replacement for xdg-open without going to the trouble of making a patch.