I have a vim script, which uses Unix type path separator as:
"Prg: Expand snippets {{{!
let s:plugin_dir=filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0]
let s:templatedir=s:plugin_dir . '/templates/'
function! Prog(arg)
execute 'r ' . s:templatedir . a:arg . '.txt'
%substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge
endfunction
"}}}
"
I have never used Windows, so I was not aware that it may break in windowsWindows. One of my userusers reported thethis issue:
The script works very well on Linux system, but when I try it on Windows, it does not work with the following error:
================================================= Error detected while processing C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line 102: E684: list index out of range: 0 E15: Invalid expression: filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121: Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir . '/templates/' =================================================
> =================================================
Error detected while processing
> C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line
> 102: E684: list index out of range: 0 E15: Invalid expression:
> filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121:
> Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir
> . '/templates/'
> =================================================
Also, he was kind enough to send me back the solution as:
In Windows, forward slash should be backward slash, so the code should be
filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]
filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]
and
s:plugin_dir . '\templates\'
s:plugin_dir . '\templates\'
Which he claims to work for him.
As far as I know, vim should alter the path separators inherently. But, clearly, this is not the case here.
The complete code in question is available here.
I will be grateful if someone kindly check this. I can't do that since I don't have any access to windowsWindows.
Thanks and Regards,