forked from jweinberg/dotvim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
370 lines (313 loc) · 10.1 KB
/
vimrc
File metadata and controls
370 lines (313 loc) · 10.1 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
scriptencoding utf-8
silent! call pathogen#runtime_append_all_bundles()
silent! call pathogen#helptags()
"" default to insert mode for most code files
"au BufWinEnter * set noinsertmode
"au BufWinEnter .vimrc,*.php,*.js,*.inc,*.jade,*.c,*.ejs,*.css,*.html,*.htm set insertmode | imap <buffer> <Esc> <C-l>
" put backups and swap files somewhere out of the way
set backupdir=~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.tmp,~/tmp,/var/tmp,/tmp
set swapfile " do want
set backup " do want
set backupcopy=yes
" persist undo across launches, vim 7.3+
if has('persistent_undo')
set undodir=~/.tmp,~/tmp,/var/tmp,/tmp
set undofile
endif
let macvim_hig_shift_movement = 1
set encoding=utf-8
set number
set numberwidth=4
set nocp " we use vim, not vi
set modelines=0 " practice safe vimming
set nomodeline
set foldenable
set laststatus=2 " always show the status line
set cmdheight=2
set cursorline " highlight current linefiletype indent off
set showcmd
set showfulltag
set shortmess+=ts
set wildmenu " turn on command line completion wild style
set wildmode=list:longest " turn on wild mode huge list
set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc,*.jpg,*.gif,*.png
set mouse=a
set iskeyword+=_,$,@,%,# " none of these are word dividers
set nostartofline
set novisualbell
set showmatch
set expandtab
set ignorecase
set infercase
set shiftround
set smartcase
set shiftwidth=2
set softtabstop=2
set tabstop=2
set ruler
set backspace=eol,start,indent " backspace crosses newlines?
set clipboard=unnamed
set scrolloff=4
set hlsearch
set incsearch
let mapleader=','
set smarttab " tabs to indent, spaces to align
set updatetime=1000
set whichwrap+=<>[]
set display=lastline " show as much of the last line as possible
set showmatch
set matchtime=2
set timeout timeoutlen=3000 ttimeoutlen=100 " adjust map/key timeouts
set hidden " allow hidden buffers, rather than closing
set foldmethod=syntax
set foldlevelstart=99
set autoread " automatically reload files changed outside Vim
set autowrite " automatically write files when doing things like :make
set modelines=5
set switchbuf=usetab
set noequalalways
"set list listchars=tab:\ \ ,trail:·
set diffopt+=vertical
if exists('+autochdir')
set autochdir
else
autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
endif
" open help on bottom
cnoreabbrev h bot h
"set completeopt= " don't use a pop up menu for completions
filetype plugin indent on " load filetype plugins/indent settings
syntax on " syntax highlighting on
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
let g:PreviewBrowsers='Safari'
let NERDShutUp=1 " no more f*cking 'unknown filetype' warnings!
" NERDTree configuration
let g:NERDTreeIgnore = ['\.sock$', '\~$']
map <Leader>n :NERDTreeToggle<CR>
" taglist stuff
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let Tlist_Auto_Open='1'
let Tlist_Use_Right_Window='1'
let Tlist_Show_One_File='1'
let Tlist_File_Fold_Auto_Close='1'
let Tlist_Enable_Fold_Column='0'
let Tlist_Exit_OnlyWindow='1'
let Tlist_Compact_Format='1'
"let Tlist_Process_File_Always='1'
"let Tlist_Show_Menu='1'
let g:tlist_javascript_settings = 'javascript;r:var;s:string;a:array;o:object;f:function;d:require'
"autocmd BufWritePost * :TlistUpdate
"let Tlist_GainFocus_On_ToggleOpen='1'
au BufEnter __Tag_List__ :setlocal statusline=Tag\ List
" Conque stuff
let g:ConqueTerm_ReadUnfocused = 1
let g:ConqueTerm_CloseOnEnd = 1
let g:ConqueTerm_InsertOnEnter = 0
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
set nocompatible " explicitly get out of vi-compatible mode
set noexrc " don't use local version of .(g)vimrc, .exrc
set cpoptions=aABceFsmq
" |||||||||
" ||||||||+-- When joining lines, leave the cursor
" ||||||| between joined lines
" |||||||+-- When a new match is created (showmatch)
" |||||| pause for .5
" ||||||+-- Set buffer options when entering the
" ||||| buffer
" |||||+-- :write command updates current file name
" ||||+-- Automatically add <CR> to the last line
" ||| when using :@r
" |||+-- Searching continues at the end of the match
" || at the cursor position
" ||+-- A backslash has no special meaning in mappings
" |+-- :write updates alternative file name
" +-- :read updates alternative file name
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]%{fugitive#statusline()}
" | | | | | | | | | | |
" | | | | | | | | | | + current
" | | | | | | | | | | column
" | | | | | | | | | +-- current line
" | | | | | | | | +-- current % into file
" | | | | | | | +-- current syntax in
" | | | | | | | square brackets
" | | | | | | +-- current fileformat
" | | | | | +-- number of lines
" | | | | +-- preview flag in square brackets
" | | | +-- help flag in square brackets
" | | +-- readonly flag in square brackets
" | +-- rodified flag in square brackets
" +-- full path to file in the buffer
if has("gui_running")
set guioptions=egmrt
colorscheme sidetracked
if has("mac")
set guifont=Consolas:h12
endif
endif
" nicer looking tabs and whitespace
if (&termencoding == "utf-8") || has("gui_running")
if v:version >= 700
set listchars=tab:»·,trail:·,extends:…,eol:¶
"let &showbreak=nr2char(8618).' '
"let &showbreak='-> '
else
set listchars=tab:»·,trail:·,extends:…,eol:¶
endif
endif
set cpoptions+=$
" Syntax customizations
let is_posix=1
let c_gnu=1
let c_space_errors=1
let c_curly_error=0
let c_no_bracket_error=1
let objc_syntax_for_h=1
let filetype_m='objc'
set cinoptions=g1,h3,t0,(0,W4
" CommandT
let g:CommandTMaxHeight=30
" Project Tree
autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
autocmd FocusGained * call s:UpdateSidebars()
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
function s:UpdateSidebars()
try
call s:UpdateNERDTree()
TlistUpdate
catch /.*/
echo "Here"
endtry
endfunction
" Project Tree
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
NERDTree
wincmd p
bd
endif
if explicitDirectory
wincmd p
endif
endfunction
" NERDTree utility function
function s:UpdateNERDTree(...)
try
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
endtry
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
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
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")
" Command-/ to toggle comments
map <D-/> <plug>NERDCommenterToggle<CR>
" Command-][ to increase/decrease indentation
vmap <D-]> >gv
vmap <D-[> <gv