Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Trinity v2.0

Support the Named Buffer Version of Source Explorer (v5.1 and above)
  • Loading branch information...
commit 5429ba402407b227e6869a48cdc52072e6a023d4 1 parent aa72704
Wenlong Che authored
Showing with 201 additions and 110 deletions.
  1. +2 −0  .gitignore
  2. +53 −32 NERD_tree.vim
  3. +59 −0 readme.md
  4. +87 −78 trinity.vim
2  .gitignore
View
@@ -0,0 +1,2 @@
+*.swp
+tags
85 NERD_tree.vim
View
@@ -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
@@ -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
@@ -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
@@ -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
59 readme.md
View
@@ -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).
165 trinity.vim
View
@@ -1,14 +1,20 @@
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
-" File Name: trinity.vim
-" Abstract: A (G)VIM plugin which build the trinity of Source Explorer,
-" TagList and NERD tree to be an IDE for software development.
-" Author: CHE Wenlong <wenlong.che@gmail.com>
-" Version: 1.6
-" Last Change: February 23, 2012
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" "
+" File Name: Trinity "
+" Abstract: A (G)Vim plugin for building 'Source Explorer', 'Taglist' and "
+" 'NERD tree' into an IDE which works like the "Source Insignt". "
+" Authors: Wenlong Che <wenlong.che@gmail.com> "
+" Homepage: http://www.vim.org/scripts/script.php?script_id=2347 "
+" GitHub: https://github.com/wesleyche/Trinity "
+" Version: 2.0 "
+" Last Change: September 16th, 2012 "
+" Licence: This program is free software; you can redistribute it and / or "
+" modify it under the terms of the GNU General Public License as "
+" published by the Free Software Foundation; either version 2, or "
+" any later version. "
+" "
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Avoid reloading {{{
@@ -30,7 +36,7 @@ set cpoptions&vim
if v:version < 700
" Tell the user what has happened
echohl ErrorMsg
- echo "Trinity: Require VIM 7.0 or above for running the Trinity."
+ echo "Require VIM 7.0 or above for running the Trinity."
echohl None
finish
endif
@@ -72,7 +78,7 @@ command! -nargs=0 -bar TrinityUpdateWindow
let s:Trinity_switch = 0
let s:Trinity_tabPage = 0
let s:Trinity_isDebug = 0
-let s:Trinity_logPath = "./trinity.log"
+let s:Trinity_logPath = '~/trinity.log'
let s:tag_list_switch = 0
let s:tag_list_title = "__Tag_List__"
@@ -118,7 +124,7 @@ function! <SID>Trinity_InitSourceExplorer()
" // Set the height of Source Explorer window "
let g:SrcExpl_winHeight = 8
- " // Set 100 ms for refreshing the Source Explorer "
+ " // Set 1 ms for refreshing the Source Explorer "
let g:SrcExpl_refreshTime = 1
" // Set "Enter" key to jump into the exact definition context "
let g:SrcExpl_jumpKey = "<ENTER>"
@@ -128,9 +134,9 @@ function! <SID>Trinity_InitSourceExplorer()
" // are using buffers. And you need add their bufname into the list below "
" // according to the command ":buffers!" "
let g:SrcExpl_pluginList = [
- \ "__Tag_List__",
- \ "_NERD_tree_",
- \ "Source_Explorer"
+ \ s:tag_list_title,
+ \ s:nerd_tree_title,
+ \ s:source_explorer_title
\ ]
" // Enable/Disable the local definition searching, and note that this is not "
" // guaranteed to work, the Source Explorer doesn't check the syntax for now. "
@@ -183,44 +189,50 @@ function! <SID>Trinity_Debug(log)
endfunction " }}}
-" Trinity_GetEditWinNR() {{{
+" Trinity_GetEditWin() {{{
-" Get the edit window NR
+" Get the edit window number
-function! <SID>Trinity_GetEditWinNR()
+function! <SID>Trinity_GetEditWin()
let l:i = 1
let l:j = 1
+ let l:srcexplWin = 0
let l:pluginList = [
\ s:tag_list_title,
\ s:source_explorer_title,
\ s:nerd_tree_title
\]
- while 1
-
- for item in l:pluginList
- if bufname(winbufnr(l:i)) ==# item
- \ || getwinvar(l:i, '&previewwindow')
- break
+ 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:j += 1
+ let l:i += 1
+ let l:j = 0
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
+ if l:i > winnr("$")
+ return -1
+ endif
+ endwhile
+ endtry
endfunction " }}}
@@ -230,48 +242,41 @@ endfunction " }}}
function! <SID>Trinity_UpdateWindow()
- let l:i = 1
- let l:rtn = -1
-
- let l:tag_list_winnr = 0
let l:source_explorer_winnr = 0
- let l:nerd_tree_winnr = 0
-
- while 1
-
- if bufname(winbufnr(l:i)) ==# s:tag_list_title
- let l:tag_list_winnr = l:i
- endif
-
- if bufname(winbufnr(l:i)) ==# s:source_explorer_title
- \ || getwinvar(l:i, '&previewwindow')
- let l:source_explorer_winnr = l:i
+ try
+ " For Named Buffer Version
+ let l:source_explorer_winnr = g:SrcExpl_GetWin()
+ catch
+ finally
+ " For Preview Window Version
+ if l:source_explorer_winnr == 0
+ let l:i = 1
+ while 1
+ if bufname(winbufnr(l:i)) ==# s:source_explorer_title
+ \ || getwinvar(l:i, '&previewwindow')
+ let l:source_explorer_winnr = l:i
+ break
+ endif
+ let l:i += 1
+ if l:i > winnr("$")
+ break
+ endif
+ endwhile
endif
- if bufname(winbufnr(l:i)) ==# s:nerd_tree_title
- let l:nerd_tree_winnr = l:i
+ if l:source_explorer_winnr > 0
+ silent! exe l:source_explorer_winnr . "wincmd " . "w"
+ silent! exe "wincmd " . "J"
+ silent! exe g:SrcExpl_winHeight . " wincmd " . "_"
endif
- let l:i += 1
- if l:i > winnr("$")
- break
+ let l:rtn = <SID>Trinity_GetEditWin()
+ if l:rtn < 0
+ return
endif
- endwhile
-
- if l:source_explorer_winnr > 0
- silent! exe l:source_explorer_winnr . "wincmd " . "w"
- silent! exe "wincmd " . "J"
- silent! exe g:SrcExpl_winHeight . " wincmd " . "_"
- endif
-
- let l:rtn = <SID>Trinity_GetEditWinNR()
-
- if l:rtn < 0
- return
- endif
-
- silent! exe l:rtn . "wincmd w"
+ silent! exe l:rtn . "wincmd w"
+ endtry
endfunction " }}}
@@ -304,12 +309,14 @@ function! <SID>Trinity_ToggleNERDTree()
if s:Trinity_tabPage == 0
let s:Trinity_tabPage = tabpagenr()
endif
+
if s:Trinity_tabPage != tabpagenr()
echohl ErrorMsg
- echo "Trinity: Not support multiple tab pages for now."
+ echo "Trinity: Not support multiple tab pages for now."
echohl None
return
endif
+
call <SID>Trinity_UpdateStatus()
if s:Trinity_switch == 0
if s:nerd_tree_switch == 0
@@ -348,7 +355,7 @@ function! <SID>Trinity_ToggleSourceExplorer()
endif
if s:Trinity_tabPage != tabpagenr()
echohl ErrorMsg
- echo "Trinity: Not support multiple tab pages for now."
+ echo "Trinity: Not support multiple tab pages for now."
echohl None
return
endif
@@ -390,7 +397,7 @@ function! <SID>Trinity_ToggleTagList()
endif
if s:Trinity_tabPage != tabpagenr()
echohl ErrorMsg
- echo "Trinity: Not support multiple tab pages for now."
+ echo "Trinity: Not support multiple tab pages for now."
echohl None
return
endif
@@ -431,12 +438,14 @@ function! <SID>Trinity_Toggle()
if s:Trinity_tabPage == 0
let s:Trinity_tabPage = tabpagenr()
endif
+
if s:Trinity_tabPage != tabpagenr()
echohl ErrorMsg
- echo "Trinity: Not support multiple tab pages for now."
+ echo "Trinity: Not support multiple tab pages for now."
echohl None
return
endif
+
if s:Trinity_switch == 1
if s:tag_list_switch == 1
TlistClose
Please sign in to comment.
Something went wrong with that request. Please try again.