posva / vim-vue

Syntax Highlight for Vue.js components
MIT License
1.29k stars 102 forks source link

It does not work correctly with context_filetype.vim and caw.vim in vue files #125

Open alex-shamshurin opened 6 years ago

alex-shamshurin commented 6 years ago

I have the same html comments < !-- --> along the file, despite the file part - in style and script - the same.

context_filetype.vim and caw.vim installed. I use vim-vue via polyglot.

harryjubb commented 5 years ago

Same issue here, all installed with Plug.

adriaanzon commented 5 years ago

@herrbischoff Does caw.vim work for you, still? You added the suggestion in #93 so I thought you may know more about this :)

isaiascardenas commented 5 years ago

Same issue here but the comment are using // instead < !-- --> along the file in my case. All installed using Plug.

herrbischoff commented 5 years ago

That’s a common issue with caw regarding wrapping comment styles. Took me a while to figure it out a couple of days ago.

You’re probably using gcc as the comment/uncomment toggle. When you’re using gcw for commenting and gcuw for uncommenting, it will work. This has apparently to do with the way caw does its magic. To have that behavior changed, feel free to open an issue at the caw repo. I will happily support it, as I have the same problem within JSP files right now.

alex-shamshurin commented 5 years ago

@herrbischoff We hope you do it

jackysee commented 5 years ago

In my config I tried https://github.com/tomtom/tcomment_vim and it works.

herrbischoff commented 5 years ago

In my config I tried https://github.com/tomtom/tcomment_vim and it works.

So tcomment.vim supports multiple languages in a single file now? Can you verify this?

harryjubb commented 5 years ago

From a quick test in a Single File Component, tcomment_vim works. I swapped it out for vim-commentary, which I'd switched back to since context_filetype.vim and caw.vim weren't working for SFCs anyway.

herrbischoff commented 5 years ago

Thanks, I will check that out as well. However, caw.vim does work properly, although only in the way I wrote up above. If you expect to toggle comments with the same command, it does not.

herrbischoff commented 5 years ago

Just confirmed this myself. tcomment works great with Vue SFCs.

I have opened a PR adding it to the README: https://github.com/posva/vim-vue/pull/134

@posva: I think this issue can be closed now.

harryjubb commented 5 years ago

It works nicely, though (slightly off-topic) as with caw.vim it has some differences to other commenting plugins. For me the biggest one is https://github.com/tomtom/tcomment_vim/issues/179 which is making it hard to switch to just for Vue support.

harryjubb commented 5 years ago

Having gone back to https://github.com/tpope/vim-commentary for a while, but finally getting fed up with manually commenting in scripts/styles in Vue SFCs, I had another go with tcomment. I had missed that @mg979 had helpfully posed a mapping to fix tomtom/tcomment_vim#179 that I have adapted, so far this is working well, I'll post again if I come across any issues.

nmap <expr>  gcc   v:count? ":<c-u><cr>gc".(v:count1-1)."j" : "gcc"

Edit:

Having some trouble with single line comment toggles with the above (and separately, the plugin overwriting my mapping), so switched to:

autocmd VimEnter * nmap <expr>  gcc   v:count? ":<c-u>.,.+".(v:count-1)."TComment<CR>" : ":TComment<CR>"

In my vimrc.

mig-hub commented 2 years ago

Is there any way to make it work with https://github.com/tpope/vim-commentary ?

herrbischoff commented 2 years ago

@mig-hub You're going to have to figure this out for yourself and/or ask Tim Pope.

I have used https://github.com/tomtom/tcomment_vim for a couple of years now and it has been working reliably for me in almost all circumstances, Vue SFC included.