-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
212 lines (183 loc) · 5.52 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
if !&compatible
set nocompatible
endif
" vim-plug {{{
if empty(glob('~/.vim/autoload/plug.vim'))
silent !mkdir -p ~/.vim/autoload ~/.vim/plugged
silent !git clone https://github.com/junegunn/vim-plug.git ~/.vim/plugged/vim-plug/
silent !ln -s ~/.vim/plugged/vim-plug/plug.vim ~/.vim/autoload/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'Shougo/vimproc.vim', {'do': 'make'}
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'w0ng/vim-hybrid'
Plug 'tpope/vim-surround'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'itchyny/lightline.vim'
Plug 'Shougo/neocomplete.vim'
Plug 'Shougo/neosnippet-snippets' | Plug 'Shougo/neosnippet.vim'
Plug 'neomake/neomake'
Plug 'posva/vim-vue', {'for': 'vue'}
Plug 'elixir-lang/vim-elixir', {'for': 'elixir'}
let s:plugs = {'plugs': get(g:, 'plugs', {})}
function! s:plugs.is_installed(name)
return has_key(self.plugs, a:name) ? isdirectory(self.plugs[a:name].dir) : 0
endfunction
call plug#end()
" }}}
set encoding=utf8
set fileencoding=utf-8
set autoread
set noswapfile
set relativenumber
set ruler
set backspace=indent,eol,start
set list
set listchars=tab:»-,trail:-,nbsp:%,eol:↲
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set smarttab
set autoindent
set showtabline=2
set laststatus=2
set cursorline
set t_ut=
" Languages
" Elixir
imap >> \|><Space>
" Plugins
if s:plugs.is_installed('vim-hybrid')
set background=dark
colorscheme hybrid
endif
if s:plugs.is_installed('neosnippet.vim')
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
endif
if s:plugs.is_installed('neocomplete.vim')
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ }
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
endif
if s:plugs.is_installed('vim-gitgutter')
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '~'
let g:gitgutter_sign_removed = '-'
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
endif
if s:plugs.is_installed('vim-fugitive')
nnoremap <silent> <Leader>gb :Gblame<CR>
nnoremap <silent> <Leader>gd :Gdiff<CR>
nnoremap <silent> <Leader>gs :Gstatus<CR>
endif
if s:plugs.is_installed('lightline.vim')
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'mode_map': {'c': 'NORMAL'},
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['fugitive', 'gitgutter', 'filename'],
\ ],
\ },
\ 'component_function': {
\ 'mode': 'MyMode',
\ 'modified': 'MyModified',
\ 'gitgutter': 'MyGitGutter',
\ 'fugitive': 'MyFugitive',
\ },
\ }
function! MyModified()
return &ft =~ 'vim-plug\|help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyMode()
return winwidth('.') > 60 ? lightline#mode() : ''
endfunction
function! MyFugitive()
try
if &ft !~? 'vim-plug\|vimfiler\|gundo' && exists('*fugitive#head')
let _ = fugitive#head()
return _
endif
catch
endtry
return ''
endfunction
function! MyGitGutter()
if ! exists('*GitGutterGetHunkSummary')
\ || ! get(g:, 'gitgutter_enabled', 0)
\ || winwidth('.') <= 90
return ''
endif
let symbols = [
\ g:gitgutter_sign_added . ' ',
\ g:gitgutter_sign_modified . ' ',
\ g:gitgutter_sign_removed . ' '
\ ]
let hunks = GitGutterGetHunkSummary()
let ret = []
for i in [0, 1, 2]
if hunks[i] > 0
call add(ret, symbols[i] . hunks[i])
endif
endfor
return join(ret, ' ')
endfunction
endif
if s:plugs.is_installed('ctrlp.vim')
let g:ctrlp_show_hidden = 1
if executable('ag')
let g:ctrlp_use_caching=0
let g:ctrlp_max_files = 15000
let g:ctrlp_user_command='ag %s --hidden -i --nocolor --nogroup -g "" --ignore .git'
endif
endif
if s:plugs.is_installed('neomake')
autocmd! BufWritePost * Neomake
let g:neomake_error_sign = {'text': '>>', 'texthl': 'Error'}
let g:neomake_warning_sign = {'text': '>>', 'texthl': 'Todo'}
" elixir
let g:neomake_elixir_enabled_makers = ['mycredo']
function NeomakeCredoErrorType(entry)
if a:entry.type ==# 'F' " Refactoring opportunities
let type = 'W'
elseif a:entry.type ==# 'D' " Software design suggestions
let type = 'I'
elseif a:entry.type ==# 'W' " Warnings
let type = 'W'
elseif a:entry.type ==# 'R' " Readability suggestions
let type = 'I'
elseif a:entry.type ==# 'C' " Convention violation
let type = 'W'
else
let type = 'M' " Everything else is a message
endif
let a:entry.type = type
endfunction
let g:neomake_elixir_mycredo_maker = {
\ 'exe': 'mix',
\ 'args': ['credo', 'list', '--strict', '%:p', '--format=oneline'],
\ 'errorformat': '[%t] %. %f:%l:%c %m,[%t] %. %f:%l %m',
\ 'postprocess': function('NeomakeCredoErrorType')
\ }
endif
if s:plugs.is_installed('nerdtree')
nnoremap <silent><F2> :NERDTreeToggle<CR>
endif