vim-vue icon indicating copy to clipboard operation
vim-vue copied to clipboard

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

Open alex-shamshurin opened this issue 6 years ago • 14 comments

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.

alex-shamshurin avatar Nov 06 '18 20:11 alex-shamshurin

Same issue here, all installed with Plug.

harryjubb avatar Nov 28 '18 13:11 harryjubb

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

adriaanzon avatar Dec 21 '18 15:12 adriaanzon

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

isaiascardenas avatar Dec 29 '18 02:12 isaiascardenas

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.

herrbischoff avatar Jan 04 '19 08:01 herrbischoff

@herrbischoff We hope you do it

alex-shamshurin avatar Jan 04 '19 09:01 alex-shamshurin

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

jackysee avatar Mar 19 '19 08:03 jackysee

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?

herrbischoff avatar Mar 19 '19 10:03 herrbischoff

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.

harryjubb avatar Mar 19 '19 10:03 harryjubb

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 avatar Mar 19 '19 11:03 herrbischoff

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.

herrbischoff avatar Mar 19 '19 11:03 herrbischoff

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 avatar Mar 19 '19 14:03 harryjubb

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.

harryjubb avatar Jul 17 '19 10:07 harryjubb

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

mig-hub avatar May 19 '22 11:05 mig-hub

@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.

herrbischoff avatar May 20 '22 11:05 herrbischoff