E518: Unknown option: <truncated file path>
Closed this issue · 5 comments
Colortemplate: v2.2.0
gVIM: v9.0.1425
The installation of vim-colorplate
with vim-plug
ran without issues.
" vimrc
set nocompatible
call plug#begin('$HOME\vimfiles\vim-plug')
Plug 'lifepillar/vim-colortemplate'
call plug#end()
filetype plugin indent on
syntax enable
Next I ran the :edit
command similarly to the Readme
example:
" gVIM
:edit vimfiles\vim-plug\vim-colortemplate\templates\dark.colortemplate
The :edit
command triggers an error message:
I have tried to use forward slashes instead of backslashes for the :edit
command, but the error message is identical. The corresponding code producing the error prepares and finally sets the value of the runtime_path
variable:
let b:colortemplate_outdir = empty(expand('%:p:h')) ? getcwd() : expand('%:p:h')
if b:colortemplate_outdir =~? '\m\%(color\)\=templates\=$'
let b:colortemplate_outdir = fnamemodify(b:colortemplate_outdir, ':h')
endif
if get(g:, 'colortemplate_rtp', 1)
execute 'set runtimepath^=' .. b:colortemplate_outdir
endif
A FEW HOURS LATER...
It looks like the :h
modifier for the expand
function is insufficient to preserve the space character in the head of the full file path. The :h:S
modifier would be suitable to escape special/whitespace characters in the path string for both the expand
and the fnamemodify
functions
let b:colortemplate_head = expand('%:p:h:S')
let b:colortemplate_outdir = empty(b:colortemplate_head) ? fnamemodify(getcwd(), ':p:h:S') : b:colortemplate_head
if get(g:, 'colortemplate_rtp', 1)
execute 'set runtimepath^=' .. b:colortemplate_outdir
endif
With these modifications, the path expansion is only ever evaluated once and the b:colortemplate_outdir
is assigned a string with the file path to the templates
folder:
C:\Users\Christian Rickert\vimfiles\vim-plug\vim-colortemplate\templates
.
In case the path expansion doesn't yield any result (set to let b:colortemplate_head = ''
for testing), the variable is instead assigned a string with the file path to the current working directory:
C:\Users\Christian Rickert
As a result, the value of the runtime_path
variable is properly set and the error message disappears.
@lifepillar If you agree with this proposed change, I would create a pull request.
Thanks for investigating this issue! Paths are tough… If you could make a PR out of that it would be great!
Btw, what do echo exists('+shellslash')
and echo &shellslash
print in your environment? Does Colortemplate work if you add set shellslash=1
in your vimrc?
Btw, what do
echo exists('+shellslash')
andecho &shellslash
print in your environment? Does Colortemplate work if you addset shellslash=1
in your vimrc?
echo exists('shellslash')
" 1
echo &shellslash
" 0
set shellslash
echo &shellslash
" 1
:edit vimfiles\vim-plug\vim-colortemplate\templates\dark.colortemplate
" E518, see below.
The current master should solve this issue, but I cannot test it on Windows. Can you please check and report whether it's fixed for you?
Closing as fixed, as per your comment here: bef949c#commitcomment-115557784