2012-07-11 7 views
6

Bazı komut b:undo_ftplugin tanımlamazlar. cpo seçenek varsayılan değeri aABceFs.

zaman set ft=python ardından set ft=css. $VIMRUNTIME/ftplugin/css.vim hemen tamamla. Ve her zaman omnifunc=pythoncomplete#Complete.

her ftplugin/name.vimb:undo_ftplugin tanımlamanız gerekir mıdır?


Bu /usr/share/vim/vim73/ftplugin.vim geçerli:

" Vim support file to switch on loading plugins for file types 
" 
" Maintainer: Bram Moolenaar <[email protected]> 
" Last change: 2006 Apr 30 

if exists("did_load_ftplugin") 
    finish 
endif 
let did_load_ftplugin = 1 

augroup filetypeplugin 
    au FileType * call s:LoadFTPlugin() 

    func! s:LoadFTPlugin() 
    if exists("b:undo_ftplugin") 
     exe b:undo_ftplugin 
     unlet! b:undo_ftplugin b:did_ftplugin 
    endif 

    let s = expand("<amatch>") 
    if s != "" 
     if &cpo =~# "S" && exists("b:did_ftplugin") 
     " In compatible mode options are reset to the global values, need to 
     " set the local values also when a plugin was already used. 
     unlet b:did_ftplugin 
     endif 

     " When there is a dot it is used to separate filetype names. Thus for 
     " "aaa.bbb" load "aaa" and then "bbb". 
     for name in split(s, '\.') 
     exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim' 
     endfor 
    endif 
    endfunc 
augroup END 

Bu /usr/share/vim/vim73/ftplugin/css.vim geçerli:

" Vim filetype plugin file 
" Language:   CSS 
" Maintainer:  Nikolai Weibull <[email protected]> 
" Latest Revision: 2008-07-09 

if exists("b:did_ftplugin") 
    finish 
endif 
let b:did_ftplugin = 1 

let s:cpo_save = &cpo 
set cpo&vim 

let b:undo_ftplugin = "setl com< cms< inc< fo< ofu<" 

setlocal comments=s1:/*,mb:*,ex:*/ commentstring& 
setlocal formatoptions-=t formatoptions+=croql 
setlocal omnifunc=csscomplete#CompleteCSS 

let &l:include = '^\s*@import\s\+\%(url(\)\=' 

let &cpo = s:cpo_save 
unlet s:cpo_save 

ben set ft=python ardından set ft=css. böylece ftplugin/css.vim bitirmek hemen

if &cpo =~# "S" && exists("b:did_ftplugin") 

b:did_ftplugin silinmiş almaz: Vim bu testi geçemez.

cevap

7

:help undo_ftplugin bahseder:

kullanıcı yapar

": setfiletype xyz" Önceki filetype etkisini geri alınmalıdır.

Not onu söylüyor "gereken" değil, "zorunluluk". Ama, uygulama

func! s:LoadFTPlugin() 
    if exists("b:undo_ftplugin") 
     exe b:undo_ftplugin 
     unlet! b:undo_ftplugin b:did_ftplugin 
    endif 

göre bir ftplugin b:undo_ftplugin tanımlamalıdır, ya da filetype ayarları :setf aracılığıyla artık değiştirilemez. Belgelerin bunu göstermesi gerektiğini düşünüyorum ve tüm ftplugins gerçekten b:undo_ftplugin'u (sadece boş, no-op değerine) ayarlamalıdır.

İlgili konular