joereynolds/vim-minisnip

Error with g:minisnip_dir, Windows OS and ":" delimiter

Closed this issue · 7 comments

The full paths in Windows begins with C:\ (or another letter). But vim-minisnip uses as a delimiter the character :. This generates the following problems:

:let g:minisnip_dir = 'c:\Users\user\minisnip:c:\Users\user\another_minisnip'

:echo split(g:minisnip_dir, ':')
['c', '\Users\user\minisnip', 'c', '\Users\user\another_minisnip']

In my computer, vim-minisnip fails if the current pwd of Vim is in another drive letter that the g:minisnip_dir.

It should use ; on Windows. e.g. from vim-go.

" PathListSep returns the appropriate OS specific path list separator.
function! go#util#PathListSep() abort
  if go#util#IsWin()
    return ";"
  endif
  return ":"
endfunction

" IsWin returns 1 if current OS is Windows or 0 otherwise
function! go#util#IsWin() abort
  let win = ['win16', 'win32', 'win64', 'win95']
  for w in win
    if (has(w))
      return 1
    endif
  endfor

  return 0
endfunction

Could you please test #18 @plom81? I don't have a Windows machine, so I can't test it myself without downloading a VM or something.

Thanks!

I have tested and and found another problem. My test have two paths:

:let g:minisnip_dir = '~\another_minisnip;~\minisnip'

The first curious thing is this:

:echo g:minisnip_dir
C:\Users\plom81\another_minisnip;~\minisnip

Only expand one of the dirs. The problem is that the second path don't expand and filereadable() function return 0, try this:

echo filereadable('~\minisnip')
0
echo filereadable(glob('~\minisnip'))
1

Can you add this change?

Note: Powershell allows ~

That's actually a different issue, and not specific to Windows. I have the same on my Linux machine.

The problem is that in plugin/minisnip it's treating this as a single path, rather than a list of paths:

let g:minisnip_dir = fnamemodify(get(g:, 'minisnip_dir', '~/.vim/minisnip'), ':p')

The problem persists, in autoload/minisnip.vim:13 when join the path with the file the l:dir variable has a wrong path, maybe needs fnamemodify()?:

let l:ft_snippetfile = fnamemodify(l:dir, ':p') . '/_' . l:filetype . '_' . l:cword

With this modification works.

Right, thanks! I amended my previous commit.

It works great, thanks!