first commit

This commit is contained in:
2021-08-29 00:05:19 +08:00
commit 6574151a51
45 changed files with 13483 additions and 0 deletions

242
plugin/NERD_tree.vim Normal file
View File

@@ -0,0 +1,242 @@
" ============================================================================
" File: NERD_tree.vim
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
"
" SECTION: Script init stuff {{{1
"============================================================
if exists("loaded_nerd_tree")
finish
endif
if v:version < 700
echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!"
finish
endif
let loaded_nerd_tree = 1
"for line continuation - i.e dont want C in &cpo
let s:old_cpo = &cpo
set cpo&vim
"Function: s:initVariable() function {{{2
"This function is used to initialise a given variable to a given value. The
"variable is only initialised if it does not exist prior
"
"Args:
"var: the name of the var to be initialised
"value: the value to initialise var to
"
"Returns:
"1 if the var is set, 0 otherwise
function! s:initVariable(var, value)
if !exists(a:var)
exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
return 1
endif
return 0
endfunction
"SECTION: Init variable calls and other random constants {{{2
call s:initVariable("g:NERDTreeAutoCenter", 1)
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
call s:initVariable("g:NERDTreeNaturalSort", 0)
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
call s:initVariable("g:NERDTreeChDirMode", 0)
call s:initVariable("g:NERDTreeCreatePrefix", "silent")
call s:initVariable("g:NERDTreeMinimalUI", 0)
if !exists("g:NERDTreeIgnore")
let g:NERDTreeIgnore = ['\~$']
endif
call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
call s:initVariable("g:NERDTreeBookmarksSort", 1)
call s:initVariable("g:NERDTreeHighlightCursorline", 1)
call s:initVariable("g:NERDTreeHijackNetrw", 1)
call s:initVariable('g:NERDTreeMarkBookmarks', 1)
call s:initVariable("g:NERDTreeMouseMode", 1)
call s:initVariable("g:NERDTreeNotificationThreshold", 100)
call s:initVariable("g:NERDTreeQuitOnOpen", 0)
call s:initVariable("g:NERDTreeRespectWildIgnore", 0)
call s:initVariable("g:NERDTreeShowBookmarks", 0)
call s:initVariable("g:NERDTreeShowFiles", 1)
call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
if !nerdtree#runningWindows() && !nerdtree#runningCygwin()
call s:initVariable("g:NERDTreeDirArrowExpandable", "▸")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾")
else
call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
endif
let g:NERDTreeOldSortOrder = []
call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")
" ASCII 160: non-breaking space used to delimit items in the tree's nodes.
call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0")
if !exists('g:NERDTreeStatusline')
"the exists() crap here is a hack to stop vim spazzing out when
"loading a session that was created with an open nerd tree. It spazzes
"because it doesnt store b:NERDTree(its a b: var, and its a hash)
let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}"
endif
call s:initVariable("g:NERDTreeWinPos", "left")
call s:initVariable("g:NERDTreeWinSize", 31)
"init the shell commands that will be used to copy nodes, and remove dir trees
"
"Note: the space after the command is important
if nerdtree#runningWindows()
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ')
call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ')
call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ')
else
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ')
call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')
endif
"SECTION: Init variable calls for key mappings {{{2
call s:initVariable("g:NERDTreeMapActivateNode", "o")
call s:initVariable("g:NERDTreeMapChangeRoot", "C")
call s:initVariable("g:NERDTreeMapChdir", "cd")
call s:initVariable("g:NERDTreeMapCloseChildren", "X")
call s:initVariable("g:NERDTreeMapCloseDir", "x")
call s:initVariable("g:NERDTreeMapDeleteBookmark", "D")
call s:initVariable("g:NERDTreeMapMenu", "m")
call s:initVariable("g:NERDTreeMapHelp", "?")
call s:initVariable("g:NERDTreeMapJumpFirstChild", "K")
call s:initVariable("g:NERDTreeMapJumpLastChild", "J")
call s:initVariable("g:NERDTreeMapJumpNextSibling", "<C-j>")
call s:initVariable("g:NERDTreeMapJumpParent", "p")
call s:initVariable("g:NERDTreeMapJumpPrevSibling", "<C-k>")
call s:initVariable("g:NERDTreeMapJumpRoot", "P")
call s:initVariable("g:NERDTreeMapOpenExpl", "e")
call s:initVariable("g:NERDTreeMapOpenInTab", "t")
call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T")
call s:initVariable("g:NERDTreeMapOpenRecursively", "O")
call s:initVariable("g:NERDTreeMapOpenSplit", "i")
call s:initVariable("g:NERDTreeMapOpenVSplit", "s")
call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode)
call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit)
call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit)
call s:initVariable("g:NERDTreeMapQuit", "q")
call s:initVariable("g:NERDTreeMapRefresh", "r")
call s:initVariable("g:NERDTreeMapRefreshRoot", "R")
call s:initVariable("g:NERDTreeMapToggleBookmarks", "B")
call s:initVariable("g:NERDTreeMapToggleFiles", "F")
call s:initVariable("g:NERDTreeMapToggleFilters", "f")
call s:initVariable("g:NERDTreeMapToggleHidden", "I")
call s:initVariable("g:NERDTreeMapToggleZoom", "A")
call s:initVariable("g:NERDTreeMapUpdir", "u")
call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
call s:initVariable("g:NERDTreeMapCWD", "CD")
"SECTION: Load class files{{{2
call nerdtree#loadClassFiles()
" SECTION: Commands {{{1
"============================================================
call nerdtree#ui_glue#setupCommands()
" SECTION: Auto commands {{{1
"============================================================
augroup NERDTree
"Save the cursor position whenever we close the nerd tree
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif"
"disallow insert mode in the NERDTree
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
augroup END
if g:NERDTreeHijackNetrw
augroup NERDTreeHijackNetrw
autocmd VimEnter * silent! autocmd! FileExplorer
au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand("<amatch>"))
augroup END
endif
" SECTION: Public API {{{1
"============================================================
function! NERDTreeAddMenuItem(options)
call g:NERDTreeMenuItem.Create(a:options)
endfunction
function! NERDTreeAddMenuSeparator(...)
let opts = a:0 ? a:1 : {}
call g:NERDTreeMenuItem.CreateSeparator(opts)
endfunction
function! NERDTreeAddSubmenu(options)
return g:NERDTreeMenuItem.Create(a:options)
endfunction
function! NERDTreeAddKeyMap(options)
call g:NERDTreeKeyMap.Create(a:options)
endfunction
function! NERDTreeRender()
call nerdtree#renderView()
endfunction
function! NERDTreeFocus()
if g:NERDTree.IsOpen()
call g:NERDTree.CursorToTreeWin()
else
call g:NERDTreeCreator.ToggleTabTree("")
endif
endfunction
function! NERDTreeCWD()
if empty(getcwd())
call nerdtree#echoWarning('current directory does not exist')
return
endif
try
let l:cwdPath = g:NERDTreePath.New(getcwd())
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echoWarning('current directory does not exist')
return
endtry
call NERDTreeFocus()
if b:NERDTree.root.path.equals(l:cwdPath)
return
endif
let l:newRoot = g:NERDTreeFileNode.New(l:cwdPath, b:NERDTree)
call b:NERDTree.changeRoot(l:newRoot)
normal! ^
endfunction
function! NERDTreeAddPathFilter(callback)
call g:NERDTree.AddPathFilter(a:callback)
endfunction
" SECTION: Post Source Actions {{{1
call nerdtree#postSourceActions()
"reset &cpo back to users setting
let &cpo = s:old_cpo
" vim: set sw=4 sts=4 et fdm=marker:

