aperezdc / vim-template

Simple templates plugin for Vim
371 stars 152 forks source link

comments swallowed when expanding template #115

Open Konfekt opened 7 years ago

Konfekt commented 7 years ago

The file template=makefile with content

NAME=main
FILES=%HERE%
DEP=$(NAME).pandoc $(FILES)

# vim:ft=make

produces, when calling vim makefile, the following file:

NAME=main
FILES=%HERE%
DEP=$(NAME).pandoc $(FILES)

That is, the comment disappears. In fact, if the comment is not placed at the beginning of the file, all lines below it won't appear when the template is expanded.

aperezdc commented 7 years ago

@Konfekt: Sorry, I cannot reproduce this using a local template, nor a global one. Are you setting any options for the plugin? If yes, which ones and to which values?

(As a gentle reminder, note that the default file names searched for local templates are .vim-template:<pattern>, and =template=<pattern> for global templates.)

Konfekt commented 7 years ago

Thank you. Indeed, the problem is naming the template =template=makefile.pandoc and calling vim makefile.pandoc with the plugin 'https://github.com/vim-pandoc/vim-pandoc' installed.

aperezdc commented 7 years ago

@Konfekt: I am glad that it seems to be working for you now! I guess we can close this issue now. Anyway, if you run into trouble again, or open a new one if you run into any other issue. Bug reports from user are super-useful :wink:

aperezdc commented 7 years ago

Reopening this, because adding a blank line to the template avoids the comment being swallowed (as per comment in vim-pandoc/vim-pandoc#218). We definitely have some issue with the logic around l:deleteLastLine at templates.vim:453.

aperezdc commented 7 years ago

I can try to figure a solution, but I am afraid it will take time as I'm quite busy lately. It would be awesome if @muff1nman could take a look at this, as he wrote some of the code around the last line deletion logic.