mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
179 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
153041ac93 | ||
|
|
68cb5fc2eb | ||
|
|
ee7aafb135 | ||
|
|
b047d7f312 | ||
|
|
1537d42706 | ||
|
|
4b566f153f | ||
|
|
f34986d30f | ||
|
|
a713a86f06 | ||
|
|
08bc9870bc | ||
|
|
94e085f1a2 | ||
|
|
241f2e9dfe | ||
|
|
c864c6e463 | ||
|
|
bc55f3dda8 | ||
|
|
39a3a78729 | ||
|
|
31f65b97b1 | ||
|
|
3837ea85e0 | ||
|
|
fedd5f1162 | ||
|
|
dc108f555e | ||
|
|
93a0a422b4 | ||
|
|
e899bed4d7 | ||
|
|
87fbc2e5e4 | ||
|
|
cf61ad3285 | ||
|
|
f772cfdefb | ||
|
|
a1e7bc0b01 | ||
|
|
e5c79fc5c1 | ||
|
|
a3b05e8e38 | ||
|
|
89cfedd39b | ||
|
|
1be18ed53c | ||
|
|
e2265ec3b3 | ||
|
|
5ba3b3a5a8 | ||
|
|
6a513e4340 | ||
|
|
1ea2a0c29b | ||
|
|
3a163fca64 | ||
|
|
36e4402550 | ||
|
|
effb5d4de0 | ||
|
|
a854feeb1e | ||
|
|
cbb0a8698f | ||
|
|
d21b00c767 | ||
|
|
5311777308 | ||
|
|
7a5685af57 | ||
|
|
38e2bcaf85 | ||
|
|
0dda0ce5d7 | ||
|
|
8fc72fd352 | ||
|
|
dc3f1b5edf | ||
|
|
dd38ab8f43 | ||
|
|
7051977808 | ||
|
|
d9f315d63e | ||
|
|
5e9635dfa4 | ||
|
|
f2a9e9a360 | ||
|
|
1080246af9 | ||
|
|
fcb4ec0303 | ||
|
|
8211554efa | ||
|
|
464699215c | ||
|
|
10bb62a728 | ||
|
|
46710bfb25 | ||
|
|
fcb54eee12 | ||
|
|
a686be5c31 | ||
|
|
bd5e5d71b5 | ||
|
|
711c8e3328 | ||
|
|
ec1f7e3e6e | ||
|
|
8535a906be | ||
|
|
eef8a7b280 | ||
|
|
891f0ed3a2 | ||
|
|
e93bf0632b | ||
|
|
31c0ec6d63 | ||
|
|
fc3cb76695 | ||
|
|
389f33ea81 | ||
|
|
abc0cc4c40 | ||
|
|
1654ef820b | ||
|
|
df3485ec64 | ||
|
|
59257d7a3a | ||
|
|
a052a0db65 | ||
|
|
65dd1137da | ||
|
|
236d20946c | ||
|
|
a796715ac1 | ||
|
|
abfd4fef76 | ||
|
|
95acf7dd25 | ||
|
|
02b3cec827 | ||
|
|
c3a2f88b63 | ||
|
|
bc2a628a10 | ||
|
|
6518d1eb4c | ||
|
|
a2ead3545e | ||
|
|
a163f327eb | ||
|
|
e9d6a7209c | ||
|
|
f0290b08dd | ||
|
|
51637ec6d4 | ||
|
|
4d77c3ae45 | ||
|
|
a7f9abe827 | ||
|
|
41029aef24 | ||
|
|
c75a022a23 | ||
|
|
1acf6321a5 | ||
|
|
e164980d84 | ||
|
|
71ebe27a8d | ||
|
|
e7ebee3084 | ||
|
|
1239f78baf | ||
|
|
5f4c005771 | ||
|
|
9e0a0b6a43 | ||
|
|
5c85d28285 | ||
|
|
f65bc62fac | ||
|
|
9b12953343 | ||
|
|
84f9793231 | ||
|
|
1f46ecf4b8 | ||
|
|
eef90bf320 | ||
|
|
3796a8799a | ||
|
|
c726655d23 | ||
|
|
bdfac3e25c | ||
|
|
faf1459ce5 | ||
|
|
02751f4d11 | ||
|
|
992c9f24eb | ||
|
|
8164fa09d3 | ||
|
|
5e50601788 | ||
|
|
23e79de2c2 | ||
|
|
4accc8a79c | ||
|
|
7522cbf4f0 | ||
|
|
3a25a594ca | ||
|
|
40374e5056 | ||
|
|
4e4fb179e7 | ||
|
|
0f2effb049 | ||
|
|
63ee15ca6e | ||
|
|
f8a105d972 | ||
|
|
f2707106bd | ||
|
|
1586cfdb03 | ||
|
|
ca8b1d2b34 | ||
|
|
100d8d2a47 | ||
|
|
efe03d6988 | ||
|
|
7b59186dfe | ||
|
|
e9f403ac44 | ||
|
|
2038f38026 | ||
|
|
6e9a5d4cea | ||
|
|
495e906169 | ||
|
|
2e6cedcad7 | ||
|
|
d76f936698 | ||
|
|
0e9feaede3 | ||
|
|
cd55e2d522 | ||
|
|
3d2bf2d9ac | ||
|
|
2f4d1b93e8 | ||
|
|
f06d99f7b5 | ||
|
|
1b13fb05ea | ||
|
|
f90da509e1 | ||
|
|
c8afb6d92d | ||
|
|
b0950d1593 | ||
|
|
9f569c61f9 | ||
|
|
7874b3c60e | ||
|
|
99afbe9ec8 | ||
|
|
78aa2fa1db | ||
|
|
111e309507 | ||
|
|
7a86663128 | ||
|
|
6f24013463 | ||
|
|
d508c231b5 | ||
|
|
8f7e2bb98a | ||
|
|
39fc42d1cf | ||
|
|
7f6603ea4a | ||
|
|
3b1289ba40 | ||
|
|
6464cff113 | ||
|
|
4f5599e275 | ||
|
|
f98a3f9eab | ||
|
|
c9c67b5b67 | ||
|
|
3803db5555 | ||
|
|
a33849ef9b | ||
|
|
b09e0fbfa4 | ||
|
|
402fea6902 | ||
|
|
589036f5c9 | ||
|
|
d3b2258acb | ||
|
|
6103a308af | ||
|
|
8d20ae913a | ||
|
|
9fc7fb8d51 | ||
|
|
6da7f317a3 | ||
|
|
d0d755ff87 | ||
|
|
56b5446eaf | ||
|
|
88020835d6 | ||
|
|
d4b78be306 | ||
|
|
5ff836ed26 | ||
|
|
6b4dca7361 | ||
|
|
7ac998fafc | ||
|
|
888934a3be | ||
|
|
fb5ee9fbc2 | ||
|
|
b2c56e94c9 | ||
|
|
3e5faf9c56 | ||
|
|
b0297c5c91 |
79
Rakefile
79
Rakefile
@@ -1,18 +1,75 @@
|
||||
desc "Copy the vim/doc files into ~/.vim"
|
||||
task :deploy_local do
|
||||
run "cp plugin/NERD_tree.vim ~/.vim/plugin"
|
||||
run "cp doc/NERD_tree.txt ~/.vim/doc"
|
||||
end
|
||||
# written by travis jeffery <travisjeffery@gmail.com>
|
||||
# contributions by scrooloose <github:scrooloose>
|
||||
|
||||
require 'rake'
|
||||
require 'find'
|
||||
require 'pathname'
|
||||
|
||||
desc "Create a zip archive for release to vim.org"
|
||||
IGNORE = [/\.gitignore$/, /Rakefile$/]
|
||||
|
||||
files = `git ls-files`.split("\n")
|
||||
files.reject! { |f| IGNORE.any? { |re| f.match(re) } }
|
||||
|
||||
desc 'Zip up the project files'
|
||||
task :zip do
|
||||
abort "NERD_tree.zip already exists, aborting" if File.exist?("NERD_tree.zip")
|
||||
run "zip NERD_tree.zip plugin/NERD_tree.vim doc/NERD_tree.txt"
|
||||
zip_name = File.basename(File.dirname(__FILE__))
|
||||
zip_name.gsub!(/ /, '_')
|
||||
zip_name = "#{zip_name}.zip"
|
||||
|
||||
if File.exist?(zip_name)
|
||||
abort("Zip file #{zip_name} already exists. Remove it first.")
|
||||
end
|
||||
|
||||
puts "Creating zip file: #{zip_name}"
|
||||
system("zip #{zip_name} #{files.join(" ")}")
|
||||
end
|
||||
|
||||
def run(cmd)
|
||||
puts "Executing: #{cmd}"
|
||||
system cmd
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts "Installed #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Pulls from origin'
|
||||
task :pull do
|
||||
puts "Updating local repo..."
|
||||
system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull")
|
||||
end
|
||||
|
||||
desc 'Calls pull task and then install task'
|
||||
task :update => ['pull', 'install'] do
|
||||
puts "Update of vim script complete."
|
||||
end
|
||||
|
||||
desc 'Uninstall plugin and documentation'
|
||||
task :uninstall do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.rm target_file
|
||||
|
||||
puts "Uninstalled #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
task :default => ['update']
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
41
nerdtree_plugin/exec_menuitem.vim
Normal file
41
nerdtree_plugin/exec_menuitem.vim
Normal file
@@ -0,0 +1,41 @@
|
||||
" ============================================================================
|
||||
" File: exec_menuitem.vim
|
||||
" Description: plugin for NERD Tree that provides an execute file menu item
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 22 July, 2009
|
||||
" 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.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_exec_menuitem")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_exec_menuitem = 1
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': '(!)Execute file',
|
||||
\ 'shortcut': '!',
|
||||
\ 'callback': 'NERDTreeExecFile',
|
||||
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
|
||||
|
||||
function! NERDTreeExecFileActive()
|
||||
let node = g:NERDTreeFileNode.GetSelected()
|
||||
return !node.path.isDirectory && node.path.isExecutable
|
||||
endfunction
|
||||
|
||||
function! NERDTreeExecFile()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
echo "==========================================================\n"
|
||||
echo "Complete the command to execute (add arguments etc):\n"
|
||||
let cmd = treenode.path.str({'escape': 1})
|
||||
let cmd = input(':!', cmd . ' ')
|
||||
|
||||
if cmd != ''
|
||||
exec ':!' . cmd
|
||||
else
|
||||
echo "Aborted"
|
||||
endif
|
||||
endfunction
|
||||
194
nerdtree_plugin/fs_menu.vim
Normal file
194
nerdtree_plugin/fs_menu.vim
Normal file
@@ -0,0 +1,194 @@
|
||||
" ============================================================================
|
||||
" File: fs_menu.vim
|
||||
" Description: plugin for the NERD Tree that provides a file system menu
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 17 July, 2009
|
||||
" 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.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_fs_menu")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_fs_menu = 1
|
||||
|
||||
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||
if g:NERDTreePath.CopyingSupported()
|
||||
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
||||
endif
|
||||
|
||||
"FUNCTION: s:echo(msg){{{1
|
||||
function! s:echo(msg)
|
||||
redraw
|
||||
echomsg "NERDTree: " . a:msg
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:echoWarning(msg){{{1
|
||||
function! s:echoWarning(msg)
|
||||
echohl warningmsg
|
||||
call s:echo(a:msg)
|
||||
echohl normal
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
|
||||
"prints out the given msg and, if the user responds by pushing 'y' then the
|
||||
"buffer with the given bufnum is deleted
|
||||
"
|
||||
"Args:
|
||||
"bufnum: the buffer that may be deleted
|
||||
"msg: a message that will be echoed to the user asking them if they wish to
|
||||
" del the buffer
|
||||
function! s:promptToDelBuffer(bufnum, msg)
|
||||
echo a:msg
|
||||
if nr2char(getchar()) ==# 'y'
|
||||
exec "silent bdelete! " . a:bufnum
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeAddNode(){{{1
|
||||
function! NERDTreeAddNode()
|
||||
let curDirNode = g:NERDTreeDirNode.GetSelected()
|
||||
|
||||
let newNodeName = input("Add a childnode\n".
|
||||
\ "==========================================================\n".
|
||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||
\ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash())
|
||||
|
||||
if newNodeName ==# ''
|
||||
call s:echo("Node Creation Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let newPath = g:NERDTreePath.Create(newNodeName)
|
||||
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
|
||||
|
||||
let newTreeNode = g:NERDTreeFileNode.New(newPath)
|
||||
if parentNode.isOpen || !empty(parentNode.children)
|
||||
call parentNode.addChild(newTreeNode, 1)
|
||||
call NERDTreeRender()
|
||||
call newTreeNode.putCursorHere(1, 0)
|
||||
endif
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Created.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeMoveNode(){{{1
|
||||
function! NERDTreeMoveNode()
|
||||
let curNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Rename the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path for the node: \n" .
|
||||
\ "", curNode.path.str())
|
||||
|
||||
if newNodePath ==# ''
|
||||
call s:echo("Node Renaming Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let bufnum = bufnr(curNode.path.str())
|
||||
|
||||
call curNode.rename(newNodePath)
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
if bufnum != -1
|
||||
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
call curNode.putCursorHere(1, 0)
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Renamed.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeDeleteNode() {{{1
|
||||
function! NERDTreeDeleteNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let confirmed = 0
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
let choice =input("Delete the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "STOP! To delete this entire directory, type 'yes'\n" .
|
||||
\ "" . currentNode.path.str() . ": ")
|
||||
let confirmed = choice ==# 'yes'
|
||||
else
|
||||
echo "Delete the current node\n" .
|
||||
\ "==========================================================\n".
|
||||
\ "Are you sure you wish to delete the node:\n" .
|
||||
\ "" . currentNode.path.str() . " (yN):"
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
|
||||
if confirmed
|
||||
try
|
||||
call currentNode.delete()
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
let bufnum = bufnr(currentNode.path.str())
|
||||
if buflisted(bufnum)
|
||||
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not remove node")
|
||||
endtry
|
||||
else
|
||||
call s:echo("delete aborted")
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeCopyNode() {{{1
|
||||
function! NERDTreeCopyNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Copy the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path to copy the node to: \n" .
|
||||
\ "", currentNode.path.str())
|
||||
|
||||
if newNodePath != ""
|
||||
"strip trailing slash
|
||||
let newNodePath = substitute(newNodePath, '\/$', '', '')
|
||||
|
||||
let confirmed = 1
|
||||
if currentNode.path.copyingWillOverwrite(newNodePath)
|
||||
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
if confirmed
|
||||
try
|
||||
let newNode = currentNode.copy(newNodePath)
|
||||
call NERDTreeRender()
|
||||
call newNode.putCursorHere(0, 0)
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not copy node")
|
||||
endtry
|
||||
endif
|
||||
else
|
||||
call s:echo("Copy aborted.")
|
||||
endif
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
2547
plugin/NERD_tree.vim
2547
plugin/NERD_tree.vim
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user