Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

136 lines (108 sloc) 3.3 kB
if has("gui_macvim")
" Fullscreen takes up entire screen
set fuoptions=maxhorz,maxvert
" Command-T for CommandT
macmenu &File.New\ Tab key=<nop>
map <D-t> :CommandT<CR>
" Command-Shift-F for Ack
macmenu Window.Toggle\ Full\ Screen\ Mode key=<nop>
map <D-F> :Ack<space>
" Command-e for ConqueTerm
map <D-e> :call StartTerm()<CR>
" Command-/ to toggle comments
map <D-/> <plug>NERDCommenterToggle<CR>
endif
" Start without the toolbar
set guioptions-=T
" Default gui color scheme
color molokai
" ConqueTerm wrapper
function StartTerm()
execute 'ConqueTerm ' . $SHELL . ' --login'
setlocal listchars=tab:\ \
endfunction
" Project Tree
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
" Disable netrw's autocmd, since we're ALWAYS using NERDTree
runtime plugin/netRwPlugin.vim
augroup FileExplorer
au!
augroup END
let g:NERDTreeHijackNetrw = 0
" If the parameter is a directory, cd into it
function s:CdIfDirectory(directory)
if isdirectory(a:directory)
call ChangeDirectory(a:directory)
endif
endfunction
" NERDTree utility function
function s:UpdateNERDTree(stay)
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
NERDTree
if !a:stay
wincmd p
end
endif
endif
endfunction
" Utility functions to create file commands
function s:CommandCabbr(abbreviation, expansion)
execute 'cabbrev ' . a:abbreviation . ' <c-r>=getcmdpos() == 1 && getcmdtype() == ":" ? "' . a:expansion . '" : "' . a:abbreviation . '"<CR>'
endfunction
function s:FileCommand(name, ...)
if exists("a:1")
let funcname = a:1
else
let funcname = a:name
endif
execute 'command -nargs=1 -complete=file ' . a:name . ' :call ' . funcname . '(<f-args>)'
endfunction
function s:DefineCommand(name, destination)
call s:FileCommand(a:destination)
call s:CommandCabbr(a:name, a:destination)
endfunction
" Public NERDTree-aware versions of builtin functions
function ChangeDirectory(dir, ...)
execute "cd " . a:dir
let stay = exists("a:1") ? a:1 : 1
call s:UpdateNERDTree(stay)
endfunction
function Touch(file)
execute "!touch " . a:file
call s:UpdateNERDTree(1)
endfunction
function Remove(file)
let current_path = expand("%")
let removed_path = fnamemodify(a:file, ":p")
if (current_path == removed_path) && (getbufvar("%", "&modified"))
echo "You are trying to remove the file you are editing. Please close the buffer first."
else
execute "!rm " . a:file
endif
endfunction
function Edit(file)
if exists("b:NERDTreeRoot")
wincmd p
endif
execute "e " . a:file
ruby << RUBY
destination = File.expand_path(VIM.evaluate(%{system("dirname " . a:file)}))
pwd = File.expand_path(Dir.pwd)
home = pwd == File.expand_path("~")
if home || Regexp.new("^" + Regexp.escape(pwd)) !~ destination
VIM.command(%{call ChangeDirectory(system("dirname " . a:file), 0)})
end
RUBY
endfunction
" Define the NERDTree-aware aliases
call s:DefineCommand("cd", "ChangeDirectory")
call s:DefineCommand("touch", "Touch")
call s:DefineCommand("rm", "Remove")
call s:DefineCommand("e", "Edit")
" Include user's local vim config
if filereadable(expand("~/.gvimrc.local"))
source ~/.gvimrc.local
endif
Jump to Line
Something went wrong with that request. Please try again.