Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 185 lines (146 sloc) 4.153 kb
9a57c0a @tmm1 make fullscreen take up entire screen
tmm1 authored
1
9ef5dce @tmm1 link gvimrc to enable apple-t for CommandT in MacVIM
tmm1 authored
2 if has("gui_macvim")
f8dc0cc @skaar fuoptions is MacVim specific - make gvim launch without error
skaar authored
3 " Fullscreen takes up entire screen
4 set fuoptions=maxhorz,maxvert
5
fb887e2 @wuputah be consistent with README about calling it command
wuputah authored
6 " Command-T for CommandT
9ef5dce @tmm1 link gvimrc to enable apple-t for CommandT in MacVIM
tmm1 authored
7 macmenu &File.New\ Tab key=<nop>
8 map <D-t> :CommandT<CR>
46b1633 @wycats Map <D-F> to `:Ack `
wycats authored
9
fb887e2 @wuputah be consistent with README about calling it command
wuputah authored
10 " Command-Shift-F for Ack
46b1633 @wycats Map <D-F> to `:Ack `
wycats authored
11 macmenu Window.Toggle\ Full\ Screen\ Mode key=<nop>
9974c7b @wycats <D-F> should be `:Ack ` not `:Ack`
wycats authored
12 map <D-F> :Ack<space>
33f6508 @tmm1 apple-e to open conqueterm
tmm1 authored
13
fb887e2 @wuputah be consistent with README about calling it command
wuputah authored
14 " Command-e for ConqueTerm
33f6508 @tmm1 apple-e to open conqueterm
tmm1 authored
15 map <D-e> :call StartTerm()<CR>
be7bac7 @wuputah add NERDCommenter, bind to Command-/
wuputah authored
16
fb887e2 @wuputah be consistent with README about calling it command
wuputah authored
17 " Command-/ to toggle comments
be7bac7 @wuputah add NERDCommenter, bind to Command-/
wuputah authored
18 map <D-/> <plug>NERDCommenterToggle<CR>
426bda3 @tmm1 Use Command-][ to control indentation (ala TextMate)
tmm1 authored
19
20 " Command-][ to increase/decrease indentation
21 vmap <D-]> >gv
22 vmap <D-[> <gv
9ef5dce @tmm1 link gvimrc to enable apple-t for CommandT in MacVIM
tmm1 authored
23 endif
331c805 @tmm1 use local gvim settings from ~/.gvimrc.local
tmm1 authored
24
9090730 @tmm1 use full option name for better understandability
tmm1 authored
25 " Start without the toolbar
26 set guioptions-=T
8d2a8e2 @wuputah start with the gvim/macvim toolbar hidden
wuputah authored
27
7286b91 @tmm1 pick default colors I like for console/gui - change them in your .local ...
tmm1 authored
28 " Default gui color scheme
c2af37f @wycats Add irblack as default theme
wycats authored
29 color ir_black
7286b91 @tmm1 pick default colors I like for console/gui - change them in your .local ...
tmm1 authored
30
33f6508 @tmm1 apple-e to open conqueterm
tmm1 authored
31 " ConqueTerm wrapper
32 function StartTerm()
24bd9f2 @wuputah use user's preferred shell
wuputah authored
33 execute 'ConqueTerm ' . $SHELL . ' --login'
33f6508 @tmm1 apple-e to open conqueterm
tmm1 authored
34 setlocal listchars=tab:\ \
35 endfunction
36
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
37 " Project Tree
38 autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
a935aab @wycats Update NERDTree and CommandT on refocus
wycats authored
39 autocmd FocusGained * call s:UpdateNERDTree()
b7cdd3c @wycats If you enter a window, and there's only one window total, and it's NERDT...
wycats authored
40 autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
41
b7cdd3c @wycats If you enter a window, and there's only one window total, and it's NERDT...
wycats authored
42 " Close all open buffers on entering a window if the only
43 " buffer that's left is the NERDTree buffer
44 function s:CloseIfOnlyNerdTreeLeft()
45 if exists("t:NERDTreeBufName")
46 echo t:NERDTreeBufName
47 if bufwinnr(t:NERDTreeBufName) != -1
48 if winnr("$") == 1
49 q
50 endif
51 endif
52 endif
53 endfunction
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
54
55 " If the parameter is a directory, cd into it
56 function s:CdIfDirectory(directory)
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
57 let explicitDirectory = isdirectory(a:directory)
58 let directory = explicitDirectory || empty(a:directory)
59
60 if explicitDirectory
61 exe "cd " . a:directory
62 endif
63
64 if directory
65 NERDTree
66 wincmd p
67 bd
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
68 endif
1475b2d @wycats If you open with an explicit directory (mvim .) start on NERDTree, not t...
wycats authored
69
70 if explicitDirectory
71 wincmd p
72 else
73
74 endif
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
75 endfunction
76
77 " NERDTree utility function
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
78 function s:UpdateNERDTree(...)
79 let stay = 0
80
81 if(exists("a:1"))
82 let stay = a:1
83 end
84
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
85 if exists("t:NERDTreeBufName")
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
86 let nr = bufwinnr(t:NERDTreeBufName)
87 if nr != -1
88 exe nr . "wincmd w"
89 exe substitute(mapcheck("R"), "<CR>", "", "")
90 if !stay
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
91 wincmd p
92 end
93 endif
94 endif
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
95
a935aab @wycats Update NERDTree and CommandT on refocus
wycats authored
96 if exists(":CommandTFlush") == 2
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
97 CommandTFlush
98 endif
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
99 endfunction
100
101 " Utility functions to create file commands
102 function s:CommandCabbr(abbreviation, expansion)
103 execute 'cabbrev ' . a:abbreviation . ' <c-r>=getcmdpos() == 1 && getcmdtype() == ":" ? "' . a:expansion . '" : "' . a:abbreviation . '"<CR>'
104 endfunction
105
106 function s:FileCommand(name, ...)
107 if exists("a:1")
108 let funcname = a:1
109 else
110 let funcname = a:name
111 endif
112
113 execute 'command -nargs=1 -complete=file ' . a:name . ' :call ' . funcname . '(<f-args>)'
114 endfunction
115
116 function s:DefineCommand(name, destination)
117 call s:FileCommand(a:destination)
118 call s:CommandCabbr(a:name, a:destination)
119 endfunction
120
121 " Public NERDTree-aware versions of builtin functions
122 function ChangeDirectory(dir, ...)
123 execute "cd " . a:dir
124 let stay = exists("a:1") ? a:1 : 1
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
125
126 NERDTree
127
128 if !stay
129 wincmd p
130 endif
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
131 endfunction
132
133 function Touch(file)
134 execute "!touch " . a:file
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
135 call s:UpdateNERDTree()
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
136 endfunction
137
138 function Remove(file)
139 let current_path = expand("%")
140 let removed_path = fnamemodify(a:file, ":p")
141
142 if (current_path == removed_path) && (getbufvar("%", "&modified"))
143 echo "You are trying to remove the file you are editing. Please close the buffer first."
144 else
145 execute "!rm " . a:file
146 endif
0eb80f3 @wycats Fixed a bunch of common annoyances:
wycats authored
147
148 call s:UpdateNERDTree()
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
149 endfunction
150
90cd2a0 @wycats Add a NERDTree-aware mkdir
wycats authored
151 function Mkdir(file)
152 execute "!mkdir " . a:file
153 call s:UpdateNERDTree()
154 endfunction
155
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
156 function Edit(file)
157 if exists("b:NERDTreeRoot")
158 wincmd p
159 endif
160
161 execute "e " . a:file
162
163 ruby << RUBY
164 destination = File.expand_path(VIM.evaluate(%{system("dirname " . a:file)}))
165 pwd = File.expand_path(Dir.pwd)
166 home = pwd == File.expand_path("~")
167
168 if home || Regexp.new("^" + Regexp.escape(pwd)) !~ destination
169 VIM.command(%{call ChangeDirectory(system("dirname " . a:file), 0)})
170 end
171 RUBY
172 endfunction
173
174 " Define the NERDTree-aware aliases
175 call s:DefineCommand("cd", "ChangeDirectory")
176 call s:DefineCommand("touch", "Touch")
177 call s:DefineCommand("rm", "Remove")
178 call s:DefineCommand("e", "Edit")
90cd2a0 @wycats Add a NERDTree-aware mkdir
wycats authored
179 call s:DefineCommand("mkdir", "MkDir")
765746e @tmm1 move project tree stuff into gvimrc
tmm1 authored
180
331c805 @tmm1 use local gvim settings from ~/.gvimrc.local
tmm1 authored
181 " Include user's local vim config
182 if filereadable(expand("~/.gvimrc.local"))
183 source ~/.gvimrc.local
184 endif
Something went wrong with that request. Please try again.