nerdcommenter
nerdcommenter copied to clipboard
The vue hook doesn't work now
From the source of 'https://github.com/posva/vim-vue#how-can-i-use-nerdcommenter-in-vue-files',I make the simplest configuration:
scriptencoding utf-8
let g:vimhome=fnamemodify(resolve(expand('<sfile>:p')), ':h')
let mapleader=','
let maplocalleader=';'
let &runtimepath=g:vimhome.'/runtime'.',$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,'.g:vimhome.'/runtime/after'
call plug#begin(g:vimhome.'/bundle') " 插件声明 {{{
Plug 'scrooloose/nerdcommenter'
Plug 'posva/vim-vue'
call plug#end() " }}}
function! NERDCommenter_before()
if &ft == 'vue'
setf javascript
echom "Changed to javascript"
endif
endfunction
For the vue file, I input the <leader>cc command, but the commentary is not the javascript style.
From:
<script>
console.log("Hello")
</script>
To:
<script>
<!-- console.log("Hello") -->
</script>
On the other side, I can see the message "Changed to javascript", which means setf javascript actually executed.
Version info:
- nerdcommenter:
2c87cae7 - vim:
8.2 (2019 Dec 12) With Patch: 1-3204 - os:
openSUSE Tumbleweed 20210731
After you open your content file what value is set for filetype? (run set ft to see)
Same here, not sure how long ago it stopped working. set ft returns filetype=vue
Does it work for any other file types for you? I don't see any special handling for vue files as opposed to other types, so I have to wonder if you have the plugin working at all? Also does your plugin manager happen do do on-demanad loading based on filetypes?
I assume the plugin is working otherwise, I've tried different commands (
@chris-cassner This plugin has never supported recognizing when you are in different contexts in a file. This is a long standing feature request (see #17) but not something we've ever implemented. If you had that functionality it was a different plugin providing it. There are plugins that do that far various combinations of source and embeded contexts. It is possible this plugin is blocking something else that would normally provide that, see #477 for a recent request to try to avoid getting in other plugin's way when they set comment strings.