-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
406 lines (324 loc) · 11.3 KB
/
vimrc
File metadata and controls
406 lines (324 loc) · 11.3 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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
" --- Basic options --- {{{
if has('vim_starting')
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set encoding=utf-8
set langmenu=en_GB.UTF-8
let $LANG = 'en_GB.UTF-8'
set fileformats=unix,dos
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
set nobackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set ignorecase " ignore case while searching
set smartcase " unless one uses upper case letter
set tabstop=8
set softtabstop=2
set shiftwidth=2
set expandtab
set autowrite
set autoread
set smarttab
set cino+=(0,u0,W2s,C1,l1
set textwidth=80
set foldmethod=marker
set foldminlines=10
" set foldcolumn=2
set listchars=tab:\|\ ,trail:·,precedes:<,extends:>,nbsp:¤
set list
set grepprg=grep\ -niH
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
set runtimepath+=~/.vim/bundles/repos/github.com/Shougo/dein.vim
" Used by a number of completion plugins
set hidden
set laststatus=2
let mapleader="\<Space>"
let maplocalleader="\\"
endif
" Finds an executable. Tries to use PATH first, then some builtin
" absolute paths, and then tries the remaining supplied paths.
function! s:PickExecutable(prog, ...)
let l:candidates = [a:prog, '/usr/local/bin' . a:prog, '/usr/bin' . a:prog]
for e in l:candidates + a:000
if executable(e)
return e
endif
endfor
echomsg "No suitable executable found for " . a:0
return ""
endfunction
if has('win32')
let g:python3_host_prog = 'python.exe'
else
let g:python_host_prog = s:PickExecutable('python')
let g:python3_host_prog = s:PickExecutable('python3')
if !has("nvim")
if len(g:python3_host_prog)
set pyxversion=3
else
set pyxversion=2
endif
endif
endif
" --- dein --- {{{1
if dein#load_state('~/.vim/bundles')
call dein#begin('~/.vim/bundles')
call dein#add('~/.vim/bundles/repos/github.com/Shougo/dein.vim')
call dein#add('Shougo/deoplete.nvim')
if has('nvim')
else
call dein#add('roxma/nvim-yarp')
call dein#add('roxma/vim-hug-neovim-rpc')
endif
call dein#add('Shougo/neco-vim')
call dein#add('Shougo/neoinclude.vim')
call dein#add('copy/deoplete-ocaml')
call dein#add('deoplete-plugins/deoplete-jedi')
call dein#add('deoplete-plugins/deoplete-zsh')
call dein#add('autozimu/LanguageClient-neovim', {
\ 'rev' : 'next', 'build' : 'bash install.sh'})
call dein#add('Shougo/vimproc.vim', {'build' : 'make'})
call dein#add('Shougo/vimfiler.vim')
call dein#add('altercation/vim-colors-solarized')
call dein#add('chrisbra/NrrwRgn')
call dein#add('ciaranm/securemodelines')
call dein#add('ekalinin/Dockerfile.vim')
call dein#add('elixir-lang/vim-elixir')
call dein#add('eugen0329/vim-esearch')
call dein#add('fatih/vim-go', {'build' : ':GoUpdateBinaries'})
call dein#add('guns/vim-sexp')
call dein#add('inkarkat/vim-ingo-library')
call dein#add('inkarkat/vim-visualrepeat')
call dein#add('inkarkat/vim-SyntaxRange')
call dein#add('jceb/vim-orgmode')
call dein#add('jnurmine/Zenburn')
call dein#add('juanchanco/vim-jbuilder')
call dein#add('junegunn/fzf', {'path' : '~/.fzf', 'build' : './install --all'})
call dein#add('junegunn/fzf.vim')
call dein#add('junegunn/goyo.vim')
call dein#add('junegunn/vim-easy-align')
call dein#add('kana/vim-textobj-user')
call dein#add('lukerandall/haskellmode-vim')
call dein#add('majutsushi/tagbar')
call dein#add('mattn/calendar-vim')
call dein#add('nelstrom/vim-textobj-rubyblock')
call dein#add('plasticboy/vim-markdown')
call dein#add('PProvost/vim-ps1')
call dein#add('rking/ag.vim')
call dein#add('ocaml/vim-ocaml')
call dein#add('osyo-manga/vim-monster')
call dein#add('scrooloose/nerdcommenter')
call dein#add('scrooloose/vim-space')
call dein#add('tpope/vim-endwise')
call dein#add('tpope/vim-fugitive')
call dein#add('tpope/vim-repeat')
call dein#add('tpope/vim-speeddating')
call dein#add('tpope/vim-surround')
call dein#add('tpope/vim-sexp-mappings-for-regular-people')
call dein#add('vim-airline/vim-airline')
call dein#add('vim-airline/vim-airline-themes')
call dein#add('vim-scripts/blockle.vim')
call dein#add('vim-scripts/CountJump')
call dein#add('vim-scripts/ConflictMotions')
call dein#add('vim-scripts/utl.vim')
call dein#add('wlangstroth/vim-racket')
call dein#add('regedarek/ZoomWin')
call dein#add('vim-syntastic/syntastic')
call dein#add('rust-lang/rust.vim')
call dein#add('fsharp/vim-fsharp', {
\ 'build' : 'make fsautocomplete',
\ 'lazy' : 1,
\ 'on_ft' : 'fsharp',
\ })
call dein#end()
call dein#save_state()
endif
set completeopt=menuone,menu,longest,preview
" --- Plugin options --- {{{1
let g:esearch = { 'adapter': 'rg' }
let g:tagbar_autofocus = 1
let g:tagbar_autoclose = 1
" --- deoplete --- {{{2
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option({
\ 'camel_case': v:true,
\ 'auto_complete': v:false,
\ })
" Plugin key-mappings.
inoremap <expr><C-@> deoplete#manual_complete()
inoremap <expr><C-Space> deoplete#manual_complete()
inoremap <expr><C-g> deoplete#undo_completion()
inoremap <expr><C-l> deoplete#complete_common_string()
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> deoplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> deoplete#smart_close_popup()."\<C-h>"
" --- Language servers --- {{{2
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> gr :call LanguageClient#textDocument_references({
\ 'includeDeclaration': v:false})<cr>
let g:LanguageClient_serverCommands = {
\ 'c': ['ccls', '--log-file=/tmp/cc.log'],
\ 'cpp': ['ccls', '--log-file=/tmp/cc.log'],
\ 'cuda': ['ccls', '--log-file=/tmp/cc.log'],
\ 'objc': ['ccls', '--log-file=/tmp/cc.log'],
\ 'ocaml': ['ocamllsp'],
\ }
" --- Airline configuration {{{2
" air-line
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" }}}
let python_highlight_all = 1
" Configure browser for haskell_doc.vim
let g:haddock_browser = "open"
let g:haddock_browser_callformat = "%s %s"
" Enable sexp editing in dune files
let g:sexp_filetypes = 'scheme,lisp,clojure,jbuilder'
" --- Helper functions --- {{{1
" Toggles various listchars options between v1 and v2
function! ToggleLC(v1, v2)
if &listchars =~ a:v1
let &listchars = substitute(&listchars, a:v1, a:v2, "")
elseif &listchars =~ a:v2
let &listchars = substitute(&listchars, a:v2, a:v1, "")
endif
endfunction
function! ToggleZenburnContrast()
let g:zenburn_high_Contrast = g:zenburn_high_Contrast ? 0 : 1
:colorscheme zenburn
endfunction
command! ZT call ToggleZenburnContrast()
" --- Key bindings --- {{{1
" Toggle display of trailing spaces
noremap <silent> <Leader>ds :call ToggleLC("trail:·", "trail: ")<CR>
" Toggle display of tabs (all modes)
noremap <silent> <Leader>dt :call ToggleLC("tab:\| ", "tab: ")<CR>
" Quickly clear highlighted searches
noremap <Leader>c :nohlsearch<CR>
" Reload file from disk
noremap <Leader>r :e %<CR>
" Toggle line wrap faster
noremap <Leader>dq :set wrap!<CR>
" Zenburn contrast toggle, as I can't ever decide on one.
noremap <Leader>dz :ZT<CR>
" I'm so used to this after using it with VSCode.
noremap <Leader>w :w<CR>
imap <C-a> <C-o>^
imap <C-e> <C-o>$
" Buffer explorer
noremap <silent> <F2> :Buffers<CR>
inoremap <silent> <F2> <C-o><F2>
" Tag list
noremap <silent> <F3> :TagbarToggle<CR>
imap <silent> <F3> <C-o><F3>
" File explorer
noremap <silent> <F4> :VimFilerExplorer<CR>
imap <silent> <F4> <C-o><F4>
" Fuzzy finding
noremap <silent> <Leader>e :Files<CR>
noremap <silent> <C-p> :History<CR>
" Preview tag under cursor
noremap <Leader>k :pclose<CR>
" Toggle input mode with M-Space
inoremap <M-Space> <Esc>
nnoremap <M-Space> i
" Easy file saving with C-s
inoremap <C-s> <C-o>:w<CR>
noremap <C-s> :w<CR>
" Don't use Ex mode, use Q for formatting
map Q gqap
" }}}
" In many terminal emulators the mouse works just fine, thus enable it.
set mouse=a
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
let g:load_doxygen_syntax = 1
syntax on
set hlsearch
endif
" --- Auto Command settings --- {{{1
" Fix detection of Objective-C++
function! s:FTmm()
if match(getline(1, min([line("$"), 200])), '^\s*\(#\s*\(include\|import\)\>\|/\*\)') > -1
set filetype=objcpp
else
set filetype=nroff
endif
endfunction
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78 | set autoindent
" Use 4 space indendation for python (inspired by PEP).
autocmd FileType python setlocal softtabstop=4 shiftwidth=4
" Recognise .mm files as Objective-C
autocmd BufRead,BufNewFile *.mm call s:FTmm()
au FileType c,cpp,cuda,objc setl formatexpr=LanguageClient#textDocument_rangeFormatting()
" Use ghc functionality for haskell files
au BufEnter *.hs compiler ghc
if executable('opam')
let s:opam = substitute(system('opam config var share'), '\n$', '', '''')
if executable('ocamlmerlin') && has('python')
let s:ocamlmerlin = s:opam . "/merlin"
execute "set rtp+=".s:ocamlmerlin."/vim"
execute "set rtp+=".s:ocamlmerlin."/vimbufsync"
endif
autocmd FileType ocaml execute "set rtp+=" . s:opam . "/ocp-indent/vim/indent/ocaml.vim"
endif
autocmd! GUIEnter * set vb t_vb=
" 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
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd") }}}
if has("gui_running")
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
let &guioptions = substitute(&guioptions, "t", "", "g")
set guioptions-=T
if &diff
let &columns = 240
let &lines = 60
else
let &columns = 100
let &lines = 50
endif
endif
if has("win32")
set guifont=Fira\ Code:h11
elseif has("unix")
set guifont=Fira\ Code\ weight=450\ 11
elseif has("macunix")
set guifont=FiraCode-Retina:h14
endif
set background=dark
let g:zenburn_high_Contrast=1
:colorscheme zenburn
" Additional local configuration
let s:localvimrc = expand("~/.vim/localrc")
if filereadable(s:localvimrc)
silent! execute 'source' s:localvimrc
endif