-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
351 lines (292 loc) · 10.9 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
set nocompatible
syntax on " syntax highlighing
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
set backupcopy=yes " helps npm builder notice file changes
" In GVIM
if has("gui_running")
set guifont=DejaVu\ Sans\ Mono\ Book\ 13 " use this font
"set lines=35 "
"set columns=130 "
set background=light " adapt colors for background
let g:lucius_style="light"
colorscheme lucius
set guioptions-=T
set guioptions-=m
else
set background=dark " adapt colors for dark background
"colorscheme lucius
"set t_Co=256
endif
hi Normal ctermbg=None
" Don't create .swp files everywhere
set directory-=.
" Together with vim-rooter, this works nice to find files in the current
" directory, which I tend to keep at project's root.
set path=**
set suffixesadd+=.handlebars
set suffixesadd+=.coffee
set suffixesadd+=.py
" ==================================================
" Hack: Reset background
" ==================================================
autocmd VimLeave * set t_Co=
" ==================================================
" Basic Settings
" ==================================================
let mapleader="," " change the leader to be a comma vs slash
set textwidth=80 " Try this out to see how textwidth helps
set cmdheight=3 " Make command line bigger
set laststatus=2 " always show status line
set scrolloff=4 " keep 3 lines when scrolling
set nocursorline " have a line indicate the cursor location
set autoindent " always set autoindenting on
set noshowcmd " don't display incomplete commands
set ruler " show the cursor position all the time
set nobackup " do not keep a backup file
set modeline " last lines in document sets Vim mode
set modelines=3 " number lines checked for modelines
set shortmess=atI " Abbreviate messages
set nostartofline " don't jump to first character when paging
set backspace=start,indent,eol " backspace over everything
set matchpairs+=<:> " show matching <> (html mainly) as well
set showmatch
set matchtime=3
set mouse=a
set nowrap
set autowrite
set diffopt+=iwhite
set noautochdir
"set spell
" default text encoding
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
" tags
set tags=tags; " ';' searches for tags file in parent directories
" complete in vim commands with a nice list
set wildmode=longest,list
set wildignore+=*.pyc
set wildignore+=*.o,*.a,*.so,*.d,*.obj,.git
" custom keys
set pastetoggle=<F8>
" If we're running in vimdiff then tweak out settings a bit
if &diff
set nospell
endif
autocmd FileType gitcommit setlocal spell!
autocmd BufNewFile,BufRead *.handlebars set filetype=handlebars
" ==================================================
" spell checking
" ==================================================
"set spell
set spelllang=pl,en
" shortcut to toggle spelling
nmap <leader>s :setlocal spell! <CR>
" setup a custom dict for spelling
" zg = add word to dict
" zw = mark word as not spelled correctly (remove)
set spellfile=~/.vim/dict.add
" ==================================================
" Basic Maps
" ==================================================
"
" Maps for jj to act as Esc
inoremap ,, <esc>
vnoremap ,, <esc>
cnoremap ,, <c-c>
" map ctrl-c to something else so I quit using it
map <c-c> <Nop>
imap <c-c> <Nop>
" sane copy-pasting :)
imap <c-v> <c-o>"+P
vmap <c-c> "+y
" start new commands without shift
nnoremap ; :
" shift block
vmap < <gv
vmap > >gv
nmap <leader>nu :set number!<cr>
" terminal
nmap <silent> <F9> :call system("gnome-terminal&")<CR>
let g:load_doxygen_syntax=1
" ==================================================
" Windows / Splits
" ==================================================
" ctrl-jklm changes to that split
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" use - and + to resize horizontal splits
map - 3<C-W>-
map + 3<C-W>+
" and for vsplits with alt-< or alt->
map <M-,> 3<C-W><
map <M-.> 3<C-W>>
set noequalalways
set winminheight=0
noremap <C-w><PageDown> <C-w><Down><C-w>_
noremap <C-w><PageUp> <C-w><Up><C-w>_
" ==================================================
" Search
" ==================================================
set nohlsearch " don't highlight searches by default
set incsearch " do incremental searching
set wrapscan
"set ignorecase " ignore case when searching
"set smartcase " if searching and search contains upper case, make case sensitive search
map <silent> <leader><C-i> :set invhlsearch<CR>
imap <silent> <leader><C-i> <C-o>:set invhlsearch<CR>
" ==================================================
" JSON formatting
" ==================================================
menu FormatFile.JSON :%!python -mjson.tool<CR>
menu Format.JSON :'<,'>!python -mjson.tool<CR>
menu FormatFile.HTML :%!tidy -i -xml -wrap 0 2>/dev/null<CR>
menu Format.HTML :'<,'>!tidy -i -xml -wrap 0 2>/dev/null<CR>
map <silent> <leader><C-f>? :popup FormatFile<CR>
vmap <silent> <leader><C-f>? <ESC>:popup Format<CR>
map <silent> <leader><C-f>j :%!python -mjson.tool<CR>
vmap <silent> <leader><C-f>j :'<,'>!python -mjson.tool<CR>
imap <silent> <leader><C-f>j <C-o>:'<,'>!python -mjson.tool<CR>
" ==================================================
" initialize Pathogen
" ==================================================
call pathogen#infect()
" ==================================================
" Clean all end of line extra whitespace with ,S
" Credit: voyeg3r https://github.com/mitechie/pyvim/issues/#issue/1
" ==================================================
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
map <silent><leader>S <esc>:keepjumps call CleanExtraSpaces()<cr>
" ==================================================
" Skeletons
" ==================================================
autocmd BufNewFile *.h TSkeletonSetup cpp.h
autocmd BufNewFile *Test.cpp TSkeletonSetup cppTest.cpp
" ==================================================
" Project
" ==================================================
let g:proj_flags="istbcg"
let g:proj_window_width=35
" ==================================================
" CommandT
" ==================================================
let g:CommandTAcceptSelectionSplitMap = '<C-o>'
let g:CommandTMaxFiles=30000
" ==================================================
" Alternate
" ==================================================
let g:alternateExtensions_h = "C,cpp,cxx,cc,CC,c"
let g:alternateExtensions_C = "h,H,hpp"
" ==================================================
" Taglist
" ==================================================
let Tlist_Ctags_Cmd = "/usr/bin/ctags"
let Tlist_WinWidth = 50
let Tlist_Show_One_File=1
map <F4> :TlistToggle<cr>
" ==================================================
" Folding
" ==================================================
"autocmd FileType cpp set foldmethod=syntax
"set foldtext=getline(v:foldstart)
"set foldnestmax=4
"set foldcolumn=5
"set foldopen+=search
"set foldlevel=0
" ==================================================
" Clang Complete
" ==================================================
let g:clang_snippets = 1
"let g:clang_snippets_engine = 'ultisnips'
" ==================================================
" Clang Format
" ==================================================
" map <leader><C-f> :pyf /home/qsorix/bin/clang-format.py<CR>
" imap <leader><C-f> <ESC>:pyf /home/qsorix/bin/clang-format.py<CR>i
autocmd BufNewFile,BufRead *.cpp set syntax=cpp11
autocmd BufNewFile,BufRead *.cc set syntax=cpp11
" ==================================================
" 3-way diff helper
" ==================================================
" Disable one diff window during a three-way diff allowing you to cut out the
" noise of a three-way diff and focus on just the changes between two versions
" at a time. Inspired by Steve Losh's Splice
function! DiffToggle(window)
" Save the cursor position and turn on diff for all windows
let l:save_cursor = getpos('.')
windo :diffthis
" Turn off diff for the specified window (but keep scrollbind) and move
" the cursor to the left-most diff window
exe a:window . "wincmd w"
diffoff
set scrollbind
set cursorbind
exe a:window . "wincmd " . (a:window == 1 ? "l" : "h")
" Update the diff and restore the cursor position
diffupdate
call setpos('.', l:save_cursor)
endfunction
" Toggle diff view on the left, center, or right windows
nmap <silent> <leader>dl :call DiffToggle(1)<cr>
nmap <silent> <leader>dc :call DiffToggle(2)<cr>
nmap <silent> <leader>dr :call DiffToggle(3)<cr>
" ==================================================
" Syntastic
" ==================================================
set statusline=%<%f\
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
set statusline+=%h%m%r%=%-14.(%l,%c%V%)\ %P
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 2 " automatically close, but not open
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_disabled_filetypes=['cpp']
let g:syntastic_python_checkers = ["flake8", "pyflakes", "python"]
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_cpp_checkers = []
let g:syntastic_error_symbol = "✗"
let g:syntastic_warning_symbol = "⚠"
" ==================================================
" py.test
" ==================================================
map <leader><C-t> :Pytest project<CR>
imap <leader><C-t> <ESC>:Pytest project<CR>i
" ==================================================
" NERDTree
" ==================================================
map <f12> :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\.pyc$']
" ==================================================
" Unite
" ==================================================
nnoremap <C-p> :Unite -start-insert file_rec/git<cr>
nnoremap <leader><C-g> :Unite -auto-preview grep:.<cr>
let g:unite_source_grep_command = 'git'
let g:unite_source_grep_default_opts = 'gr'
let g:unite_source_grep_recursive_opt = ''
let g:unite_source_tag_max_fname_length = 70
autocmd FileType unite call s:unite_my_settings()
function! s:unite_my_settings()"{{{
imap <silent><buffer><expr> <C-CR> unite#do_action('above')
map <silent><buffer><expr> <C-CR> unite#do_action('above')
endfunction"}}}
autocmd BufEnter *
\ if empty(&buftype)
\| nnoremap <buffer> <C-]> :<C-u>UniteWithCursorWord -immediately tag<CR>
\| nnoremap <buffer> <C-w><C-]> :<C-u>UniteWithCursorWord -immediately -default-action=split tag<CR>
\| endif
" ==================================================
" JavaScript indenting
" ==================================================
let g:SimpleJsIndenter_BriefMode = 1