Open chancez opened 1 month ago
Thanks for reporting the bug. I fixed it, just had to fnameescape
the file name first. Try the latest master
please.
Here is what the code is trying to achieve:
.jinja
(or whatever other extension) from the file name (using fnamemodify
).jinja
to the detected file typeI don't have any better idea how to tell Vim "try detecting the file type, but pretend that last file extension wasn't there". Using the :file
command to change the buffer name causes other problem as well.
@HiPhish Nice! Thanks for the update.
The latest master no longer fails in the same way, and the filename reported in the buffer seems to be correct. However, it does seem to still be somewhat buggy. When I try to save, I get the following error instead:
E13: File exists (add ! to override)
That said, this error is relatively easy to work-around at least.
Yes, that problem is related to my use of :filename
, it seems to dissociate the buffer from its file. I hope I can find a workaround.
@chancez I think I have managed to fix the problem. Can you please report back if anything weird starts happening, like changes being lost or files that should not exist getting created?
Well in my small test case, it works as expected. I'll report back if I find any issues. Thanks again for the help. Nothing like finding a bug after 6 years and getting it fixed in no time, your a champ!
I know this project is really old, but I figured I'd file this bug report, just in case anyone else encounters the issue I did.
I'm using https://copier.readthedocs.io/en/stable/ which uses Jinja to template out scaffolding for files in a repository. One feature is that it uses Jinja in the filenames of files to do logic like conditionally create certain files. However this means there's
%
in the filenames. What I found is that when I'm using this jinja.vim plugin I cannot save files with%
in them.For example with the filename
template/.github/ISSUE_TEMPLATE/{% if create_bug_report_issue_template %}bug_report.yaml{% endif %}.jinja
I get an error like:
I think this is because of the usage of the
expand()
function here: https://github.com/HiPhish/jinja.vim/blob/master/ftdetect/jinja.vim#L25 and the subsequent call tofnamemodify
here https://github.com/HiPhish/jinja.vim/blob/master/ftdetect/jinja.vim#L32C27-L32C38. I'm not sure if the expand call is required, or what the correct fix is, but maybe when I have some time I'll try forking and fixing it myself to see if it works for my use-case, but if you have suggestions I'd love to hear it.Anyways, thanks for your plugin!