forked from carlhuda/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgvimrc
More file actions
286 lines (236 loc) · 6.64 KB
/
gvimrc
File metadata and controls
286 lines (236 loc) · 6.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
if has("gui_macvim")
" Fullscreen takes up entire screen
set fuoptions=maxhorz,maxvert
" Command-T for CommandT
macmenu &File.New\ Tab key=<D-T>
map <D-t> :CommandT<CR>
imap <D-t> <Esc>:CommandT<CR>
" Command-O for list of Opened buffers (using command t buffers)
map <D-O> :CommandTBuffer<CR>
imap <D-O> <Esc>:CommandTBuffer<CR>
" Command-Return for fullscreen
macmenu Window.Toggle\ Full\ Screen\ Mode key=<D-CR>
" Command-Shift-F for Ack
map <D-F> <Esc>:Ack<space>
vmap <D-F> y<Esc>:Ack<space><C-r>"
" search pattern yank selection
vmap / y<Esc>/<C-r>"
vmap ? y<Esc>?<C-r>"
" map Command-Shift-5 (Command-%) for search replace pattern
vmap <D-%> y<Esc>:%s/<C-r>"/
" map Alt-/ to remove highlited search results (nohl)
nn <M-/> :nohl<CR>
vn <M-/> :nohl<CR>
ino <M-/> <C-o>:nohl<CR>
" Command-e for ConqueTerm
map <D-e> :call StartTerm()<CR>
" Command-/ to toggle comments
map <D-/> <plug>NERDCommenterToggle<CR>
imap <D-/> <Esc>0<plug>NERDCommenterToggle<CR>i
" Command-d to delete line
imap <D-d> <Esc>ddi
map <D-d> dd
" Command-][ to increase/decrease indentation
vmap <D-]> >gv
vmap <D-[> <gv
" Map Command-# to switch tabs
map <D-0> 0gt
imap <D-0> <Esc>0gt
map <D-1> 1gt
imap <D-1> <Esc>1gt
map <D-2> 2gt
imap <D-2> <Esc>2gt
map <D-3> 3gt
imap <D-3> <Esc>3gt
map <D-4> 4gt
imap <D-4> <Esc>4gt
map <D-5> 5gt
imap <D-5> <Esc>5gt
map <D-6> 6gt
imap <D-6> <Esc>6gt
map <D-7> 7gt
imap <D-7> <Esc>7gt
map <D-8> 8gt
imap <D-8> <Esc>8gt
map <D-9> 9gt
imap <D-9> <Esc>9gt
" Command-Option-ArrowKey to switch viewports
map <D-M-Up> <C-w>k
imap <D-M-Up> <C-o><C-w>k
map <D-M-Down> <C-w>j
imap <D-M-Down> <C-o><C-w>j
map <D-M-Right> <C-w>l
imap <D-M-Right> <C-o><C-w>l
map <D-M-Left> <C-w>h
imap <D-M-Left> <C-o><C-w>h
" Command-Option-[hjkl] to switch viewports
map <D-M-k> <C-w>k
imap <D-M-k> <C-o><C-w>k
map <D-M-j> <C-w>j
imap <D-M-j> <C-o><C-w>j
map <D-M-l> <C-w>l
imap <D-M-l> <C-o><C-w>l
map <D-M-h> <C-w>h
imap <D-M-h> <C-o><C-w>h
" Command-Shift-[hjkl] to switch viewports
map <D-K> <C-w>k
imap <D-K> <C-o><C-w>k
map <D-J> <C-w>j
imap <D-J> <C-o><C-w>j
map <D-L> <C-w>l
imap <D-L> <C-o><C-w>l
map <D-H> <C-w>h
imap <D-H> <C-o><C-w>h
" Adjust viewports to the same size
map <Leader>= <C-w>=
imap <Leader>= <Esc> <C-w>=
" Remap select text (alt shift [left/right]) to visual commands B/E
nn <S-M-Left> vb<C-g>
vn <S-M-Left> b<C-g>
ino <S-M-Left> <Esc>vb<C-g>
nn <S-M-Right> ve<C-g>
vn <S-M-Right> e<C-g>
ino <S-M-Right> <Esc>ve<C-g>
endif
" Don't beep
set visualbell
" Start without the toolbar
set guioptions-=T
" Default gui color scheme
color ir_black
" ConqueTerm wrapper
function StartTerm()
execute 'ConqueTerm ' . $SHELL . ' --login'
setlocal listchars=tab:\ \
endfunction
" Project Tree
if exists("loaded_nerd_tree")
autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
autocmd FocusGained * call s:UpdateNERDTree()
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
endif
#autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
#autocmd FocusGained * call s:UpdateNERDTree()
#autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
endif
endif
endif
endfunction
" If the parameter is a directory, cd into it
function s:CdIfDirectory(directory)
let explicitDirectory = isdirectory(a:directory)
let directory = explicitDirectory || empty(a:directory)
if explicitDirectory
exe "cd " . fnameescape(a:directory)
endif
" Allows reading from stdin
" ex: git diff | mvim -R -
if strlen(a:directory) == 0
return
endif
if directory
keepjumps NERDTree
wincmd p
bd
endif
if explicitDirectory
wincmd p
endif
endfunction
" NERDTree utility function
function s:UpdateNERDTree(...)
let stay = 0
if(exists("a:1"))
let stay = a:1
end
if exists("t:NERDTreeBufName")
let nr = bufwinnr(t:NERDTreeBufName)
if nr != -1
exe nr . "wincmd w"
exe substitute(mapcheck("R"), "<CR>", "", "")
if !stay
wincmd p
end
endif
endif
if exists(":CommandTFlush") == 2
CommandTFlush
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 " . fnameescape(a:dir)
let stay = exists("a:1") ? a:1 : 1
keepjumps NERDTree
if !stay
wincmd p
endif
endfunction
function Touch(file)
execute "!touch " . shellescape(a:file, 1)
call s:UpdateNERDTree()
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 " . shellescape(a:file, 1)
endif
call s:UpdateNERDTree()
endfunction
function Mkdir(file)
execute "!mkdir " . shellescape(a:file, 1)
call s:UpdateNERDTree()
endfunction
function Edit(file)
if exists("b:NERDTreeRoot")
wincmd p
endif
execute "e " . fnameescape(a:file)
ruby << RUBY
destination = File.expand_path(VIM.evaluate(%{system("dirname " . shellescape(a:file, 1))}))
pwd = File.expand_path(Dir.pwd)
home = pwd == File.expand_path("~")
if home || Regexp.new("^" + Regexp.escape(pwd)) !~ destination
VIM.command(%{call ChangeDirectory(fnamemodify(a:file, ":h"), 0)})
end
RUBY
endfunction
" Define the NERDTree-aware aliases
if exists("loaded_nerd_tree")
call s:DefineCommand("cd", "ChangeDirectory")
call s:DefineCommand("touch", "Touch")
call s:DefineCommand("rm", "Remove")
call s:DefineCommand("e", "Edit")
call s:DefineCommand("mkdir", "Mkdir")
cabbrev Edit! e!
endif
" Include user's local vim config
if filereadable(expand("~/.gvimrc.local"))
source ~/.gvimrc.local
endif