-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·306 lines (236 loc) · 7.81 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
" ##############################################################################
" VIM general config
" ##############################################################################
"
set shell=/bin/bash
set nocompatible
set clipboard=unnamedplus
" Use aliases
let $BASH_ENV="~/.bash_aliases"
" Set to auto read when a file is changed from the outside
set autoread
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
" Cue the magic (regex)
set magic
" Buffers can be hidden (not have to explicitly write, etc...)
set hidden
" Shhh
set visualbell
set noerrorbells
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugins
filetype plugin on
" Set 5 lines - when moving vertically using j/k
set so=5
" Turn on the WiLd menu (vim cmd auto-complete w/ tab)
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,*dist/*,*tmp/*,*build/*,*.DS_Store
" Always show current position
set ruler
" Title terminal with name of file
set title
" Set line num
set number
set relativenumber
" Height of the command bar
set cmdheight=1
" Show command status
set showcmd
" Be careful, and you can avoid this backup annoyingness
set nobackup
set nowb
set noswapfile
" Show matching brackets
set showmatch
set mat=2 " tenths of seconds
" Set utf8 as standard encoding and en_US as the standard language
set encoding=UTF-8
" Use Unix as the standard file type
set ffs=unix,dos,mac
set diffopt+=vertical
" Increase memory limit for pattern matching
set mmp=5000
" ##############################################################################
" Plugins
" ##############################################################################
call plug#begin()
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-scriptease'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
" Plug 'junegunn/gv.vim'
" Plug 'mhinz/vim-signify'
" Plug 'idanarye/vim-merginal'
" Plug 'sodapopcan/vim-twiggy'
" Plug 'w0rp/ale'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'svermeulen/vim-easyclip'
" Plug 'jpalardy/vim-slime'
" Plug 'mileszs/ack.vim'
" Plug 'hynek/vim-python-pep8-indent'
" Plug 'pangloss/vim-javascript'
" Plug 'mxw/vim-jsx'
" Plug 'davidhalter/jedi-vim'
Plug 'christoomey/vim-tmux-navigator'
" Plug 'walkermatt/vim-mapfile'
" Plug 'rodjek/vim-puppet'
" Plug 'godlygeek/tabular'
" Plug 'tell-k/vim-autopep8'
Plug 'vim-scripts/paredit.vim'
" Plug 'SirVer/ultisnips'
" Plug 'honza/vim-snippets'
" Plug 'vim-scripts/Solarized'
" Plug 'leafgarland/typescript-vim'
" Plug 'Rykka/riv.vim'
" Plug 'Rykka/InstantRst'
" Plug 'vim-pandoc/vim-pandoc'
" Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'arcticicestudio/nord-vim', { 'branch': 'develop' }
" Plug 'vim-scripts/diffchar.vim'
" Plug 'jeffkreeftmeijer/vim-numbertoggle'
Plug 'ryanoasis/vim-devicons'
" Plug 'mhinz/vim-startify'
Plug 'itchyny/lightline.vim'
" Plug 'ambv/black'
" Plug 'fisadev/vim-isort'
" Plug 'szymonmaszke/vimpyter'
" Plug 'neilagabriel/vim-geeknote'
" Plug 'fmoralesc/vim-tutor-mode'
" Plug 'fmoralesc/vim-pad'
" Plug 'wallinb/notational-fzf-vim'
call plug#end()
" ##############################################################################
" Key binds
" ##############################################################################
let mapleader=","
let maplocalleader=","
" Disable arrows, must not show weakness
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Swap ; and : Convenient.
" nnoremap ; :
" nnoremap : ;
" remap jj to escape in insert mode
inoremap jj <Esc>
" This unsets the "last search pattern" register by hitting return
nnoremap <CR> :noh<CR><CR>
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
" And commands can wrap
set whichwrap+=<,>,h,l
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
nnoremap <F7> "=strftime("%c")<CR>P
inoremap <F7> <C-R>=strftime("%c")<CR>
" ##############################################################################
" Filetype
" ##############################################################################
au BufRead,BufNewFile *.map,*.sym set filetype=mapfile
" ##############################################################################
" Look
" ##############################################################################
" Allows transparent background
" hi Normal ctermbg=none
" Folding
syntax enable
set foldmethod=manual
set foldlevel=99
hi Folded ctermfg=250
hi Folded ctermbg=236
" Statusline
set laststatus=2
set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ Col:\ %c
set statusline+=\ %#warningmsg#
set statusline+=\ %*
function! MyFoldText()
let line=getline(v:foldstart)
return '↸ ' . line
endfunction
set foldtext=MyFoldText()
" ##############################################################################
" Search related
" ##############################################################################
set grepprg=grep\ -nH\ $*
" Ignore case when searching
set ignorecase
" all lower -> insensitive, any upper -> sensitive
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" allows incsearch highlighting for range commands
cnoremap $t <CR>:t''<CR>
cnoremap $T <CR>:T''<CR>
cnoremap $m <CR>:m''<CR>
cnoremap $M <CR>:M''<CR>
cnoremap $d <CR>:d<CR>``
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
function! VisualSelection(direction) range
let l:saved_reg=@"
execute "normal! vgvy"
let l:pattern=escape(@", '\\/.*$^~[]')
let l:pattern=substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/=l:pattern
let @"=l:saved_reg
endfunction
" ##############################################################################
" Tab behavior
" ##############################################################################
" Use spaces instead of tabs
set expandtab
" 1 tab == 4 spaces
set shiftwidth=4
set softtabstop=4
filetype indent on
set autoindent " Basic auto-indent
" ##############################################################################
" Wrapping
" ##############################################################################
set wrap
set linebreak "Only at linebreak
set nolist " list disables linebreak
set textwidth=0
set wrapmargin=0
" ##############################################################################
" Auto commands
" ##############################################################################
autocmd FileType c,cpp,java,php,python,puppet autocmd BufWritePre <buffer> %s/\s\+$//e
" Tab behavior for filetypes
autocmd FileType html,htmldjango,xml,javascript,yaml,css setlocal shiftwidth=2 tabstop=2 softtabstop=2
" When vimrc is edited, reload it
autocmd! bufwritepost .vimrc source %