Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The vue hook doesn't work now #476

Open
run27017 opened this issue Aug 9, 2021 · 5 comments
Open

The vue hook doesn't work now #476

run27017 opened this issue Aug 9, 2021 · 5 comments

Comments

@run27017
Copy link

run27017 commented Aug 9, 2021

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
@alerque
Copy link
Member

alerque commented Oct 29, 2021

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

@chris-gassner
Copy link

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

@alerque
Copy link
Member

alerque commented Dec 18, 2021

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?

@chris-gassner
Copy link

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 , <script> or <style> part of the file. It always uses html style comments.

@alerque
Copy link
Member

alerque commented Dec 18, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@alerque @run27017 @chris-gassner and others