forked from peikk0/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
315 lines (257 loc) · 7 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
" peikk0's vimrc
" Load plugins on Vim 7
if !has("packages")
runtime pack/vendor/opt/pathogen/autoload/pathogen.vim
execute pathogen#infect()
endif
syntax on
filetype plugin indent on
if has("terminfo") || has("nvim")
if has("packages")
packadd base16
endif
set t_Co=256
set background=dark
let base16colorspace=256
colorscheme base16-default-dark
end
set nocompatible
set modeline
set modelines=5 " Debian likes to disable this
set backspace=indent,eol,start
set nobackup
set noundofile
set swapfile
set autoread
set updatetime=100
set title
set shortmess=aoOtTI
set wildmenu
set wildmode=longest:full,full
set viminfo='20,\"500,h
set history=50
set fileencodings=utf-8,latin1,default
set fileformats=unix,dos,mac
set shiftwidth=4
set expandtab
set smarttab
set autoindent
set smartindent
set omnifunc=syntaxcomplete#Complete
let showbreak="> "
set list
if (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8') && version >= 700
let &listchars="tab:\u21e5\u2010,trail:\u2022,extends:\u21c9,precedes:\u21c7,nbsp:\u2423"
let &fillchars="vert:\u259a,fold:\u00b7"
else
set listchars=tab:>-,trail:~,extends:>,precedes:<,nbsp:_
endif
set selection=inclusive
set virtualedit=block
set number
set numberwidth=3
set cursorline
set ruler
set showcmd
set laststatus=2
set colorcolumn=80
set hlsearch
set incsearch
set ignorecase
set smartcase
set scrolloff=3
set sidescrolloff=5
set scrolljump=1
set completeopt=longest,menu
set diffopt+=vertical
set timeoutlen=250
set mouse=
set shell=/bin/sh
set grepprg=grep\ -nH\ $*
function! OpenURL(url)
if $DISPLAY !~ '^\w'
exe "silent !sensible-browser \"".a:url."\""
else
exe "silent !sensible-browser -T \"".a:url."\""
endif
redraw!
endfunction
command! -nargs=1 OpenURL :call OpenURL(<q-args>)
" open URL under cursor in browser
nnoremap gb :OpenURL <cfile><CR>
nnoremap gG :OpenURL http://www.google.com/search?q=<cword><CR>
nnoremap gW :OpenURL http://en.wikipedia.org/wiki/Special:Search?search=<cword><CR>
if has("autocmd")
autocmd FileType go setlocal shiftwidth=8 tabstop=8 noexpandtab
autocmd FileType html setlocal shiftwidth=2 tabstop=2
autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2
autocmd FileType man setlocal nolist
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
autocmd FileType text setlocal textwidth=78
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
" use XHTML and CSS with :TOhtml
let use_xhtml=1
let html_use_css=1
let html_ignore_folding=1
let html_use_encoding="UTF-8"
" === Plugins ===
" Load all packages on Vim >= 8
if has("packages")
packloadall
endif
" airline
let g:airline_theme='base16_default'
let g:airline_powerline_fonts = 1
let g:airline_left_sep = "\uE0C6"
" let g:airline_left_alt_sep = "\uE0C6"
let g:airline_right_sep = "\uE0C7"
" let g:airline_right_alt_sep = "\uE0C7"
let g:airline_section_z = airline#section#create(['%3p%%'.g:airline_symbols.space, "\uE0A1" . '%{line(".")}' . "\uE0A3" . '%{col(".")}'])
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#show_tab_type = 0
" csv
let g:csv_table_leftalign=1
" gist
let g:gist_detect_filetype=1
let g:gist_open_browser_after_post=1
let g:gist_browser_command='sensible-browser %URL%'
let g:gist_clip_command='xclip -selection clipboard'
let g:gist_show_privates=1
" Man
runtime ftplugin/man.vim
" Match It
runtime macros/matchit.vim
" NERDTree
let NERDTreeIgnore = ['\.pyc$']
if has("autocmd")
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
endif
function! NTFinderP()
"" Check if NERDTree is open
if exists("t:NERDTreeBufName")
let s:ntree = bufwinnr(t:NERDTreeBufName)
else
let s:ntree = -1
endif
if (s:ntree != -1)
"" If NERDTree is open, close it.
:NERDTreeClose
else
"" Try to open a :Rtree for the rails project
if exists(":Rtree")
"" Open Rtree (using rails plugin, it opens in project dir)
:Rtree
else
"" Open NERDTree in the file path
:NERDTreeFind
endif
endif
endfunction
" netrw
let g:netrw_http_cmd="curl -s -o"
" Python
let python_highlight_builtins=1
let python_highlight_exceptions=1
let python_highlight_numbers=1
let python_highlight_space_errors=1
let g:pymode_doc=0
let g:pymode_options=0
let g:pymode_lint_checkers = ['pyflakes', 'pep8']
" Ruby
let ruby_operators=1
let g:rubycomplete_buffer_loading=1
let g:rubycomplete_classes_in_global=1
let g:rubycomplete_rails=1
" rails
let g:rails_gnu_screen=1
let g:rails_mappings=1
let g:rails_syntax=1
" rainbow
" let g:rainbow_active=1
" syntastic
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:syntastic_puppet_checkers=["puppet"]
let g:syntastic_puppet_puppetlint_args="--error-level error"
let g:syntastic_php_checkers=['php']
let g:syntastic_python_checkers=[]
let g:syntastic_tex_checkers=[]
function! SL(function)
if exists('*'.a:function)
return call(a:function,[])
else
return ''
endif
endfunction
set statusline=[%n]\ %<%f\ %y[%{&ff}][%{&fenc}]%h%w%r%m%{SL('fugitive#statusline')}%#ErrorMsg#%{SL('SyntasticStatuslineFlag')}%*%=%5l/%L%4c%V\ [0x%04B]
" terraform
let g:terraform_align=1
let g:terraform_fold_sections=1
let g:terraform_fmt_on_save=1
" === Mappings ===
inoremap jj <Esc>
map <silent> <F1> :call NTFinderP()<CR>
map <F5> <Esc>gg=G''
map <A-Right> gt
map <A-Left> gT
set pastetoggle=<F11>
" easy-align
nmap ga <Plug>(EasyAlign)
xmap ga <Plug>(EasyAlign)
" "" '' <> () [] {}
noremap! "" ""<esc>i
noremap! """ """"""<esc>hhi
noremap! '' ''<esc>i
noremap! << <><esc>i
noremap! </ </><esc>i
noremap! <</ </><esc>hi
noremap! <<! <!-- --><esc>hhhi
noremap! <% <% %><esc>hhi
noremap! <%= <%= %><esc>hhi
noremap! (( ()<left>
noremap! (<cr> (<cr>)<c-o>O
noremap! (; ();<esc>hi
noremap! (<cr>; (<cr>);<c-o>O
noremap! ('; ('');<esc>hhi
noremap! ("; ("");<esc>hhi
noremap! (' ('')<esc>hi
noremap! (" ("")<esc>hi
noremap! {{ {}<left>
noremap! {<cr> {<cr>}<c-o>O
noremap! {; {};<esc>hi
noremap! {<cr>; {<cr>};<c-o>O
noremap! {'; {''};<esc>hhi
noremap! {"; {""};<esc>hhi
noremap! {' {''}<esc>hi
noremap! {" {""}<esc>hi
noremap! {# {# #}<esc>hhi
noremap! {% {% %}<esc>hhi
noremap! {{% {{ }}<esc>hhi
noremap! {{{ {{{ }}}<esc>hhhi
noremap! {{{<cr> {{{ <cr>}}}<esc>kA
noremap! [[ []<left>
noremap! [<cr> [<cr>]<c-o>O
noremap! [; [];<esc>hi
noremap! [<cr>; [<cr>];<c-o>O
noremap! ['; [''];<esc>hhi
noremap! ["; [""];<esc>hhi
noremap! [' ['']<esc>hi
noremap! [" [""]<esc>hi
if exists(":nohls")
nnoremap <silent> <C-L> :nohls<CR><C-L>
endif
" === LOCAL ===
if filereadable(glob("~/.vimrc.local"))
source ~/.vimrc.local
endif
" vim:ft=vim:sw=2:ts=2:et