分页: 1 / 1

集成winmanager 和 NERDTree

发表于 : 2009-10-29 10:12
lich0079
NERDTree是个好插件 但如果同时使用它 又使用taglist的话 就不方便 所以想集成winmanager 和 NERDTree

winmanager的doc说是可以放入其他的插件的,但要提供一个全局变量名

In addition to registering, the plugin itself initializes a variable called
the "title" which starts with the name, such as: >

" this line goes in your script file.
let g:YourPlugin_title = "[My Plugin Title]"

还要提供几个方法
The following is a list of hooks which should be provided. A few of them are
optional. Consider the case where you want to add a plugin which you have
named "YourPlugin". In the following discussion, a "hook" simply refers to a
globally visible function which is formed according to the rule that it start
with the string "YourPlugin_", where "YourPlugin" is the name of your plugin.

*winmanager-hook-start*
YourPlugin_Start() This function is called during initialization. It
{Mandatory} can be assumed (and _should_ be) that the focus is
already in the buffer where stuff needs to be
displayed. i.e, the plugin shouldnt open some other
buffer during this function. (i.e, commands such as
":e", ":vsplit", ":wincmd h" etc in this stage are
bad. If however, you absolutely need to switch
buffers or something which will cause |BufEnter| or
|BufDelete| events, then you need to temporarily
switch winmanager off by using
|WinManagerSuspendAUs|)

*winmanager-hook-isvalid*
YourPlugin_IsValid() winmanager is dynamic in the sense that it allows the
{Mandatory} plugins to change their displays when a BufEnter event
occurs. At each BufEnter event, winmanager will cycle
through all the visible explorers asking them if
their display is "valid". If it isn't, then they will
be redrawn by calling the next function.

For plugins such as bufexplorer which change with
every BufEnter, it is sufficient to make this always
return 1. For plugins such as fileexplorer, the
display never changes with the BufEnter even. hence
in its case, it will always return 0

我看了他自己的filebrowser,是这么写的

" -- stuff used by winmanager
let g:FileExplorer_title = "[File List]"
function! FileExplorer_Start()
let b:displayMode = "winmanager"
if exists('s:lastDirectoryDisplayed')
call s:EditDir(s:lastDirectoryDisplayed)
else
call s:EditDir(expand("%:p:h"))
end
if exists('s:lastCursorRow')
exe s:lastCursorRow
exe 'normal! '.s:lastCursorColumn.'|'
end
endfunction

function! FileExplorer_IsValid()
return 1
endfunction


所以我在配置文件中做了如下定义
let g:NERDTree_title = "[NERDTree]"
function! NERDTree_Start()
call g:NERDTree()
endfunction

function! NERDTree_IsValid()
return 1
endfunction

let g:winManagerWindowLayout='NERDTree|TagList'

但提示我
NERDTree() 是 unknown function 这里主要应该是我语法不对 我刚接触vim 那么帮我看下start里应该怎么写去调用NERDTree

Re: 集成winmanager 和 NERDTree

发表于 : 2009-11-09 9:43
lich0079
ding