aperezdc / vim-template

Simple templates plugin for Vim
371 stars 152 forks source link

provide a complete for template syntax? #140

Closed Freed-Wu closed 4 years ago

Freed-Wu commented 4 years ago

just like lsp, when user write a language will auto prompt the keyword of this language?

image

fimmind commented 4 years ago

@aperezdc, now I get such an error whenever I startup neovim: 04 06 20_22:38:07:204643299

There is my nvim config, if it's helpful for fixing

Freed-Wu commented 4 years ago

it is my error. function coc#source#template#foo() should be declared in autoload/coc/source/template.vim, but after test, i create a new file vim-template.vim. it should rename it to template.vim.

Freed-Wu commented 4 years ago

i found coc.nvim has a plugin https://github.com/voldikss/coc-template to realize the same function. amazing.

Freed-Wu commented 4 years ago

@fimmind Can https://github.com/aperezdc/vim-template/pull/143 solve your problem?

fimmind commented 4 years ago

I'll try it within the day and tell you if it fixed the problem. (Sorry for such a late answer)

Freed-Wu commented 4 years ago

it is my pleasure!

fimmind commented 4 years ago

I tried #143 and now there is no error message on startup, but completion still doesn't work. I guess that's cause the plugin doesn't provide a way for vim to identify template files (e.g. echo &ft for =template=.py shows python, and completion works the same way as for any other Python file). I also tried adding

autocmd BufEnter =template=* setlocal ft=template
autocmd BufEnter .vim-template:* setlocal ft=template

into ftdetect/template.vim, but this didn't help

fimmind commented 4 years ago

I figured out that I used a wrong filetype. Now I added following into ftdetect/vim-template.vim and everything works very well:

autocmd BufEnter =template=* setlocal ft=vim-template
autocmd BufEnter .vim-template:* setlocal ft=vim-template

But I looked at vim-template's source code and found out that there are lines of code attempting to set filetype similarly to how I did this, but somewhy they have no effect. Do you know why could this happen?

Freed-Wu commented 4 years ago

perhaps you use lazy load function fo plugin manager? i think if can move these code to ftdetect/filetype.vim will be better if it can. https://github.com/aperezdc/vim-template/issues/139

fimmind commented 4 years ago

No, I load the plugin with a single line:

  Plug 'aperezdc/vim-template'

without of any configuration for lazyness (I use vim-plug)