-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
534 lines (471 loc) · 18 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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
" ____ _____
" | _ \_ _| Derek Taylor (DistroTube)
" | | | || | http://www.youtube.com/c/DistroTube
" | |_| || | http://www.gitlab.com/dwt1/
" |____/ |_|
"
" A customized .vimrc for vim (https://www.vim.org/)
set nocompatible " be iMproved, required
filetype off " required
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim-plug core
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Check if Vim-plug is installed, if not, install it
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 | so ~/.vimrc
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle For Managing Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
"{{ The Basics }}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
"" Snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'gmarik/Vundle.vim' " Vundle
Plug 'itchyny/lightline.vim' " Lightline statusbar
Plug 'suan/vim-instant-markdown', {'rtp': 'after'} " Markdown Preview
Plug 'frazrepo/vim-rainbow'
Plug 'joshdick/onedark.vim'
"{{ File management }}
Plug 'vifm/vifm.vim' " Vifm
Plug 'scrooloose/nerdtree' " Nerdtree
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Highlighting Nerdtree
Plug 'ryanoasis/vim-devicons' " Icons for Nerdtree
"{{ Productivity }}
" Plug 'ycm-core/YouCompleteMe'
Plug 'vimwiki/vimwiki' " VimWiki
Plug 'jreybert/vimagit' " Magit-like plugin for vim
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-commentary'
Plug 'vim-autoformat/vim-autoformat'
"{{ Tim Pope Plugins }}
Plug 'tpope/vim-surround' " Change surrounding marks
Plug 'tpope/vim-fugitive'
"{{ Syntax Highlighting and Colors }}
Plug 'PotatoesMaster/i3-vim-syntax' " i3 config highlighting
Plug 'kovetskiy/sxhkd-vim' " sxhkd highlighting
Plug 'vim-python/python-syntax' " Python highlighting
Plug 'ap/vim-css-color' " Color previews for CSS
"{{ Junegunn Choi Plugins }}
Plug 'junegunn/goyo.vim' " Distraction-free viewing
Plug 'junegunn/limelight.vim' " Hyperfocus on a range
Plug 'junegunn/vim-emoji' " Vim needs emojis!
" c
Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']}
" Plug 'xavierd/clang_complete'
Plug 'rhysd/vim-clang-format'
Plug 'ludwig/split-manpage.vim'
" elixir
Plug 'elixir-lang/vim-elixir'
Plug 'carlosgaldino/elixir-snippets'
" elm
"" Elm Bundle
" Plug 'elmcast/elm-vim'
" erlang
" Plug 'jimenezrick/vimerl'
" go
"" Go Lang Bundle
" Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
Plug 'gko/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" lua
"" Lua Bundle
Plug 'xolox/vim-lua-ftplugin'
Plug 'xolox/vim-lua-inspect'
" ocaml
"" OCaml Bundle
" Plug 'def-lkb/ocp-indent-vim'
" perl
"" Perl Bundle
Plug 'vim-perl/vim-perl'
Plug 'c9s/perlomni.vim'
" php
"" PHP Bundle
" Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install --no-dev -o'}
" Plug 'stephpy/vim-php-cs-fixer'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" ruby
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-projectionist'
Plug 'thoughtbot/vim-rspec'
Plug 'ecomba/vim-ruby-refactoring', {'tag': 'main'}
" rust
" Vim racer
Plug 'racer-rust/vim-racer'
" Rust.vim
Plug 'rust-lang/rust.vim'
" Async.vim
Plug 'prabirshrestha/async.vim'
" Vim lsp
Plug 'prabirshrestha/vim-lsp'
" Asyncomplete.vim
Plug 'prabirshrestha/asyncomplete.vim'
" Asyncomplete lsp.vim
Plug 'prabirshrestha/asyncomplete-lsp.vim'
" scala
if has('python')
" sbt-vim
Plug 'ktvoelker/sbt-vim'
endif
" vim-scala
Plug 'derekwyatt/vim-scala'
" svelte
Plug 'leafOfTree/vim-svelte-plugin'
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
" vuejs
Plug 'posva/vim-vue'
Plug 'leafOfTree/vim-vue-plugin'
"" Include user's extra bundle
if filereadable(expand("~/.vimrc.local.bundles"))
source ~/.vimrc.local.bundles
endif
" Install plugins if missing
autocmd VimEnter *
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#end()
" Post install steps for YouCompleteMe
" if filereadable(expand('~/.vim/plugged/YouCompleteMe/install.py'))
" echo "Installing YouCompleteMe"
" !cd ~/.vim/plugged/YouCompleteMe && python3 install.py --all && cd -
" endif
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
filetype plugin on
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" Install plugins and source .vimrc
nnoremap <leader>pi :PlugInstall<CR>:source $MYVIMRC<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set encoding=utf-8
" set fileencoding=utf-8
set ttyfast
set path+=** " Searches current directory recursively.
set wildmenu " Display all matches when tab complete.
set incsearch " Incremental search
set hlsearch
set ignorecase
set smartcase
set hidden " Needed to keep multiple buffers open
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
set nobackup " No auto backups
set noswapfile " No swap
set t_Co=256 " Set if term supports 256 colors.
set number " relativenumber " Display line numbers
"" Copy/Paste/Cut
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
filetype indent plugin on
syntax on
set guifont=CascadiaCova\ NF:s12
let g:rehash256 = 1
let g:onedark_terminal_italics='1'
let g:onedark_hide_endofbuffer='1'
colorscheme onedark
"" Map leader to ( )
let mapleader=' '
" session management
let g:session_directory = "~/.vim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1
let g:C_UseTool_cmake = 'yes'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Remap Keys
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap ESC to ii
:imap ii <Esc>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Status Line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" The lightline.vim theme
let g:lightline = {
\ 'colorscheme': 'onedark',
\ }
let g:lightline = {
\ 'colorscheme': 'onedark',
"\ 'active': {
"\ 'left': [ ['mode', 'paste'],
"\ ['fugitive', 'readonly', 'filename', 'modified'] ],
"\ 'right': [ [ 'lineinfo' ], ['percent'] ]
"\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"\ue0a2":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"\ue0a0":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ } "" This is comment: I fotgot this line in my last post, just added
" Always show statusline
set laststatus=2
" Uncomment to prevent non-normal modes showing in powerline and below powerline.
set noshowmode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab " Use spaces instead of tabs.
set smarttab " Be smart using tabs ;)
set shiftwidth=2 " One tab == four spaces.
set tabstop=2 " One tab == four spaces.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => NERDTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Uncomment to autostart the NERDTree
" autocmd vimenter * NERDTree
map <leader><tab> :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = ''
let g:NERDTreeDirArrowCollapsible = '▼'
let NERDTreeShowLineNumbers=1
let NERDTreeShowHidden=1
let NERDTreeMinimalUI = 1
let g:NERDTreeWinSize=38
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Theming
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" highlight LineNr ctermfg=8 ctermbg=none cterm=none
" highlight CursorLineNr ctermfg=7 ctermbg=8 cterm=none
" highlight VertSplit ctermfg=0 ctermbg=8 cterm=none
" highlight Statement ctermfg=2 ctermbg=none cterm=none
" highlight Directory ctermfg=4 ctermbg=none cterm=none
" highlight StatusLine ctermfg=7 ctermbg=8 cterm=none
" highlight StatusLineNC ctermfg=7 ctermbg=8 cterm=none
" highlight NERDTreeClosable ctermfg=2
" highlight NERDTreeOpenable ctermfg=8
" highlight Comment ctermfg=4 ctermbg=none cterm=italic
" highlight Constant ctermfg=12 ctermbg=none cterm=none
" highlight Special ctermfg=4 ctermbg=none cterm=none
" highlight Identifier ctermfg=6 ctermbg=none cterm=none
" highlight PreProc ctermfg=5 ctermbg=none cterm=none
" highlight String ctermfg=12 ctermbg=none cterm=none
" highlight Number ctermfg=1 ctermbg=none cterm=none
" highlight Function ctermfg=1 ctermbg=none cterm=none
" highlight WildMenu ctermfg=0 ctermbg=80 cterm=none
" highlight Folded ctermfg=103 ctermbg=234 cterm=none
" highlight FoldColumn ctermfg=103 ctermbg=234 cterm=none
" highlight DiffAdd ctermfg=none ctermbg=23 cterm=none
" highlight DiffChange ctermfg=none ctermbg=56 cterm=none
" highlight DiffDelete ctermfg=168 ctermbg=96 cterm=none
" highlight DiffText ctermfg=0 ctermbg=80 cterm=none
" highlight SignColumn ctermfg=244 ctermbg=235 cterm=none
" highlight Conceal ctermfg=251 ctermbg=none cterm=none
" highlight SpellBad ctermfg=168 ctermbg=none cterm=underline
" highlight SpellCap ctermfg=80 ctermbg=none cterm=underline
" highlight SpellRare ctermfg=121 ctermbg=none cterm=underline
" highlight SpellLocal ctermfg=186 ctermbg=none cterm=underline
" highlight Pmenu ctermfg=251 ctermbg=234 cterm=none
" highlight PmenuSel ctermfg=0 ctermbg=111 cterm=none
" highlight PmenuSbar ctermfg=206 ctermbg=235 cterm=none
" highlight PmenuThumb ctermfg=235 ctermbg=206 cterm=none
" highlight TabLine ctermfg=244 ctermbg=234 cterm=none
" highlight TablineSel ctermfg=0 ctermbg=247 cterm=none
" highlight TablineFill ctermfg=244 ctermbg=234 cterm=none
" highlight CursorColumn ctermfg=none ctermbg=236 cterm=none
" highlight CursorLine ctermfg=none ctermbg=236 cterm=none
" highlight ColorColumn ctermfg=none ctermbg=236 cterm=none
" highlight Cursor ctermfg=0 ctermbg=5 cterm=none
" highlight htmlEndTag ctermfg=114 ctermbg=none cterm=none
" highlight xmlEndTag ctermfg=114 ctermbg=none cterm=none
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vifm
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>vv :Vifm<CR>
map <Leader>vs :VsplitVifm<CR>
map <Leader>sp :SplitVifm<CR>
map <Leader>dv :DiffVifm<CR>
map <Leader>tv :TabVifm<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VimWiki
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim-Instant-Markdown
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:instant_markdown_autostart = 0 " Turns off auto preview
let g:instant_markdown_browser = "surf" " Uses surf for preview
map <Leader>md :InstantMarkdownPreview<CR> " Previews .md file
map <Leader>ms :InstantMarkdownStop<CR> " Kills the preview
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Open terminal inside Vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>tt :vertical terminal<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Mouse Scrolling
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set mouse=a
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => autoformat settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=79
endfunction
endif
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd fileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Splits and Tabbed Files
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set splitbelow splitright
"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
" Remap splits navigation to just CTRL + hjkl
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Make adjusing split sizes a bit more friendly
noremap <silent> <C-Left> :vertical resize +3<CR>
noremap <silent> <C-Right> :vertical resize -3<CR>
noremap <silent> <C-Up> :resize +3<CR>
noremap <silent> <C-Down> :resize -3<CR>
" Change 2 split windows from vert to horiz or horiz to vert
map <Leader>th <C-w>t<C-w>H
map <Leader>tk <C-w>t<C-w>K
" Removes pipes | that act as seperators on splits
" set fillchars+=vert:\
"" Git
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Git commit --verbose<CR>
noremap <Leader>gsh :Git push<CR>
noremap <Leader>gll :Git pull<CR>
noremap <Leader>gs :Git<CR>
noremap <Leader>gb :Git blame<CR>
noremap <Leader>gd :Gvdiffsplit<CR>
noremap <Leader>gr :GRemove<CR>
" session management
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>
" snippets
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"" Buffer nav
noremap <leader>z :bp<CR>
noremap <leader>q :bp<CR>
noremap <leader>x :bn<CR>
noremap <leader>w :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Switching windows
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h
"" save & exit
noremap <leader>e :wq<CR>
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
"" Open current line on GitHub
nnoremap <Leader>o :.GBrowse<CR>
"" Include user's local vim config
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Other Stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:python_highlight_all = 1
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar