-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
322 lines (265 loc) · 8.73 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
filetype off
"set noncompatible
set rtp+=~/.vim/bundle/Vundle.vim
set rtp+=~/.vim/bundle/hoon.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/vimshell.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'Glench/Vim-Jinja2-Syntax'
Plugin 'vim-syntastic/syntastic'
Plugin 'Xe/lolcode.vim'
"Plugin 'Valloric/YouCompleteMe'
Plugin 'leafo/moonscript-vim'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'junegunn/goyo.vim'
Plugin 'tpope/vim-surround'
"Plugin 'nsf/gocode', {'rtp','.vim/'}
Plugin 'tpope/vim-fugitive'
Plugin 'morhetz/gruvbox'
Plugin 'vim-ruby/vim-ruby'
Plugin 'fatih/vim-go'
Plugin 'Matt-Deacalion/vim-systemd-syntax'
Plugin 'yosssi/vim-gcss'
Plugin 'kchmck/vim-coffee-script'
Plugin 'digitaltoad/vim-pug'
Plugin 'eagletmt/neco-ghc'
Plugin 'dag/vim2hs'
Plugin 'eagletmt/ghcmod-vim'
Plugin 'rust-lang/rust.vim'
Plugin 'mattn/webapi-vim'
Plugin 'yosssi/vim-ace'
Plugin 'zah/nim.vim'
Plugin 'chakrit/upstart.vim'
Plugin 'embear/vim-localvimrc'
Plugin 'dpwright/vim-tup'
Plugin 'mattn/go-errcheck-vim'
"Plugin 'm2mdas/phpcomplete-extended'
Plugin 'vimwiki/vimwiki'
Plugin 'exu/pgsql.vim'
Plugin 'gilgigilgil/anderson.vim'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-lua-ftplugin'
Plugin 'rubik/vim-dg'
Plugin 'elmcast/elm-vim'
Plugin 'dag/vim-fish'
Plugin 'ackyshake/VimCompletesMe'
call vundle#end()
set t_Co=256
"colorscheme desert
colorscheme gruvbox
syntax on
filetype plugin indent on
set whichwrap=<,>,[,],b,
set backspace=indent,eol,start
set cursorcolumn
set cursorline
set background=dark
set autoread
set mouse=a
set showcmd " Show commands as they're being typed
set number
set relativenumber
" Set backup off, as most of the stuff is in VCS, git, SVN
set nobackup
set nowb
set noswapfile
" Enable C spacing for C-like languages
" Thank you Xe, jdhore
set ai
au BufRead,BufNewFile *.c,*.cpp,*.cxx,*.hpp,*.c++,*.hh,*.hxx,*.ipp,*.moc,*.tcc,*.inl set cindent
au BufRead,BufNewFile *.c,*.cpp,*.cxx,*.hpp,*.c++,*.hh,*.hxx,*.ipp,*.moc,*.tcc,*.inl set tabstop=8
au BufRead,BufNewFile *.c,*.cpp,*.cxx,*.hpp,*.c++,*.hh,*.hxx,*.ipp,*.moc,*.tcc,*.inl set shiftwidth=8
set cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
" Other Language specific hacks: Python
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4
" Lolcode is special
au Filetype lolcode setl et ts=4 sw=4
" so is Elixir
au Filetype elixir setl et ts=2 sw=2
" Make lua have ruby spacing for reading
au Filetype lua setl et ts=2 sw=2
" Erlang!
au Filetype erlang setl et ts=4 sw=4
" Oh nim
au Filetype nim setl et ts=2 sw=2
au BufRead,BufNewFile *.nimble set filetype=nim
au BufRead,BufNewFile *.nims set filetype=nim
" moonscript is cool too
au Filetype moon setl et ts=2 sw=2
au BufWrite moon call s:RunShellCommand('moonc -l')
" Coffeescript is goodness
au Filetype coffee setl et ts=2 sw=2
" Go!
au Filetype go setl noet ts=4 sw=4
" Yaml
au Filetype yaml setl et ts=2 sw=2
" Haskell
au Filetype haskell setlocal omnifunc=necoghc#omnifunc
au Filetype haskell setl et ts=4 sw=4
" Cabal
au Filetype cabal setl et ts=2 sw=2
" Emails should wrap at 75 characters to allow for replies on an 80 character
" terminal
au Filetype mail let &colorcolumn="70,75"
au Filetype mail set spell
au Filetype mail setlocal textwidth=75
au Filetype mail set expandtab
" APKBUILD files have spacing like python
au BufRead APKBUILD setl noexpandtab softtabstop=0 tabstop=4 shiftwidth=4 nosmarttab
" .tmpl files
au BufRead,BufNewFile *.tmpl set filetype=gotmplhtml
" Make tabs visible
set list
set listchars=tab:>-,trail:~,extends:>,precedes:<
" Default Settings
set tabstop=2
set softtabstop=2
set shiftwidth=2
set encoding=utf-8
" Append modeline after last line in buffer
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline,
"")
call append(line("$"), l:modeline)
endfunction
command WQ wq
command Wq wq
command W w
command Q q
set wildmenu
set wildignore=*.o,*~,*.pyc
" Delete extraspaces 4 at a time
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
match ExtraWhitespace /\s\+$\| \+\ze\t/
" Paste macros
" Thanks to Xe adn jdhore
map <F8> :set paste<CR>
map <F9> :set nopaste<CR>
imap <F8> <C-O>:set paste<CR>
imap <F9> <nop>
set pastetoggle=<F9>
map <F3> gg=G:w<cr>
" status line
set ls=2
set statusline=%F%m%r%h%w\ >\ FORMAT=%{&ff}\ >\ TYPE=%Y\ >\ BUF=\#%n\ <\POS=%04l,%04v\ <\ %p%%\ <\ LEN=%L
" Color column definition
" let &colorcolumn="80"
highlight ColorColumn ctermbg=58
" resume at line
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" textfiles at 78 cols
autocmd BufNewFile,BufRead *.txt
\ if &tw == 0 && ! exists("g:leave_my_textwidth_alone") |
\ setlocal textwidth=78 |
\ endif
" Delete trailing whitespace on save, useful for python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
" Gist
let g:gist_clip_command = 'xclip -selection clipboard'
let g:gist_show_privates = 1
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
let g:gist_post_private = 1
" Airline
let g:airline#extensions#tabline#enabled = 0
let g:airline_powerline_fonts = 0
let g:airline_theme = 'deus'
" Macvim
set guioptions-=r
" Leader
let mapleader = " "
let g:mapleader = " "
" Highlight a line to read over later
nnoremap <silent> <leader>l ml:execute 'match Search /\%'.line('.').'l/'<CR>
nmap <leader>w :w!<cr>
nmap <leader>d :call DeleteTrailingWS()<cr>
nmap <leader>rt :retab<cr>
nmap <leader>g :Gist<cr>
noremap <silent> <leader>ml :call AppendModeline()<CR>
nmap <leader>sp gg=G:w<cr>
noremap <leader>c :Goyo<CR>
nmap <leader>gf :%!gofmt<CR>
" Spellchecking
map <leader>ss :setlocal spell!<cr>
" License
let g:licenses_authors_name = 'Nasir Hussain <[email protected]>'
" Goyo
function! Goyo_before()
silent !tmux set status off
set noshowmode
set noshowcmd
" ...
endfunction
function! Goyo_after()
silent !tmux set status on
set showmode
set showcmd
" ...
endfunction
let g:goyo_callbacks = [function('Goyo_before'), function('Goyo_after')]
" Use current directory as vimshell prompt
let g:vimshell_prompt_expr =
\ 'escape(fnamemodify(getcwd(), ":~").">", "\\[]()?! ")." "'
let g:vimshell_prompt_pattern = '^\%(\f\|\\.\)\+> '
let g:ycm_semantic_triggers = {'haskell' : ['.']}
let g:go_fmt_command = "goimports"
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'brown', 'darkblue', 'darkgray', 'darkgreen', 'darkred', 'darkmagenta', 'darkred'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
let g:rainbow_active = 1 " 0 if you want to enable it later via :RainbowToggle
let g:vimwiki_list = [{'path': '~/src/vimwiki/'}]
function RangerExplorer()
exec "silent !ranger --choosefile=/tmp/vim_ranger_current_file ". expand("%:p:h")
if filereadable('/tmp/vim_ranger_current_file')
exec 'edit '. system('cat /tmp/vim_ranger_current_file')
call system('rm /tmp/vim_ranger_current_file')
endif
redraw!
endfun
map <Leader>x :call RangerExplorer()<CR>
" play.rust-lang configuration
let g:rust_clip_command = 'xclip -selection clipboard'
" Golang
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" VimCompletesMe
autocmd FileType vim let b:vcm_tab_complete = 'vim'
autocmd FileType go let b:vcm_tab_complete = 'go'