Shougo / dein.vim

:zap: Dark powered Vim/Neovim plugin manager
MIT License
3.43k stars 198 forks source link

dein 'hook_source' FileType autocmd break the highlight #294

Closed zgpio closed 6 years ago

zgpio commented 6 years ago

Warning: I will close the bug issue without the minimal init.vim and the reproduce ways.

Problems summary

dein 'hook_source' FileType autocmd break the markdown highlight

Environment Information (Required!)

Provide a minimal .vimrc with less than 50 lines (Required!)

clone plasticboy/vim-markdown plugin into ~/vimfiles/pack/github/start/;

if &compatible
  set nocompatible
endif
set rtp^=~/.cache/dein/repos/github.com/Shougo/dein.vim

let s:path = expand('~/.cache/dein')
if dein#load_state(s:path)
  call dein#begin(s:path)

  call dein#add('kana/vim-smartchr', {
        \ 'on_event': 'InsertEnter',
        \ 'hook_source': 'autocmd FileType c echo "foo"'
        \})

  call dein#end()
  call dein#save_state()
endif

filetype plugin indent on
syntax enable

The reproduce ways from Vim starting (Required!)

  1. clone plasticboy/vim-markdown plugin into ~/vimfiles/pack/github/start/;
  2. use my minimal vimrc
  3. :e foo.md foo.md is a exist file,contains:
        ```vim
        set nu
  4. just enter the insert mode, you will find markdown's vim code higlight break

    Screen shot (if possible)

    before enter insert: default

after enter insert (as you see, the set nu highlight broken): default

Shougo commented 6 years ago

Reproduced. But it is feature.

You have changed autocmd FileType in the hook. dein executes let &filetype = &filetype to recall FileType autocmd. It breaks vim syntax highlight.

You can simulate the behavior by let &fletype = &filetype after opening the buffer.

Shougo commented 6 years ago

So, it is let &fletype = &filetype breaks mardown highlight. I don't know plasticboy/vim-markdown's feature.

zgpio commented 6 years ago

Maybe I should add it in hook_add.