-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
332 lines (271 loc) · 7.99 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
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
" ==>> GENERAL
set t_Co=256
" don't bug me all the time
set visualbell
" use nifty non-vi features
set nocompatible
" disable the Ex mode
nnoremap Q <nop>
" erase old autocommands
au!
" reload .vimrc on save
au BufWritePost .vimrc source ~/.vimrc
" timeout for shortcuts
set timeoutlen=400
" mouse is really usefule sometimes
set mouse=a
let mapleader = ";"
set splitbelow
set splitright
"" ==>> FILES AND BUFFERS
filetype off
filetype plugin indent on
syntax on
set enc=utf-8
set fileencodings=utf-8,iso-8859-2
" reload on change
set autoread
set autowrite
set noswapfile
set nobackup
set nowritebackup
" allow unloading unsaved buffer
set hidden
noremap <Leader>e :NERDTree<CR>
" quick buffer switching
noremap <Leader>j <C-^>
" autosave on buffer switch
set autowrite
" get rid of whitespace
" au BufLeave * silent! %s/[ \t]*$//g
" save file as root
cmap w!! w !sudo tee % >/dev/null<CR>:e!<CR><CR>
cmap wm :w \| make
"" ==>> COLORS
set background=dark
let g:solarized_termcolors = 256
let g:solarized_visibility = "normal"
let g:solarized_contrast = "normal"
colorscheme solarized
" some highlighting (EasyMotion, Fugitive) doesn't work well with solarized
hi link EasyMotionTarget ErrorMsg
hi link EasyMotionShade Comment
if has("gui_running")
set fuoptions=maxvert,maxhorz
au GUIEnter * set fullscreen
endif
set guifont=Courier\ New\ bold:h14
set guioptions=
"" ==>> SEARCH AND INDEX
set hlsearch
set ignorecase
" when search pattern contains uppercase char disable ignorecase
set smartcase
set incsearch
" continues search from beginning
set wrapscan
" lower priority on tab completion
set suffixes=.pyc,.bak,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set history=50
" search work under cursor
nmap <Leader>a :Ack -i <cword><CR>
" use ag not ack
let g:ackprg = 'ag --nogroup --nocolor --column'
" save typing :nohl
noremap <Leader><space> :nohl<CR>
" jump to matching bracket for a short period of time
set showmatch
" search for tags all the way up to the root
set tags=./tags;$HOME
" gf searches recursively downwards the current directory
set path+=./**,**
" ==>> INDENTING
set expandtab
set autoindent
set smartindent
set tabstop=2
set softtabstop=2
" spaces for autoindent
set shiftwidth=2
" see where my whitespace is
set list
set listchars=tab:\.\ ,nbsp:~,trail:_
set foldmethod=manual
" ==>> USEFUL
inoremap {{ {<CR>}<Esc>O
" up/down consistent with wrapped lines
nnoremap j gj
nnoremap k gk
" sections jumping
noremap js ?==>><CR>:nohl<CR>zt
noremap ks /==>><CR>:nohl<CR>zt
nnoremap cP <esc>:let @" = expand("%")<CR>
"nnoremap <Leader>lf :ln<CR>
"nnoremap <Leader>lb :ln<CR>
"let g:lt_location_list_toggle_map = '<leader>ls'
"let g:lt_quickfix_list_toggle_map = '<leader>lc'
autocmd Filetype qf wincmd J
" toggle the paredit
let g:paredit_leader = ','
nnoremap <Leader>p :let paredit_mode=1 - paredit_mode<CR>::let paredit_mode<CR>
set pastetoggle=<F2>
" replacement from register
"nnoremap cp "_diw"0P
"vnoremap cp "_d"0P
"This allows for change paste motion cp{motion}
nmap <silent> cp :set opfunc=ChangePaste<CR>g@
function! ChangePaste(type, ...)
silent exe "normal! `[v`]\"_c"
silent exe "normal! p"
endfunction
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
map Y y$
" ==>> VIM MODES
" pressing j and k together escapes
inoremap jk <esc>
inoremap kj <esc>
inoremap KJ <esc>
inoremap JK <esc>
" info on cursor position in statusline
set ruler
set showmode
set showcmd
set number
set wildmenu
" ==>> FILE SPECIFIC
" this didn't work when in bundle/vimclojure-2/ftdetect
au BufNewFile,BufRead *.json set filetype=javascript
au BufNewFile,BufRead *.clj set filetype=clojure
au BufNewFile,BufRead *.cljs set filetype=clojure
au BufNewFile,BufRead *.less set filetype=less
au BufNewFile,BufRead *.coffee set filetype=coffee
au BufNewFile,BufRead *.html set filetype=html
" compile coffee script files on save
au BufWritePost *.coffee !coffee -c <afile> 2>&1
" compile less files on save
au BufWritePost *.less !lessc -c <afile> > %<.css
au FileType python set tabstop=4
au FileType python set softtabstop=4
au FileType python set shiftwidth=4
au FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
au FileType python ab pymain if __name__ == '__main__':
au FileType haskell set tabstop=4
au FileType haskell set softtabstop=4
au FileType haskell set shiftwidth=4
au FileType coffee set tabstop=2
au FileType coffee set softtabstop=2
au FileType coffee set shiftwidth=2
au FileType html set tabstop=2
au FileType html set softtabstop=2
au FileType html set shiftwidth=2
"c like behaviour for multiline comments
au FileType d source setlocal fo-=t fo+=croql
au FileType d source set foldmethod=indent
" ==>> PACKAGES
let g:EasyMotion_leader_key = '<space>'
" keep my package sanity
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-fireplace'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-abolish'
Bundle 'tpope/vim-unimpaired'
Bundle 'guns/vim-clojure-static'
Bundle 'kien/rainbow_parentheses.vim'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'
Bundle 'vim-scripts/cscope.vim'
Bundle 'mileszs/ack.vim'
Bundle 'wincent/Command-T'
Bundle 'a.vim'
Bundle 'vim-scripts/LustyJuggler'
Bundle 'camelcasemotion'
"Bundle 'octol/vim-cpp-enhanced-highlight'
"Bundle 'scrooloose/syntastic'
"Bundle 'Valloric/YouCompleteMe'
nnoremap <silent> <Leader>t :CommandT<CR>
nnoremap <silent> <Leader>b :CommandTBuffer<CR>
" don't require extra confirmation to accept ycm config on startup
let g:ycm_confirm_extra_conf = 0
let g:ycm_autoclose_preview_window_after_completion = 1
"let g:ycm_add_preview_to_completeopt = 0
"set completeopt-=preview
let g:LustyJugglerDefaultMappings = 0
nmap <silent> <Leader>j :LustyJuggler<CR>
" rainbow parentheses
let g:rbpt_loadcmd_toggle = 1
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" TODO Move this to a plugin
" Function to find files in subdirectories.
" Credits to Vladimir Marek and http://vim.wikia.com/wiki/VimTip1234
function! Find(name)
let l:list=system("find . -name '*".a:name."*' | grep -v \".svn/\" | perl -ne 'print \"$.\\t$_\"'")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:name."' not found"
return
endif
if l:num != 1
echo l:list
let l:input=input("Which ? (CR=nothing)\n")
if strlen(l:input)==0
return
endif
if strlen(substitute(l:input, "[0-9]", "", "g"))>0
echo "Not a number"
return
endif
if l:input<1 || l:input>l:num
echo "Out of range"
return
endif
let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
else
let l:line=l:list
endif
let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
execute ":e ".l:line
endfunction
command! -nargs=1 Find :call Find("<args>")
" Define a command to make it easier to use
command! -nargs=+ QFDo call QFDo(<q-args>)
if !exists("*QFDo")
" Function that does the work
function! QFDo(command)
" Create a dictionary so that we can
" get the list of buffers rather than the
" list of lines in buffers (easy way
" to get unique entries)
let buffer_numbers = {}
" For each entry, use the buffer number as
" a dictionary key (won't get repeats)
for fixlist_entry in getqflist()
let buffer_numbers[fixlist_entry['bufnr']] = 1
endfor
" Make it into a list as it seems cleaner
let buffer_number_list = keys(buffer_numbers)
" For each buffer
for num in buffer_number_list
" Select the buffer
exe 'buffer' num
" Run the command that's passed as an argument
exe a:command
" Save if necessary
update
endfor
endfunction
endif
nmap <Leader>s <C-\>
" little mapping to help me with indentin
noremap <Leader>i 20i<tab><esc>kF(jldw
noremap ii ~hi
let g:bufExplorerSplitBelow=1
set exrc
set secure