ultisnips icon indicating copy to clipboard operation
ultisnips copied to clipboard

Ultisnips cannot detect default user folder for NeoVim on Windows.

Open xarthurx opened this issue 4 years ago • 9 comments

Expected behavior: I can edit my own snippets when using :UltiSnipsEdit.

Actual behavior: A message pop up:

UltiSnips was not able to find a default directory for snippets. Do you have a .vim directory? Try :UltiSnipsEdit! instead of :UltiSnipsEdit.

Steps to reproduce

  1. Install UltiSnips for Neovim using vim-plug on Windows 10.

  2. type :UltiSnipsEdit.

PS.1: If I use :UltiSnipsEdit!. only the official snips from vim-snippets was listed. image

PS.2: I tried adding dirs and runtimes in the init.vim file, but things don't get better. Is it because ultisnips only check the $XDG_CONFIG folder for linux machines, but not $LOCALAPPDATA where Nvim is installed on Windows?


  • Operating System: Windows 10
  • Vim Version: Neovim latest.
  • UltiSnips Version: latest.
  • Python inside Vim: 3.7
  • Docker repo/vimrc:

xarthurx avatar Jun 23 '20 09:06 xarthurx

Additional notes:

If I set g:UltiSnipsSnippetDirectories to a dir with an absolute path, then I can edit my own snippets. But once I include the keyword UltiSnips in that settings (or use it only as the default settings), the above issue will occur.

xarthurx avatar Jun 23 '20 09:06 xarthurx

Same problem, vim-plug, win10

Yonshoku avatar Nov 02 '20 23:11 Yonshoku

I have the exact same issue as xarthurx and Yonshoku (neovim v0.5.0-811 and then neovim v0.5.0-828 64 bits + Windows 10 20H2 + Python 3.7 + vim-plug) Even when setting the absolute path of my snippets or adjusting the runtimepath variable I had the same error.

FruitDZign avatar Nov 12 '20 01:11 FruitDZign

You need to create a directory called UltiSnips inside ~/.vim directory mkdir ~/.vim/UltiSnips

cristianUrbina avatar Feb 08 '22 04:02 cristianUrbina

I have no idea what Neovim does differently so this does not work. Please try reproducing with Vanilla Vim. I'll leave the ticket open for a while until I see a repro with Vanilla Vim, otherwise I assume this is a neovim only problem.

This issue was deprioritized due to it only affecting Neovim and not core Vim.

Why is Neovim only best-effort?

UltiSnips maintenance is a lot of work. Reproducing bug reports is tedious, slow and error prone. The current maintainers have to limit their scope to provide a reasonable level of service to the community.

Neovim should work with any plugin that core vim works with. But in the past, Neovim support has been difficult for UltiSnips: It regularly had bugs that did not affect the core Vim distributions, i.e. Vim, gVim, MacVim, and Vim for Windows and its testing approach required a completely separate code path from core as well. Therefore, currently Neovim bugs are considered on a best effort basis.

UltiSnips is looking for an additional maintainer that is interested in bringing the Neovim level of service on par with core Vim. If you are interested in helping out, please reach out to SirVer.

SirVer avatar Feb 13 '22 08:02 SirVer

I think the issue may because UltiSnips does not recognize the neovim folder structure, i.e. everything inside ~/nvim instead of ~/.vim. Would it be possible to simply add an option to add a different default folder?

xarthurx avatar Feb 25 '22 09:02 xarthurx

@xarthurx UltiSnips is using rtp like any Vim plugin should. It does not have a "default folder" per se. I have no idea if and if yes, how Neovim has deviated from this. If a simple patch is possible, I gladly accept a pull request.

SirVer avatar Feb 27 '22 19:02 SirVer

BTW, it works if you create the folder inside ~/.config/nvim/ instead of ~/.vim/

igor-ribeiro avatar Apr 01 '22 04:04 igor-ribeiro

I'm using neovim now, and I use let g:UltiSnipsSnippetDirectories = ["~/.config/nvim/UltiSnips"] in my init.vim, which probably fixed the issue. (Attention to the '[')

Because I found the origin g:UltiSnipsSnippetDirectories is set to ['UltiSnips'] only, it can't be expand to an absolute path. Besides, my &runtimepath has no ~/.config/nvim so Path(snippet_dir).parent can't be neovim's "dot_vim_dir". If you specify g:UltiSnipsSnippetDirectories, it would return directly without traverse &runtimepath.

Tsingv avatar Jul 28 '22 04:07 Tsingv

I created a PR that should fix this. At least it allows NeoVim and Vim to work properly on my system :-)

I cannot test on windows but it would be appreciated if anybody could try (@xarthurx perhaps?)

FYI: what @igor-ribeiro mentions here is because get_dot_vim() only handles one file which happens to be ~/.config/nvim/ (only due to ordering in the code :man_shrugging: )

marcdeop avatar Aug 12 '22 15:08 marcdeop