1118
plugin/asyncrun.vim Normal file

File diff suppressed because it is too large Load Diff

132
plugin/buffergator.vim Normal file
View File

@@ -0,0 +1,132 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Buffergator
""
"" Vim document buffer navigation utility
""
"" Copyright 2011 Jeet Sukumaran.
""
"" 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 3 of the License, or
"" (at your option) any later version.
""
"" This program is distributed in the hope that it will be useful,
"" but WITHOUT ANY WARRANTY; without even the implied warranty of
"" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
"" GNU General Public License <http://www.gnu.org/licenses/>
"" for more details.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Reload and Compatibility Guard <<FOLD<<
" ============================================================================
" Reload protection.
if (exists('g:did_buffergator') && g:did_buffergator) || &cp || version < 700
finish
endif
let g:did_buffergator = 1
" avoid line continuation issues (see ':help user_41.txt')
let s:save_cpo = &cpo
set cpo&vim
" >>FOLD>>
" Global MRU Initialization <<FOLD<<
" ==============================================================================
" Moves (or adds) the given buffer number to the top of the list
if !exists("g:buffergator_mru_cycle_loop")
let g:buffergator_mru_cycle_loop = 1
endif
let g:buffergator_track_mru = 1
let g:buffergator_mru = []
function! BuffergatorUpdateMRU(acmd_bufnr)
if len(g:buffergator_mru) < 1 " maybe should be 2?
if g:buffergator_mru_cycle_loop
let g:buffergator_mru = []
for l:bni in range(bufnr("$"), 1, -1)
if buflisted(l:bni)
\ && getbufvar(l:bni, "&filetype") != "netrw"
call add(g:buffergator_mru, l:bni)
endif
endfor
endif
endif
if !exists("w:buffergator_mru")
let w:buffergator_mru = g:buffergator_mru[:]
endif
if g:buffergator_track_mru
let bnum = a:acmd_bufnr + 0
" if bnum == 0 || !buflisted(bnum) || !(empty(getbufvar(bnum, "netrw_browser_active")))
if bnum == 0 || !buflisted(bnum) || getbufvar(bnum, "&filetype") == "netrw"
return
endif
call filter(g:buffergator_mru, 'v:val !=# bnum')
call insert(g:buffergator_mru, bnum, 0)
call filter(w:buffergator_mru, 'v:val !=# bnum')
call insert(w:buffergator_mru, bnum, 0)
endif
endfunction
" Autocommands that update the most recenly used buffers
augroup BuffergatorMRU
au!
autocmd BufEnter * call BuffergatorUpdateMRU(expand('<abuf>'))
autocmd BufRead * call BuffergatorUpdateMRU(expand('<abuf>'))
autocmd BufNewFile * call BuffergatorUpdateMRU(expand('<abuf>'))
autocmd BufWritePost * call BuffergatorUpdateMRU(expand('<abuf>'))
augroup NONE
" >>FOLD>>
" Public Command and Key Maps <<FOLD<<
" ==============================================================================
" command! -nargs=0 BuffergatorToggle :call buffergator#ToggleBuffergator()
" command! -nargs=0 BuffergatorClose :call buffergator#CloseBuffergator()
" command! -nargs=0 BuffergatorOpen :call buffergator#OpenBuffergator()
" command! -nargs=0 BuffergatorTabsToggle :call buffergator#ToggleBuffergatorTabs()
" command! -nargs=0 BuffergatorTabsOpen :call buffergator#OpenBuffergatorTabs()
" command! -nargs=0 BuffergatorTabsClose :call buffergator#CloseBuffergatorTabs()
" command! -nargs=0 BuffergatorUpdate :call buffergator#UpdateBuffergator('',-1)
" command! -nargs=* BuffergatorMruCyclePrev :call buffergator#BuffergatorCycleMru(-1, "<args>")
" command! -nargs=* BuffergatorMruCycleNext :call buffergator#BuffergatorCycleMru(1, "<args>")
" command! -nargs=? -bang BuffergatorMruList :call buffergator#BuffergatorEchoMruList('<bang>')
" if !exists('g:buffergator_suppress_keymaps') || !g:buffergator_suppress_keymaps
" " nnoremap <silent> <Leader><Leader> :BuffergatorToggle<CR>
" nnoremap <silent> <Leader>b :BuffergatorOpen<CR>
" nnoremap <silent> <Leader>B :BuffergatorClose<CR>
" nnoremap <silent> <Leader>t :BuffergatorTabsOpen<CR>
" nnoremap <silent> <Leader>to :BuffergatorTabsOpen<CR>
" nnoremap <silent> <Leader>tc :BuffergatorTabsClose<CR>
" nnoremap <silent> <Leader>T :BuffergatorTabsClose<CR>
" if !exists('g:buffergator_suppress_mru_switching_keymaps') || !g:buffergator_suppress_mru_switching_keymaps
" nnoremap <silent> <M-b> :BuffergatorMruCyclePrev<CR>
" nnoremap <silent> <M-S-b> :BuffergatorMruCycleNext<CR>
" if !exists('g:buffergator_keep_old_mru_switching_keymaps') || !g:buffergator_keep_old_mru_switching_keymaps
" nnoremap <silent> gb :BuffergatorMruCyclePrev<CR>
" nnoremap <silent> gB :BuffergatorMruCycleNext<CR>
" else
" nnoremap <silent> [b :BuffergatorMruCyclePrev<CR>
" nnoremap <silent> ]b :BuffergatorMruCycleNext<CR>
" endif
" endif
" if !exists('g:buffergator_suppress_mru_switch_into_splits_keymaps') || !g:buffergator_suppress_mru_switch_into_splits_keymaps
" nnoremap <silent> <Leader><LEFT> :BuffergatorMruCyclePrev leftabove vert sbuffer<CR>
" nnoremap <silent> <Leader><UP> :BuffergatorMruCyclePrev leftabove sbuffer<CR>
" nnoremap <silent> <Leader><RIGHT> :BuffergatorMruCyclePrev rightbelow vert sbuffer<CR>
" nnoremap <silent> <Leader><DOWN> :BuffergatorMruCyclePrev rightbelow sbuffer<CR>
" nnoremap <silent> <Leader><S-LEFT> :BuffergatorMruCycleNext leftabove vert sbuffer<CR>
" nnoremap <silent> <Leader><S-UP> :BuffergatorMruCycleNext leftabove sbuffer<CR>
" nnoremap <silent> <Leader><S-RIGHT> :BuffergatorMruCycleNext rightbelow vert sbuffer<CR>
" nnoremap <silent> <Leader><S-DOWN> :BuffergatorMruCycleNext rightbelow sbuffer<CR>
" endif
" endif
" >>FOLD>>
" Restore State <<FOLD<<
" ============================================================================
" restore options
let &cpo = s:save_cpo
" >>FOLD>>
" vim:foldlevel=4:

