Closed heavenshell closed 11 years ago
Thanks for the patch.
But I have one concern: Unftbundle() ends up calling itself because the doautoall FileType
inside Unftbundle() triggers the autocmd FileType call Unftbundle()
directive near the bottom of unbundle.vim. Thankfully, the recursion is not infinite. :sweat_smile:
Also, the BufRead
event should have caused set filetype=python
when you opened a *.py
file. I wonder why this does not occur in MacVim GUI? :apple:
Hi, thanks for quick reply.
Also, the BufRead event should have caused set filetype=python when you opened a *.py file. I wonder why this does not occur in MacVim GUI?
I reproduced in Windows GUI/CUI Vim following steps(I use old Windows XP).
:set ft=python
to change filetypeautocmd FileType
.Sorry, I hava no idea why CUI MacVim works ok :-(
Regards,
Hi,
I continute to look into this problem. I think another plugin conflict to jedi.vim. Would you please wait to merge or it's ok to reject this patch. If this problem occuerd by unbundle.vim, I'll report you.
I applicate your kindness.
Regards,
Sure, I will wait. There's no hurry. :innocent:
HI, I catch up this problem.
The reason why this problem occured by filetype plugin on
before unbundle.vim load.
If filetype plugin on
set before unbundle.vim, need to reload filetype for execute autocmd FileType
.
Because filetype plugin on
execute autocmd FileType
once.
Following code is a sample to check autocmd behavior.
autocmd!
set nocompatible
filetype indent plugin on
filetype off
filetype indent plugin on
autocmd FileType vim call s:Sample()
function! s:Sample()
echomsg 'sample'
endfunction
This script echo sample
once.
A lot of Japanese Vim user favor to use Vim-Kaoriya package which are included Original Vim binary + additional plugins + some patches.
This package contains vimrc_example.vim and load before $HOME/.vimrc load.
And vimrc_example.vim conatines filetype plugin indent on
.
FYI Vim detect $VIM/{vimrc,.vimrc,_vimrc}
load it and then load $HOME/.vimrc
.
Using this package, filetype indnt plugin
always on.
So autocmd FileType
already executed before unbundle.vim load.
Followings are use-cases of filetype state when unbundle.vim loaded.
filetype plugin on
before. This case is OK to load autocmd FileType
because unbundle.vim set fietype plugin indent on
at last.autocmd FileType
already executed. So need to reload autocmd FileType
filetype plugin on
before. So need to reload autocmd FileType
I update my patch.
Checking filetype loaded or not, if filetype is OFF, nothings to do.
Otherwise set filetype again to execute autocmd FileType
.
BTW I reported MacVim CUI works ok before, sorry that was my probrem.
I aliased vim to vim -u $HOME/.vimrc
to not load example_vimrc.vim :-p
Please check.
Regards,
Thanks for the explanation and updated patch! :sparkles:
What if we turn off filetype detection before turning it on?
diff --git a/unbundle.vim b/unbundle.vim
index 09b47bd..b25b91f 100644
--- a/unbundle.vim
+++ b/unbundle.vim
@@ -49,5 +49,6 @@ augroup Unftbundle
autocmd!
autocmd FileType * call Unftbundle(expand('<amatch>'))
augroup END
runtime! ftbundle/*/*/ftdetect/*.vim
+filetype off
filetype plugin indent on
Would that solve the problem?
Hi, thank you for comment.
Would that solve the problem?
No.
If already filetype plugin on
before unbundle.vim, 2nd filetype plugin on
did not execute autocmd FileType
.
IMHO this is Vim's spec.
Please see :h filetype-off
.
You can see filetype info to type :filetype
.
$ vim -u NONE -U NONE -N
:filetype
filetype detection:OFF plugin:OFF indent:OFF
:filetype plugin on
and :filetype
filetype detection:ON plugin:ON indent:OFF
:filetype off
and :filetype
7 shows filetype detection:OFF plugin:(on) indent:OFF
plugin:(on)
means Vim caches filetype plugin
flag.
So autocmd FileType
did not execute again.Regards,
Thanks for the detailed analysis! :+1:
Since Vim is caching the filetype plugin
flag at step 7, let's try turning off all filetype flags:
diff --git a/unbundle.vim b/unbundle.vim
index 09b47bd..b25b91f 100644
--- a/unbundle.vim
+++ b/unbundle.vim
@@ -49,5 +49,6 @@ augroup Unftbundle
autocmd!
autocmd FileType * call Unftbundle(expand('<amatch>'))
augroup END
runtime! ftbundle/*/*/ftdetect/*.vim
+filetype plugin indent off
filetype plugin indent on
Does that solve it?
By the way, I am asking you these additional questions because I think the solution can be made shorter (less lines of code). Thanks for your patience.
Hi,
Great, it's works! Very nice :+1:
By the way, I am asking you these additional questions because I think the solution can be made shorter (less lines of code). Thanks for your patience.
Totally agree with you.
Thank you for solving problem.
Merged as c854f6a3d6d00fd57ba5ad120800d64439b608ee. Thanks for your contribution! :smiley_cat:
Hi, nice plugin I like it. But I've got a problem.
I use jedi.vim which is auto complete for Python. I've Downloaded
jedi.vim
to~/.vim/ftbundle/python/
and then open python file. Butjedi.vim
did not work at GUI MacVim.app. (CUI MacVim works well)unbundle.vim did not load
autocmd FileType
when ftbundle plugin loaded.jedi.vim
definedautocmd FileType python
at https://github.com/davidhalter/jedi-vim/blob/master/plugin/jedi.vim#L49 (One of the example usingautocmd FileType
)IMHO unbundle.vim is heavily related with filetype. A lot of FileType plugin defined
autocmd FileType
.So, I add
FileType
todoautoall
.Please check and include.
Regards,