-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
321 lines (259 loc) · 7.55 KB
/
vimrc
File metadata and controls
321 lines (259 loc) · 7.55 KB
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
"Set $VIMDIR if unset
if empty($VIMDIR)
if has('nvim')
let $VIMDIR = glob('~/.config/nvim')
else
let $VIMDIR = glob('~/.vim')
end
end
"Install vimplug, if not present
if empty(glob($VIMDIR . '/autoload/plug.vim'))
silent !curl -fLo $VIMDIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
call mkdir($VIMDIR . '/spell', 'p')
call mkdir($VIMDIR . '/undo', 'p')
call mkdir($VIMDIR . '/tmp', 'p')
call mkdir($VIMDIR . '/backup', 'p')
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin($VIMDIR . '/plugged')
"Well it's only sensible
Plug 'tpope/vim-sensible'
"Colour scheme
Plug 'morhetz/gruvbox'
"Airline
Plug 'bling/vim-airline'
function! UpdatePowerlineFonts(info)
if a:info.status != 'unchanged'
!./install.sh
endif
endfunction
Plug 'powerline/fonts', { 'dir': $VIMDIR . '/fonts/powerline', 'do': function('UpdatePowerlineFonts') }
function! UpdateJetBrainsMono(info)
if a:info.status != 'unchanged'
let os = substitute(system('uname'), '\n', '', '')
if os == 'Linux'
!cp fonts/ttf/*.ttf "$HOME/.local/share/fonts"
!fc-cache -f "$HOME/.local/share/fonts"
elseif os == 'Darwin'
!cp fonts/ttf/*.ttf "$HOME/Library/Fonts"
endif
endif
endfunction
Plug 'JetBrains/JetBrainsMono', { 'dir': $VIMDIR . '/fonts/jetbrainsmono', 'do': function('UpdateJetBrainsMono') }
"Operate on sandwiches
Plug 'machakann/vim-sandwich'
"Line numbers
set number
Plug 'jeffkreeftmeijer/vim-numbertoggle'
"Automatic syntax checking
Plug 'dense-analysis/ale'
"Ignore long lines and bare excepts are OK
let ale_python_flake8_options = "--ignore=E501,E722"
let ale_puppet_puppetlint_options = '--no-140chars-check --no-arrow-alignment-check'
let ale_linters = { 'puppet': [ 'puppet', 'puppetlint' ] }
nnoremap <silent> <C-k> <Plug>(ale_previous_wrap)
nnoremap <silent> <C-j> <Plug>(ale_next_wrap)
"Only install YCM if we have cmake installed
if executable('cmake')
function! BuildYCM(info)
let l:install_command = [ '!python3 install.py --system-boost --all' ]
if a:info.status != 'unchanged'
execute join(l:install_command, ' ')
endif
endfunction
"Completer
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
let g:ycm_key_list_select_completion = [ '<Ctrl-n>' ]
let g:ycm_key_list_previous_completion = [ '<Ctrl-p>' ]
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
"Avoid peekaboo crash with YCM
let g:ycm_filetype_blacklist = { 'peekaboo': 1 }
"Snippets
Plug 'SirVer/ultisnips'
let g:UltiSnipsExpandTrigger="<c-j>"
Plug 'honza/vim-snippets'
let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', '~/.vim/plugged/vim-snippets/UltiSnips']
endif
"Comment stuff in and out
Plug 'tpope/vim-commentary'
"Git integration
Plug 'tpope/vim-fugitive'
" Display register content before selecting on
Plug 'junegunn/vim-peekaboo'
"Visual undo tree
Plug 'mbbill/undotree'
"I like to know far I have to go
Plug 'henrik/vim-indexed-search'
"Look at all the colours!
Plug 'junegunn/rainbow_parentheses.vim'
"Auto end stuff
Plug 'tpope/vim-endwise'
"Auto close parentheses
Plug 'townk/vim-autoclose'
" Fix omkompatibilyt with YCM
let g:AutoClosePumvisible = {"ENTER": "", "ESC": ""}
"Better search experience
Plug 'junegunn/vim-slash'
"Git stuff
Plug 'airblade/vim-gitgutter'
"Scratch buffer
Plug 'vim-scripts/scratch.vim'
"Align on stuff
Plug 'godlygeek/tabular'
"More text objects
Plug 'wellle/targets.vim'
"Naming things is challenging
function UpdatetThesaurus(info)
if a:info.status == 'installed'
execute '!cd $VIMDIR && curl -o the.zip https://www.openoffice.org/lingucomponent/MyThes-1.zip && unzip -o the.zip && rm -f the.zip'
endif
endfunction
Plug 'Ron89/thesaurus_query.vim', { 'do': function('UpdatetThesaurus') }
let g:tq_enabled_backends = [ 'openoffice_en', 'datamuse_com']
let g:tq_openoffice_en_file = $VIMDIR . '/MyThes-1.0/th_en_US_new'
let g:tq_online_backends_timeout = 0.4
"File browser
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
"REPL inside vim
Plug 'jpalardy/vim-slime'
let g:slime_target = "vimterminal"
"Golang
Plug 'fatih/vim-go', { 'for': 'go' }
augroup VimGo
autocmd!
autocmd User vim-go
\ set nolist |
\ let g:go_fmt_command = "goimports"
augroup END
"Ruby
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
"Python
Plug 'python-mode/python-mode', { 'for': 'python' }
"Puppet
Plug 'rodjek/vim-puppet' ", { 'for': 'puppet' }
augroup VimPuppet
autocmd!
autocmd User vim-puppet let g:puppet_align_hashes = 0
augroup END
"Rust
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
augroup RustVim
autocmd!
autocmd User rust.vim
\ let g:rustfmt_autosave = 1 |
\ FileType rust let b:AutoClosePairs = AutoClose#DefaultPairsModified("", "'")
augroup END
"Racket
Plug 'wlangstroth/vim-racket', { 'for': 'racket' }
Plug 'tpope/vim-sexp-mappings-for-regular-people', { 'for': 'racket' }
Plug 'guns/vim-sexp', { 'for': 'racket' }
augroup Racket
autocmd filetype racket
\ set lisp |
\ set autoindent |
\ :RainbowParentheses |
\ let b:AutoClosePairs = AutoClose#DefaultPairsModified("", "'")
augroup END
"Markdown
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
Plug 'reedes/vim-pencil', { 'for': 'markdown' }
augroup MarkdownPencil
autocmd!
autocmd User vim-pencil
\ let g:pencil#conceallevel = 0 |
\ let g:airline_section_x = '%{PencilMode()}' |
\ :call pencil#init({'wrap': 'hard', 'autoformat': 0})
augroup END
"Visual indent level
Plug 'nathanaelkane/vim-indent-guides'
let g:indent_guides_default_mapping = 1
augroup VimIndentGuides
autocmd!
autocmd FileType python,json,yaml
\ IndentGuidesEnable
augroup END
"Support some of all the other languages!
Plug 'sheerun/vim-polyglot'
let g:polyglot_disabled = ['go', 'ruby', 'python', 'puppet', 'rust', 'racket' ]
call plug#end()
set hidden
set ignorecase
set smartcase
set hlsearch
set showcmd
set visualbell
"Quiet error on installation
try
"Override highligthing of trailing spaces
augroup HLtrailing
autocmd!
if has('nvim')
autocmd ColorScheme * highlight link Whitespace Error
else
autocmd ColorScheme * highlight link SpecialKey Error
end
augroup END
colorscheme gruvbox
catch
endtry
set background=dark
let g:airline_theme = 'gruvbox'
"We have powerline fonts
let g:airline_powerline_fonts = 1
if has('gui_running')
"Turn off tool bar
set guioptions-=T
"Turn off scrollbar
set guioptions-=r
set cursorline
if has("gui_macvim")
set guifont=JetBrains\ Mono\ Medium:h16
else
set guifont=JetBrains\ Mono\ Medium\ 13
endif
else
set nocursorline
"Fix 256 color scheme not coloring lines in terminal
set t_ut=
"neovim specifics
if has('nvim')
"Don't change cursor shape in neovim
set guicursor=
"Use 'correct' colors in term
set termguicolors
endif
endif
set expandtab
set shiftwidth=2
set tabstop=2
set list
set listchars=tab:→\ ,trail:·,nbsp:␣
set nowrap
set wildmode=longest,full
set foldmethod=syntax
set nofoldenable
set backupdir^=$VIMDIR/backup
set directory^=$VIMDIR/tmp
if version >= 703
set undodir^=$VIMDIR/undo
endif
"Persistent undo
set undofile
"Force diff to use vertical split
set diffopt+=vertical
"Spelling defaults
set spelllang=en_gb,da
augroup SpellFileTypes
autocmd!
autocmd FileType markdown,gitcommit setlocal spell
augroup END
"Complete
set complete=.,w,b,u,t,i,kspell
set completeopt=menuone
"Search for files recursively using :find
set path+=**
"Fat fingers
nnoremap <F1> <nop>
inoremap <F1> <nop>