66
plugin/template.vim Normal file
View File

@@ -0,0 +1,66 @@
" File: template.vim
" Author: Wonder <wonderbeyond@gmail.com>
" Description:
" Generates template for new files.
" 这里主要根据文件名加载模板, 而不是根据 vim 识别到的文件类型.
" .c 和 .h 文件可能会被识别为相同类型, 显然它们需要不同的模板.
" Rules:
" *先看整个文件名(不含路径), 再看扩展名.
" 例如 main.cc 文件中会定义 main 函数, 其他 .cc 文件则未必然.
" *先看是否有普通的静态模板, 再看是否有动态模板.
if exists("g:enable_template") && g:enable_template == 1 && exists("g:template_dir")
augroup Template_Generator
autocmd! Template_Generator
autocmd BufNewFile * call Read_template()
augroup END
else
finish
endif
let s:common_tpl_dir = g:template_dir . "/common"
let s:dynamic_tpl_dir = g:template_dir . "/dynamic"
function! Read_template()
let filename = expand("%:t")
let extname = expand("%:e")
" 先检查是否存在[普通的][全名]匹配模板(例如 main.cc).
let common_tpl_file = expand(s:common_tpl_dir . "/full/" . filename)
if filereadable(common_tpl_file)
call Read_template_file(common_tpl_file)
return
endif
" 再检查是否存在[动态的][全名]匹配模板.
let dynamic_template_generator = expand(s:dynamic_tpl_dir . "/full/" .filename)
if executable(dynamic_template_generator)
call Read_dynamic_template(dynamic_template_generator, filename)
return
endif
" 再检查是否存在[普通的][后缀]匹配模板.
let common_tpl_file = expand(s:common_tpl_dir . "/ext/" . extname)
if filereadable(common_tpl_file)
call Read_template_file(common_tpl_file)
return
endif
" 最后检查是否存在[动态的][后缀]匹配模板.
let dynamic_template_generator = expand(s:dynamic_tpl_dir . "/ext/" . extname)
if executable(dynamic_template_generator)
call Read_dynamic_template(dynamic_template_generator, filename)
return
endif
endfunction
function! Read_template_file(filename)
silent execute "0r " . a:filename
endfunction
" 读取模板生成器动态生成的模板.
" generator参数指定生成器程序的路径.
" 同时还把文件名传递给生成器.
function! Read_dynamic_template(generator, filename)
silent execute "0r !" . a:generator . " " . a:filename
endfunction