nerdcommenter icon indicating copy to clipboard operation
nerdcommenter copied to clipboard

The vue hook doesn't work now

Open run27017 opened this issue 4 years ago • 5 comments
trafficstars

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

run27017 avatar Aug 09 '21 03:08 run27017

After you open your content file what value is set for filetype? (run set ft to see)

alerque avatar Oct 29 '21 17:10 alerque

Same here, not sure how long ago it stopped working. set ft returns filetype=vue

chris-gassner avatar Dec 17 '21 14:12 chris-gassner

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?

alerque avatar Dec 18 '21 13:12 alerque

I assume the plugin is working otherwise, I've tried different commands (cs, c$) and they all work as expected, it just does no longer recognize whether I'm in the

chris-gassner avatar Dec 18 '21 20:12 chris-gassner

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

alerque avatar Dec 18 '21 21:12 alerque