-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
430 lines (361 loc) · 11.5 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
" vim: set norelativenumber:
" .vimrc
"
" My personal vimrc file
"
" Author: Anders L. Hurum <andershurum@gmail.com>
" Source: github.com/peakbreaker/.dotfiles
" Website: https://peakbreaker.com
" Email: andershurum@gmail.com
" Github: https://github.com/peakbreaker
"
" # mmmmm #
" mmmm mmm mmm # m # # m mm mmm mmm # m mmm m mm
" #" "# #" # " # # m" #mmmm" #" " #" # " # # m" #" # #" "
" # # #"""" m"""# #"# # # # #"""" m"""# #"# #"""" #
" ##m#" "#mm" "mm"# # "m #mmmm" # "#mm" "mm"# # "m "#mm" #
" #
" #
"
" Whenever a line has been thoughtfully considered and added, it is indented
"
" Instructions for non basic things :
" - <C-j> for jumpmenu
" - <leader>. for tags
" - m<space> for deleting all markers
" Fix for 2R issue https://github.com/1587/vim/issues/390
set t_u7=
" Plugins ----------------------------------------------------------------- {{{
" Autoinstall Plug if its not installed
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()
" Personal plugin
Plug 'peakBreaker/peakPlugin'
" Theming
Plug 'junegunn/vim-emoji'
Plug 'dylanaraps/wal.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Syntax
Plug 'cespare/vim-toml'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'posva/vim-vue'
Plug 'ap/vim-css-color'
" Autocomplete/running & other utils
Plug 'vim-syntastic/syntastic' | Plug 'Valloric/YouCompleteMe' | Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
Plug 'skywind3000/asyncrun.vim'
Plug 'othree/vim-autocomplpop'
Plug 'vim-scripts/L9'
" Git
Plug 'jreybert/vimagit'
Plug 'airblade/vim-gitgutter'
" Filesystem/Project handling
Plug 'ctrlpvim/ctrlp.vim'
Plug 'dkprice/vim-easygrep'
Plug 'ludovicchabant/vim-gutentags'
" Programming lang specifics
Plug 'nvie/vim-flake8'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'hashivim/vim-terraform'
" Superpowers
Plug 'tpope/vim-surround'
Plug 'vim-scripts/ZoomWin'
Plug 'janko-m/vim-test'
Plug 'antoyo/vim-licenses'
Plug 'kshenoy/vim-signature'
call plug#end()
" Configuring Plugins --------------------------------------------------- {{{
" Kite
let g:kite_tab_complete=1
set completeopt-=menu
set completeopt+=menuone " show the popup menu even when there is only 1 match
set completeopt+=preview " show preview window
set completeopt+=noinsert " don't insert any text until user chooses a match
set completeopt-=noselect " dont select first match
autocmd CompleteDone * if !pumvisible() | pclose | endif
let g:kite_documentation_continual=1
" Ultisnips
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:ultisnips_python_style="numpy"
let g:UltiSnipsSnippetDirectories=["UltiSnips", "peakbreaker-snippets"]
" Airline linebar
let g:airline_theme='wal'
" Quick run via <F5>
nnoremap <F5> :call <SID>compile_and_run()<CR>
nnoremap <F6> :AsyncStop<CR>
nnoremap <F4> :call asyncrun#quickfix_toggle(8)<cr>
function! s:compile_and_run()
exec 'w'
exec "AsyncStop"
if &filetype == 'c'
exec "AsyncRun! gcc % -o %<; time ./%<"
elseif &filetype == 'cpp'
exec "AsyncRun! g++ -std=c++11 % -o %<; time ./%<"
elseif &filetype == 'java'
exec "AsyncRun! javac %; time java %<"
elseif &filetype == 'sh'
exec "AsyncRun! time bash %"
elseif &filetype == 'python'
exec "AsyncRun! time python3 %"
endif
endfunction
" Use the Go LSP gopls for autocomplete
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" if &filetype == 'go'
" augroup peakbr_go_autocomplete
" autocmd!
" ...
" augroup END
" endif
" augroup SPACEVIM_ASYNCRUN
" autocmd!
" " Automatically open the quickfix window
" autocmd User AsyncRunStart call asyncrun#quickfix_toggle(15, 1)
" augroup END
"
" asyncrun now has an option for opening quickfix automatically
let g:asyncrun_open = 15
" Control-p speedup
"" Ignore some sane things
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,venv*/*
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$|vendor\|\.hg$\|\.svn$\|\.yardoc\|public\/images\|public\/system\|data\|log\|tmp$|venv$',
\ 'file': '\.exe$\|\.so$\|\.dat$'
\ }
"" caching and optimized search
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
" }}}
let g:acp_enableAtStartup = 1
" Terraform
let g:terraform_align=1
let g:terraform_fold_sections = 1
let g:terraform_fmt_on_save=1
" }}}
" Basic configs ----------------------------------------------------------- {{{
" Some basics
let mapleader = " "
set nocompatible
filetype off
" Wildmode autocomplete
set wildmode=longest,list,full
"filetype plugin on
syntax on
set encoding=utf-8
" Enable modelines
set modeline
set modelines=3
" Statusline
set laststatus=2 " always display the status line
" UI Basics
set number
set relativenumber
set ruler
set nocursorline " Do not highlight current line (doest work so well with all themes)
set visualbell " Blink cursor on error instead of beeping (grr)
set title
set textwidth=79
set wildmenu
colorscheme wal
" Editing basics
set wrap
set formatoptions=qron1
" Colored column
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%80v', 100)
" Tabs and spaces highlighting
exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~"
set list
" Searching
set incsearch " Search incrementally
set hlsearch " Highlight search
set ignorecase " Disabling case sensitiveness
set smartcase " And enabling smart case sensitiveness
" Clear search
noremap <leader>n :let @/=''<cr>
noremap <leader>N :let @/=''<cr>
" Blink the targeted match
highlight WhiteOnRed ctermbg=red
nnoremap <silent> n n:call HLNext(0.2)<CR>
nnoremap <silent> N N:call HLNext(0.2)<CR>
function! HLNext (blinktime)
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let blinks = 3
for n in range(1,blinks)
let red = matchadd('WhiteOnRed', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm'
call matchdelete(red)
redraw
exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm'
endfor
endfunction
" Splits at the bottom right
set splitbelow
set splitright
" Spaces / Tabs
set tabstop=4 " number of spaces in one tab
set softtabstop=4 " num spaces in tab when editing
set expandtab " tabs are spaces
" Makes vim jimp to last position when reopening file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Jump to matching brackety when inserting one
set showmatch
set matchtime=3
" }}}
" Folding ----------------------------------------------------------------- {{{
set foldlevelstart=0
" }}}
" Commenting -------------------------------------------------------------- {{{
" source: https://stackoverflow.com/a/24046914/2571881
let s:comment_map = {
\ "c": '\/\/',
\ "cpp": '\/\/',
\ "go": '\/\/',
\ "java": '\/\/',
\ "javascript": '\/\/',
\ "lua": '--',
\ "scala": '\/\/',
\ "php": '\/\/',
\ "python": '#',
\ "ruby": '#',
\ "rust": '\/\/',
\ "sh": '#',
\ "desktop": '#',
\ "fstab": '#',
\ "conf": '#',
\ "profile": '#',
\ "bashrc": '#',
\ "bash_profile": '#',
\ "mail": '>',
\ "eml": '>',
\ "bat": 'REM',
\ "ahk": ';',
\ "vim": '"',
\ "tex": '%'
\ }
function! ToggleComment()
if has_key(s:comment_map, &filetype)
let comment_leader = s:comment_map[&filetype]
if getline('.') =~ '^\s*$'
return
endif
if getline('.') =~ '^\s*' . comment_leader
" Uncomment the line
execute 'silent s/\v\s*\zs' . comment_leader . '\s*\ze//'
else
" Comment the line
execute 'silent s/\v^(\s*)/\1' . comment_leader . ' /'
endif
else
echo "No comment leader found for filetype"
endif
endfunction
" function! pasteregister()
" let r = input('Register: ')
" execute ''
" endfunction
nnoremap <Leader>/ :call ToggleComment()<CR>
vnoremap <Leader>/ :call ToggleComment()<CR>
" }}}
" Jumping ---------------------------------------------------------------- {{{
function! GotoJump()
jumps
let j = input("Please select your jump: ")
if j != ''
let pattern = '\v\c^\+'
if j =~ pattern
let j = substitute(j, pattern, '', 'g')
execute "normal " . j . "\<c-i>"
else
execute "normal " . j . "\<c-o>"
endif
endif
endfunction
nnoremap <leader>j :call GotoJump()<CR>
" }}}
" Hotkeys ---------------------------------------------------------------- {{{
" Switching between windows quicker
nmap <C-J> <C-W>j
nmap <C-K> <C-W>k
nmap <C-H> <C-W>h
nmap <C-L> <C-W>l
" Buffers
nnoremap <leader>bp :prev<CR>
nnoremap <leader>bn :next<CR>
nnoremap <leader>bb :buffers<CR>:buffer<space>
nnoremap <leader>bd :buffers<CR>:bdelete<space>
" Marks & jumps
nnoremap <C-Y> <C-I>
" Git blaming
vnoremap <leader>b :!git blame <C-R>=expand("%:p")<CR> -L '<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>'
vnoremap <leader>B ygv :!git log --pretty=format:"<..> %s %H" -L <C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>:<C-R>=expand("%:p")<CR> --abbrev-commit \| grep "<..>"
" vmap <leader>B :!git blame <C-R>=expand("%:p")<CR> \| sed -n '<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>' p
" For folding
nmap <Tab> za
nnoremap <expr> <leader><Tab> &foldlevel ? 'zM' :'zR'
" For jumping to definition
nmap <C-[> <C-t>
nnoremap <leader>. :CtrlPTag<CR>
" For vimmagit
nnoremap <leader>gs :Magit<CR>
" Autocompleting
inoremap <C-Space> <C-X><C-O>
" Copying and pasting with system clipboard
vnoremap <leader>c "+y
nmap <leader>v "+p
" Move up/down editor lines
nnoremap j gj
nnoremap k gk
" When indenting we dont want to deselect
vnoremap < <gv
vnoremap > >gv
" For vimtests
nnoremap <leader>tn :TestNearest
nnoremap <leader>tf :TestFile
nnoremap <leader>ts :TestSuite
nnoremap <leader>tg :TestVisit
nnoremap <leader>tr :TestLast<CR>
nnoremap <leader>tl :TestLast<CR>
" Other
nnoremap <leader>w :wqa<CR>
nnoremap <leader>qq :qa!<CR>
" Switch : and ;
nnoremap ; :
nnoremap : ;
" Jumping forward in history
" }}}
" Autocmds ---------------------------------------------------------------- {{{
autocmd FileType sh nnoremap <buffer> <leader>r :w<CR>:exec '!bash' expand("%")<CR>
autocmd FileType python nnoremap <buffer> <leader>r :w<CR>:exec '!python3' shellescape(@%, 1)<CR>
" }}}
" Whitespace
set shiftwidth=2
set noshiftround
" Cursor motion
set scrolloff=3
set backspace=indent,eol,start
set matchpairs+=<:> " use % to jump between pairs
runtime! macros/matchit.vim
" Allow hidden buffers
set hidden
" Rendering
set ttyfast
" Last line
set showmode
set showcmd
" Formatting
"map <leader>q gqip