forked from scrooloose/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
298 lines (227 loc) · 8.7 KB
/
vimrc
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
"necessary on some Linux distros for pathogen to properly load bundles
filetype off
"load pathogen managed plugins
call pathogen#runtime_append_all_bundles()
"Use Vim settings, rather then Vi settings (much better!).
"This must be first, because it changes other options as a side effect.
set nocompatible
"allow backspacing over everything in insert mode
set backspace=indent,eol,start
"store lots of :cmdline history
set history=1000
set showcmd "show incomplete cmds down the bottom
set showmode "show current mode down the bottom
set hlsearch "hilight searches by default
set number "add line numbers
set showbreak=...
set wrap linebreak nolist
"add some line space for easy reading
set linespace=4
" setup swap and backup dir
set backupdir=~/.vim/backup//
set directory=~/.vim/swp//
"disable visual bell
set visualbell t_vb=
"turn off needless toolbar and scrollbars on gvim/mvim
set guioptions-=m
set guioptions-=r
set guioptions-=l
set guioptions-=L
set guioptions-=T
" COMMENTING OUT AS IT DOESN'T WORK WITH POWERLINE
"recalculate the trailing whitespace warning when idle, and after saving
"autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
"return '[\s]' if trailing white space is detected
"return '' otherwise
"function! StatuslineTrailingSpaceWarning()
"if !exists("b:statusline_trailing_space_warning")
"if search('\s\+$', 'nw') != 0
"let b:statusline_trailing_space_warning = '[\s]'
"else
"let b:statusline_trailing_space_warning = ''
"endif
"endif
"return b:statusline_trailing_space_warning
"endfunction
"recalculate the tab warning flag when idle and after writing
"autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
"return '[&et]' if &et is set wrong
"return '[mixed-indenting]' if spaces and tabs are used to indent
"return an empty string if everything is fine
"function! StatuslineTabWarning()
"if !exists("b:statusline_tab_warning")
"let tabs = search('^\t', 'nw') != 0
"let spaces = search('^ ', 'nw') != 0
"if tabs && spaces
"let b:statusline_tab_warning = '[mixed-indenting]'
"elseif (spaces && !&et) || (tabs && &et)
"let b:statusline_tab_warning = '[&et]'
"else
"let b:statusline_tab_warning = ''
"endif
"endif
"return b:statusline_tab_warning
"endfunction
"indent settings
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=3 "deepest fold is 3 levels
set nofoldenable "dont fold by default
set wildmode=list:longest "make cmdline tab completion similar to bash
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*.class,*.jar,*~ "stuff to ignore when tab completing
"vertical/horizontal scroll off settings
set scrolloff=3
set sidescrolloff=7
set sidescroll=1
"load ftplugins and indent files
filetype plugin on
filetype indent on
"turn on syntax highlighting
syntax on
"some stuff to get the mouse going in term
set mouse=a
set ttymouse=xterm2
colorscheme xoria256
if has("gui_running")
"tell the term has 256 colors
set t_Co=256
set guitablabel=%M%t
"set lines=40
"set columns=115
set guifont=Consolas\ for\ Powerline\ 12
if has("gui_gnome")
set term=gnome-256color
endif
else
"dont load csapprox if there is no gui support - silences an annoying warning
let g:CSApprox_loaded = 1
endif
"map to bufexplorer
nnoremap <leader>b :BufExplorer<cr>
"make Y consistent with C and D
nnoremap Y y$
"mark syntax errors with :signs
let g:syntastic_enable_signs=1
"snipmate setup
source ~/.vim/snippets/support_functions.vim
autocmd vimenter * call s:SetupSnippets()
function! s:SetupSnippets()
"if we're in a rails env then read in the rails snippets
if filereadable("./config/environment.rb")
call ExtractSnips("~/.vim/snippets/ruby-rails", "ruby")
call ExtractSnips("~/.vim/snippets/eruby-rails", "eruby")
endif
call ExtractSnips("~/.vim/snippets/html", "eruby")
call ExtractSnips("~/.vim/snippets/html", "xhtml")
call ExtractSnips("~/.vim/snippets/html", "php")
endfunction
"visual search mappings
function! s:VSetSearch()
echom "in vsetsearch"
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
"jump to last cursor position when opening a file
"dont do it when writing a commit log entry
autocmd BufReadPost * call SetCursorPosition()
function! SetCursorPosition()
if &filetype !~ 'commit\c'
if line("'\"") > 0 && line("'\"") <= line("$")
exe "normal! g`\""
normal! zz
endif
end
endfunction
"key mapping for window navigation
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
"Map backspace to clear matches
nmap <BS> :nohlsearch<CR>:match none<CR>
" Make j and k behave will with long lines
nmap j gj
nmap k gk
"Powerline plugin
let g:Powerline_symbols = 'fancy'
"CTRL.P.vim plugin
set runtimepath^=~/.vim/bundle/ctrlp.vim
" Open a split with vimrc
nnoremap <leader>ev :vsplit $HOME/.vim/vimrc<cr>
nnoremap <leader>sv :source %<cr>
" Clojure
let g:vimclojure#ParenRainbow=1
let vimclojure#SetupKeyMap = 0
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set maxfuncdepth=16384
function! JumpToDir(dest)
execute "lcd ~/.marks/" . a:dest
pwd
endfunction
function! JumpToDirCompletions(arg_lead, L, P)
"return globpath("~/.marks", a:arg_lead . "*")
return system("ls -1d ~/.marks/* | sed 's,^.*.marks/,,'")
endfunction
command! -complete=custom,JumpToDirCompletions -nargs=1 Jump call JumpToDir("<args>")
nnoremap <leader>w :%s/facts\?/& :wip/g<cr>
nnoremap <leader>W :%s/ :wip//g<cr>
vnoremap <leader>w :s/facts\?/& :wip/g<cr>
vnoremap <leader>W :s/ :wip//g<cr>
nnoremap <leader>d mf"dyiwgg/(defn\?\s*d<cr><esc>:nohlsearch<cr>
nnoremap <leader>r mob"ayt/gg2w"nyt./:require<cr>:nohlsearch<cr>o[<esc>"npa :as <esc>"apa]<esc>3bea.
function! OpenTest()
let file_path = @%
"let file_name = strpart(file_path, strridx(file_path, "/") + 1)
let test_file_path_suffixed = substitute(file_path, "\.clj", "_test.clj", "")
let test_file_path = substitute(test_file_path_suffixed, "src/", "test/", "")
echom "Opening " . test_file_path
execute "normal! :topleft vs " . test_file_path . "\<cr>"
endfunction
nnoremap <leader>t :call OpenTest()<cr>
function! OpenSource()
let file_path = @%
"let file_name = strpart(file_path, strridx(file_path, "/") + 1)
let src_file_path_suffixed = substitute(file_path, "_test.clj", ".clj", "")
let src_file_path = substitute(src_file_path_suffixed, "test/", "src/", "")
echom "Opening " . src_file_path
execute "normal! :botright vs " . src_file_path . "\<cr>"
endfunction
nnoremap <leader>s :call OpenSource()<cr>
nnoremap <leader>bl :%s/"bookmarks"/"remote_bookmarks"/<cr>:%s/"local_bookmarks"/"bookmarks"/<cr>
nnoremap <leader>br :%s/"bookmarks"/"local_bookmarks"/<cr>:%s/"remote_bookmarks"/"bookmarks"/<cr>
vnoremap m y`<v`>
nnoremap <leader>jt mob"ayt/f/l"dyegg/:as a\><cr>:nohlsearch<cr>T["nyt `o:execute "normal! :tabnew src/" . substitute(substitute("n", '-', '_', 'g'), '\.', '/', 'g') . ".clj\<lt>cr>"<cr>/d<cr>
nnoremap <leader>jv mob"ayt/f/l"dyegg/:as a\><cr>:nohlsearch<cr>T["nyt `o:execute "normal! :botright vsplit src/" . substitute(substitute("n", '-', '_', 'g'), '\.', '/', 'g') . ".clj\<lt>cr>"<cr>/d<cr>
nnoremap <leader>jj mob"ayt/f/l"dyegg/:as a\><cr>:nohlsearch<cr>T["nyt `o:execute "normal! :e src/" . substitute(substitute("n", '-', '_', 'g'), '\.', '/', 'g') . ".clj\<lt>cr>"<cr>/d<cr>
nnoremap <leader>jr mob"ayt/f/l"dyegg/:as a\><cr>:nohlsearch<cr>0f[
nnoremap <leader>d bi...<esc>ea...<esc>
:nnoremap <leader>stime :%s/#<LocalDateTime \(\d\{4\}\)-\(\d\{1,2\}\)-\(\d\{1,2\}\)T\(\d\{1,2\}\):\(\d\{1,2\}\)>/(time\/date-time \1 \2 \3 \4 \5 0)/g<cr>
:nnoremap <leader>sdate :%s/#<LocalDate \(\d\{4\}\)-\(\d\{1,2\}\)-\(\d\{1,2\}\)/(time\/date-time \1 \2 \3)/g<cr>
function! IncFont()
set guifont=Consolas\ for\ Powerline\ 25
endfunction
function! DecFont()
set guifont=Consolas\ for\ Powerline\ 12
endfunction
nnoremap <leader>= :call IncFont()<cr>
nnoremap <leader>- :call DecFont()<cr>
" <leader>u mapped to generate uuid
nnoremap <leader>u mt:r !uuidgen<cr>diW`tpjdd`te
" ctrl-o same as ctrl-p
nnoremap <C-o> :<C-u>CtrlP<cr>
set laststatus=2