Skip to content

Commit

Permalink
Trinity v2.0
Browse files Browse the repository at this point in the history
Support the Named Buffer Version of Source Explorer (v5.1 and above)
  • Loading branch information
wenlongche committed Sep 18, 2012
1 parent aa72704 commit 5429ba4
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 110 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.swp
tags
85 changes: 53 additions & 32 deletions NERD_tree.vim
Expand Up @@ -1836,14 +1836,14 @@ function! s:CreateTreeWin()
let splitLocation = (g:NERDTreeWinPos == "top" || g:NERDTreeWinPos == "left") ? "topleft " : "botright "
let splitMode = s:ShouldSplitVertically() ? "vertical " : ""
let splitSize = g:NERDTreeWinSize
" CHE Wenlong delete for trinity.vim
" Wenlong Che delete for trinity.vim
" Begin
" let t:NERDTreeWinName = localtime() . s:NERDTreeWinName
" End
" CHE Wenlong add for trinity.vim
" Wenlong Che add for trinity.vim
" Begin
let t:NERDTreeWinName = s:NERDTreeWinName
" End
" End
let cmd = splitLocation . splitMode . splitSize . ' new ' . t:NERDTreeWinName
silent! execute cmd

Expand Down Expand Up @@ -2332,22 +2332,22 @@ function! s:OpenFileNode(treenode)
if winnr != -1
exec winnr . "wincmd w"

" CHE Wenlong delete for trinity.vim
" Wenlong Che delete for trinity.vim
" Begin
" elseif s:ShouldSplitToOpen(winnr("#"))
" call s:OpenFileNodeSplit(a:treenode)
" End
else
" CHE Wenlong add for trinity.vim
" Wenlong Che add for trinity.vim
" Begin
let l:rtn = s:GetEditWinNR()
let l:rtn = s:GetEditWin()
if l:rtn < 0
return
endif
silent! exe l:rtn . "wincmd w"
" End
try
" CHE Wenlong delete for trinity.vim
" Wenlong Che delete for trinity.vim
" Begin
" wincmd p
" End
Expand Down Expand Up @@ -2889,7 +2889,7 @@ endfunction
"FUNCTION: s:BindMappings() {{{2
function! s:BindMappings()
" set up mappings and commands for this buffer
" CHE Wenlong delete for trinity.vim
" Wenlong Che delete for trinity.vim
" Begin
" nnoremap <silent> <buffer> <middlerelease> :call <SID>HandleMiddleMouse()<cr>
" End
Expand Down Expand Up @@ -3578,34 +3578,55 @@ function! s:UpDir(keepState)
endif
endfunction

" CHE Wenlong add for trinity.vim
" Wenlong Che add for trinity.vim
" Begin
function! s:GetEditWinNR()
let s:Trinity_pluginList = [
\ "__Tag_List__",
\ "_NERD_tree_",
\ "Source_Explorer"
\ ]

function! s:GetEditWin()

let l:i = 1
let l:j = 1

let l:srcexplWin = 0
let l:pluginList = [
\ "__Tag_List__",
\ "_NERD_tree_",
\ "Source_Explorer"
\]
while 1
for item in l:pluginList
if bufname(winbufnr(l:i)) ==# item || getwinvar(l:i, '&previewwindow')
break
else
let l:j += 1
endif
endfor
if j >= len(l:pluginList)
return l:i
else
let l:i += 1
let l:j = 0
endif
if l:i > winnr("$")
return -1
endif
endwhile
\ "__Tag_List__",
\ "_NERD_tree_",
\ "Source_Explorer"
\ ]

try
let l:srcexplWin = g:SrcExpl_GetWin()
catch
finally
while 1
" compatible for Named Buffer Version and Preview Window Version
for item in l:pluginList
if (bufname(winbufnr(l:i)) ==# item)
\ || (l:srcexplWin == 0 && getwinvar(l:i, '&previewwindow'))
\ || (l:srcexplWin == l:i)
break
else
let l:j += 1
endif
endfor

if l:j >= len(l:pluginList)
return l:i
else
let l:i += 1
let l:j = 0
endif

if l:i > winnr("$")
return -1
endif
endwhile
endtry

endfunction
" End

Expand Down
59 changes: 59 additions & 0 deletions readme.md
@@ -0,0 +1,59 @@
**Trinity**
===========

The Trinity plugin manages Source Explorer, Taglist and NERD Tree. The below
shows my work platform with Trinity.

Features
========

* Automatic Display of Declarations in the Context Window on the bottom in the (G)VIM window using the Source Explorer:
http://www.vim.org/scripts/script.php?script_id=2179

* Symbol Windows For Each File on the left in the (G)VIM window (G)VIM using the script named 'taglist.vim':
http://www.vim.org/scripts/script.php?script_id=273

* Quick Access to All Files on the right in the (G)VIM window using the script named 'The NERD tree(NERD_tree.vim)':
http://www.vim.org/scripts/script.php?script_id=1658

Installation
============

1. Place the Trinity files (trinity.vim and NERD_tree.vim) in your Vim directory (such as ~/.vim)
or have it installed by a bundle manager like Vundle or NeoBundle.
2. Open the three plugins together with *:TrinityToggleAll* or map these
commands to keys in your .vimrc (Settings Example)

Requirements
------------
Trinity requires:
* Vim 7.0 or higher

Screenshots
===========

Left window is Taglist, Bottom window is Source Explorer, and Right window is NERD tree
---------------------
![One Declaration Found](http://i.imgur.com/bbGVO.jpg)

Settings Example
================
```vim
" Open and close all the three plugins on the same time
nmap <F8> :TrinityToggleAll<CR>
" Open and close the Source Explorer separately
nmap <F9> :TrinityToggleSourceExplorer<CR>
" Open and close the Taglist separately
nmap <F10> :TrinityToggleTagList<CR>
" Open and close the NERD tree separately
nmap <F11> :TrinityToggleNERDTree<CR>
```

Changelog
=========
2.0
- Support the Named Buffer Version of Source Explorer (v5.1 and above).

0 comments on commit 5429ba4

Please sign in to comment.