-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
295 lines (238 loc) · 8.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
filetype plugin on
syntax on
let mapleader=','
call plug#begin('~/.vim/bundle')
Plug 'https://bitbucket.org/bliof/snowlight.git'
Plug 'https://github.com/AndrewRadev/switch.vim.git'
Plug 'https://github.com/StanAngeloff/php.vim.git'
Plug 'https://github.com/benmills/vimux.git'
Plug 'https://github.com/bling/vim-airline.git'
Plug 'https://github.com/chrisbra/Colorizer.git'
Plug 'https://github.com/chrisbra/vim-diff-enhanced'
Plug 'https://github.com/embear/vim-localvimrc.git'
Plug 'https://github.com/google/vim-jsonnet.git'
Plug 'https://github.com/jnwhiteh/vim-golang.git'
Plug 'https://github.com/junegunn/fzf.git', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'https://github.com/junegunn/fzf.vim.git'
Plug 'https://github.com/junegunn/goyo.vim.git'
Plug 'https://github.com/junegunn/vim-peekaboo.git'
Plug 'https://github.com/kchmck/vim-coffee-script.git'
Plug 'https://github.com/majutsushi/tagbar.git'
Plug 'https://github.com/mattn/emmet-vim.git'
Plug 'https://github.com/mbbill/undotree.git'
Plug 'https://github.com/mhinz/vim-startify.git'
Plug 'https://github.com/morhetz/gruvbox.git'
Plug 'https://github.com/rhysd/devdocs.vim'
Plug 'https://github.com/scrooloose/nerdcommenter.git'
Plug 'https://github.com/scrooloose/syntastic.git'
Plug 'https://github.com/sheerun/vim-polyglot.git'
Plug 'https://github.com/skalnik/vim-vroom.git'
Plug 'https://github.com/slim-template/vim-slim.git'
Plug 'https://github.com/tpope/vim-fugitive.git'
Plug 'https://github.com/tpope/vim-rails.git'
Plug 'https://github.com/tpope/vim-repeat.git'
Plug 'https://github.com/tpope/vim-surround.git'
Plug 'https://github.com/tpope/vim-unimpaired.git'
Plug 'https://github.com/veloce/vim-aldmeris.git'
Plug 'https://github.com/vim-airline/vim-airline-themes.git'
Plug 'https://github.com/vim-perl/vim-perl.git', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
call plug#end()
"set nocdsfgdfsgompatible
set backupdir=~/.vim/backup,.
set directory=~/.vim/backup,.
set undodir=~/.vim/backup,.
set undofile
set hlsearch
set incsearch
set smartcase
set autowrite
set autoindent
set smartindent
filetype indent on
set smarttab
set complete-=i
set pastetoggle=<F4>
set foldmethod=marker
set wildmenu
set nomodeline
set noautochdir
set shiftwidth=4
set softtabstop=4
set expandtab
set backspace=indent,eol,start
set termguicolors
" fixes vim and tmux background color problems
if &term =~ '256color'
set t_ut=
endif
set t_Co=256
if $COLORSCHEME == 'dark'
set background=dark
colorscheme gruvbox
let g:gruvbox_contrast_dark='hard'
else
set background=light
colorscheme snowlight
endif
nnoremap <c-a> ^
inoremap <c-a> <esc>^I
nnoremap <c-e> $
inoremap <c-e> <esc>$i
nnoremap - o<esc>
nnoremap _ O<esc>
vnoremap <c-c> "-y<ESC>
inoremap <c-v> <ESC>"+Pa
" make tab in v mode ident code
vnoremap <tab> >gv
vnoremap <s-tab> <gv
vnoremap <c-c> "+y<ESC>
inoremap <c-v> <ESC>"+Pa
" make tab in normal mode ident code
nnoremap <tab> I<tab><esc>
nnoremap <s-tab> ^i<bs><esc>
inoremap <c-h> <ESC> :bp <CR>
inoremap <c-l> <ESC> :bn <CR>
nnoremap <silent> <c-h> :bp <CR>
nnoremap <silent> <c-l> :bn <CR>
"nnoremap <F3> :buffers<CR>:buffer<Space>
" Swap the word under the cursor and the cursor stay at the begining of the new word under the cursor
nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><C-o>:noh<CR>
" Swap the word under the cursor position with the one on the left and move the cursor to the new position
nnoremap <silent> gl "_yiw?\w\+\_W\+\%#<CR>:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>:noh<CR>
" Swap the word under the cursor position with the one on the right and move the cursor to the new position
nnoremap <silent> gr "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><c-o>/\w\+\_W\+<CR><c-l>:noh<CR>
"sudo save
cmap w!! %!sudo tee > /dev/null %
augroup FileTypeOptions
autocmd!
autocmd FileType yaml,haml,ruby,coffee setlocal sw=2 sts=2 ts=2
autocmd FileType xsd,xml,html,eruby setlocal sw=2 sts=2 ts=2
autocmd FileType jade,css,scss,ts,tsx,typescript,typescriptreact setlocal sw=2 sts=2 ts=2
autocmd FileType javascript setlocal sw=2 sts=2 ts=2
autocmd FileType go setlocal noet sw=4 sts=4 ts=4
autocmd FileType tex setlocal noet sw=4 sts=4 ts=4
autocmd FileType cpp setlocal sw=4 sts=4 ts=4
autocmd FileType python autocmd BufWritePre <buffer> :Yapf
augroup END
augroup SpellCheck
autocmd!
autocmd FileType gitcommit setlocal spell
autocmd FileType markdown setlocal spell
autocmd FileType text setlocal spell
augroup END
let perl_include_pod = 1
let perl_extended_vars = 1
function! s:FixWhitespace(line1,line2)
let l:save_cursor = getpos(".")
silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//'
call setpos('.', l:save_cursor)
endfunction
" Run :FixWhitespace to remove end of line white space.
command! -range=% FixWhitespace call <SID>FixWhitespace(<line1>,<line2>)
autocmd InsertLeave * match Error /\(\s\+$\|\t \| \t\)/
set listchars=
set list
"======================================================================
" Plugins config
"======================================================================
function! s:find_git_root()
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
endfunction
command! ProjectFiles execute 'Files' s:find_git_root()
set rtp+=~/.fzf
let g:fzf_layout = { 'down': '~30%' }
nnoremap <silent> <C-p> :ProjectFiles<CR>
command! -bang -nargs=* Ag
\ call fzf#vim#grep(
\ 'ag --nogroup --column --color --color-line-number "15" --color-match "106" --color-path "1;15" '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
noremap <leader>a :Ag! <C-r>=expand('<cword>')<CR><CR>
nnoremap <F3> :Buffers<CR>
nnoremap <F1> :TagbarToggle<CR>
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|\.hg|\.svn|tmp\/cache|mnesia)$',
\ 'file': '\v\.(exe|so|dll|cache|jpg|gif|png|pdf|woff|ttf|eot|doc|ico)$',
\ }
let g:notes_directories = ['~/Documents/notes']
let g:encodingOptions = ['cp1251']
" localvimrc
let g:localvimrc_sandbox = 0
let g:localvimrc_persistent = 1
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
let g:airline_theme = 'lucius'
let g:ctrlp_reuse_window = 'startify'
let g:startify_change_to_vcs_root = 1
let g:startify_custom_header = map(split(system('vim --version | head -n 4'), '\n'), '" ". v:val') + ['', '', '']
let g:startify_custom_footer = ['', '', '', ' Onward through the mist.']
let g:startify_list_order = [
\ [' MRU (here):'],
\ 'dir',
\ [' MRU:'],
\ 'files',
\ [' Sessions:'],
\ 'sessions',
\ [' Bookmarks:'],
\ 'bookmarks',
\ ]
let g:startify_bookmarks = [
\ '~/.vimrc',
\ ]
if $COLORSCHEME != 'dark'
hi StartifyBracket ctermfg=245
hi StartifyFile ctermfg=24
hi StartifyFooter ctermfg=0
hi StartifyHeader ctermfg=0
hi StartifyNumber ctermfg=0
hi StartifyPath ctermfg=238
hi StartifySlash ctermfg=238
hi StartifySpecial ctermfg=24
endif
nnoremap <F2> :UndotreeToggle<CR>:UndotreeFocus<CR>
let g:undotree_WindowLayout=2
let g:goyo_width=100
function! s:Presentation()
set nospell
hi Error NONE
call goyo#execute(0, 120)
endfunction
command! Presentation call <SID>Presentation()
let g:VimuxOrientation="h"
let g:vroom_map_keys=0
let g:vroom_use_vimux=1
map <unique> <Leader>t :VroomRunTestFile<CR>
map <unique> <Leader>s :VroomRunNearestTest<CR>
map <unique> <Leader>l :VroomRunLastTest<CR>
map <Leader>p :VimuxPromptCommand<CR>
nmap <Leader>m <Plug>(devdocs-under-cursor)
vnoremap u <Nop>
noremap ~ <Nop>