leafOfTree / vim-vue-plugin

Vim syntax and indent plugin for .vue files
The Unlicense
177 stars 9 forks source link

Vue SFC custom block support ? #29

Closed IndexXuan closed 3 years ago

IndexXuan commented 3 years ago

Thanks for this awesome plugin. can we support Vue SFC custom block like , or something.

e.g. https://github.com/intlify/vite-plugin-vue-i18n e.g. https://github.com/ktsn/vue-route-generator#route-custom-block

thanks a lot.

leafOfTree commented 3 years ago

That's a good idea. Definitely, we should. I'll check it soon.

leafOfTree commented 3 years ago

I've added the feature. Please try and let me know if it works.

Here's the doc: https://github.com/leafOfTree/vim-vue-plugin#custom-blocks

Example

let g:vim_vue_plugin_custom_blocks = { 
      \'docs': 'markdown',
      \'i18n': ['json', 'yaml', 'json5'],
      \}

Should highlight custom blocks in .vue file such as

<docs>
# This is the documentation for component.
</docs>

<i18n lang="yaml">
en:
  hello: "Hello World!"
ja:
  hello: "こんにちは、世界!"
</i18n>
IndexXuan commented 3 years ago

image sorry, there are some errors .

leafOfTree commented 3 years ago

Hi, IndexXuan, which vim version do you use? It seems that your vim doesn't support the optional function argument. I've replaced it with a normal argument. Hope it'll solve the errors. https://github.com/leafOfTree/vim-vue-plugin/commit/b24ce563611a7041c8a2e7ded82e7f30fbe88e17

leafOfTree commented 3 years ago

Also, you probably need to install a vim json5 plugin since vim doesn't support it by default yet.

IndexXuan commented 3 years ago

@leafOfTree It works, thanks for this awesome plugin. switch from vim-vue to it now. also I am use nvim 0.5.0.

yes, after install json5 plugin, it even work for json-like syntax.