ultisnips icon indicating copy to clipboard operation
ultisnips copied to clipboard

Duplicated snippets when using symlink.

Open ameeruljunaidi opened this issue 3 years ago • 13 comments

I am syncing my dot files to two computers and have my ".vim" symlinked to a file in a git repo called "dotfiles".

Ultisnip seems to be detecting duplicate and asking me to choose everytime.

image

" Ultisnips settings

let g:UltiSnipsSnippetDirectories=["UltiSnips", "custom-snippets"]

ameeruljunaidi avatar Apr 11 '21 22:04 ameeruljunaidi

I was about to write the same. Just a small addition: The setting let g:UltiSnipsSnippetDirectories = ["..."] seems to be completely ignored.

Artem-Schander avatar Apr 14 '21 10:04 Artem-Schander

@Artem-Schander no, it is not ignored, but the way snippets are searched for and edited is complex (unfortunately for good reasons) and not super intuitive. It is well documented in the help I think, but it is a bit to read.

To just fix this annoyance, you probably want to use g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit, documented here https://github.com/SirVer/ultisnips/blob/issue/1343/fix/doc/UltiSnips.txt#L186.

SirVer avatar Apr 16 '21 19:04 SirVer

Hi @SirVer,

I think I'm to dumb. It does not work and to be honest It does not seem like it is a solution at all. I've tried to set the following without any change:

let g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit = "~/.config/nvim/plugged/vim-snippets/snippets"
let g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit = "/home/va-artem/.dotfiles/config/nvim/plugged/vim-snippets/snippets/php.snippets"

Assuming it would work as I understand the docs. Wouldn't it only load the files from a single directory?

Artem-Schander avatar Apr 19 '21 09:04 Artem-Schander

Hi @SirVer,

Thanks for the workaround. Unfortunately, it did not work and Ultisnip still detected duplicates...

ameeruljunaidi avatar Apr 20 '21 01:04 ameeruljunaidi

I do not understand what is going on in both your cases then. Could you provide a minimal repro case so I can either fully appreciate the issue or debug what is going on? Please provide a fully reproducible example, ideally using the approach explained in https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs or if not possible with a minimal vimrc and snippets files, symlinks and involved directory structure and an exact sequence of key strokes that trigger the bug.

SirVer avatar Apr 20 '21 07:04 SirVer

I'll try to find some time and create an example over the weekend

Artem-Schander avatar Apr 21 '21 17:04 Artem-Schander

@Artem-Schander friendly ping. I will not be able to help without a repro case.

SirVer avatar May 03 '21 13:05 SirVer

@SirVer It's still on my agenda. I'm trying my best to find some time

Artem-Schander avatar May 03 '21 17:05 Artem-Schander

@SirVer thanks for your patience. Here is the repo as minimal as i could get it while still having this issue.
Without the plugins vim-vdebug/vdebug and sheerun/vim-polyglot this issue does not occur.
I hope this helps to narrow it down

Artem-Schander avatar May 12 '21 18:05 Artem-Schander

@Artem-Schander Thanks for providing this repro case! That this is an interplay with other plugins bumps this down in priority for me, since that will be much harder to track down and impact much less users. I hope I get around to it to dig in soonish still.

@ameeruljunaidi are you using any of the mentioned plugins as well?

SirVer avatar May 18 '21 14:05 SirVer

@SirVer Allright. It's not a big deal for me anyway. Take your time and let me know if I can help somehow.

Artem-Schander avatar May 18 '21 14:05 Artem-Schander

Thank you @SirVer, I had the same issue and removing sheerun/vim-polyglot solved the issue! Thank you for your help :)

karma-riuk avatar Sep 21 '21 07:09 karma-riuk

vim-polyglot does some symlink resolution while modifying the runtimepath so it can put vim-polyglot at the beginning of the runtime path. I'm not sure if the symlink resolution is necessary but essentially it means the runtimepath is modified and so Ultisnips finds both instances of your snippets.

https://github.com/sheerun/vim-polyglot/blob/master/autoload/polyglot/init.vim#L3581-L3586

nulty avatar Dec 08 '21 23:12 nulty