Closed xream closed 8 years ago
Hello, this is something that has to be done in nerdcommenter side. There're two issues about it: https://github.com/scrooloose/nerdcommenter/issues/225 https://github.com/scrooloose/nerdcommenter/issues/17
@posva I see. I was just wondering what plugin you guys use.
@xream I find myself with the same issue 😢
I've been trying to improve my vue handling in vim as well. I just stumbled across tcomment and tried replacing vim-commentary with it, and it seems to work well for me. I have to set filetype=html
to get it to work properly, but now commenting works in the html, javascript, and css regions of a .vue file.
I need to keep using it to see if there are side effects, and I need to figure out a way to get correct syntax highlighting in the javascript region (syntax highlighting works, but it's not as good as what I get in a standalone javascript file).
ft=html
works well for js, html and css. However if you're using a
preprocessor like pug, sass or stylus, you'll need something like vim-vue
On Wed, 14 Sep 2016, 07:39 Bennett Rogers, notifications@github.com wrote:
I've been trying to improve my vue handling in vim as well. I just stumbled across tcomment https://github.com/tomtom/tcomment_vim and tried replacing vim-commentary with it, and it seems to work well for me. I have to set filetype=html to get it to work properly, but now commenting works in the html, javascript, and css regions of a .vue file.
I need to keep using it to see if there are side effects, and I need to figure out a way to get correct syntax highlighting in the javascript region (syntax highlighting works, but it's not as good as what I get in a standalone javascript file).
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/posva/vim-vue/issues/17#issuecomment-246911610, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoicegnk1R1fsJ34Z00oKTglzgiLfFFks5qp4iJgaJpZM4If7FR .
I do have vim-vue installed as well... Is it not actually doing anything if the filetype isn't set to vue?
I do use sass inside the style region of my .vue files. What functionality is lost there by setting ft=html
?
If you don't set the ft, it's not changing anything Some of the syntax highlighting may not work on html
On Wed, 14 Sep 2016, 09:16 Bennett Rogers, notifications@github.com wrote:
I do have vim-vue installed as well... Is it not actually doing anything if the filetype isn't set to vue?
I do use sass inside the style region of my .vue files. What functionality is lost there by setting ft=html?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/posva/vim-vue/issues/17#issuecomment-246926671, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoicVRtduGL3DwPzS0Boix8-BUwdsnBks5qp580gaJpZM4If7FR .
Note for anyone finding this closed issue in the future:
@xream added hooks to NERDCommenter to allow switching to different comment delimiters, depending on the region of the .vue
file.
Add the following to your .vimrc
to enable it:
let g:ft = ''
fu! NERDCommenter_before()
if &ft == 'vue'
let g:ft = 'vue'
let stack = synstack(line('.'), col('.'))
if len(stack) > 0
let syn = synIDattr((stack)[0], 'name')
if len(syn) > 0
let syn = tolower(syn)
exe 'setf '.syn
endif
endif
endif
endfu
fu! NERDCommenter_after()
if g:ft == 'vue'
setf vue
g:ft
endif
endfu
@nemtsov Thanks for the hooks, works perfectly. I think the g:ft
in the third-to-last line is a typo though.
This is not work at visual mode T_T
Note for anyone finding this closed issue in the future:
@xream added hooks to NERDCommenter to allow switching to different comment delimiters, depending on the region of the
.vue
file.Add the following to your
.vimrc
to enable it:let g:ft = '' fu! NERDCommenter_before() if &ft == 'vue' let g:ft = 'vue' let stack = synstack(line('.'), col('.')) if len(stack) > 0 let syn = synIDattr((stack)[0], 'name') if len(syn) > 0 let syn = tolower(syn) exe 'setf '.syn endif endif endif endfu fu! NERDCommenter_after() if g:ft == 'vue' setf vue g:ft endif endfu
The code does not work well for below code:
<template>
<div>
<i-col>
<p>haha</p>
</i-col>
</div>
</template>
<script>
export default {
data () {
return {}
}
}
</script>
If I invoke <leader>cc
for some lines, it produce below comments (with /* */
)
<template>
<div>
<i-col>
/*<p>haha</p>*/
</i-col>
</div>
</template>
<script>
export default {
data () {
/*return {}*/
}
}
</script>
With scrooloose/nerdcommenter all I get is
/* */