This repository was archived by the owner on Mar 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.vim
More file actions
365 lines (292 loc) · 12 KB
/
init.vim
File metadata and controls
365 lines (292 loc) · 12 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
set directory=~/.vim/backup
set backupdir=~/.vim/backup " keep swap files here
filetype off " required
call plug#begin('~/.local/share/nvim/plugged')
Plug 'tpope/vim-fugitive' " git plugin
Plug 'vim-airline/vim-airline' " bottom status bar
Plug 'vim-airline/vim-airline-themes'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " fuzzy finder conf
Plug 'junegunn/fzf.vim' " fuzzy finder
Plug 'scrooloose/nerdtree' " folders tree
Plug 'scrooloose/nerdcommenter' " code commenter
Plug 'jacoborus/tender.vim' " my favorite theme so far :)
Plug 'kien/rainbow_parentheses.vim' " for nested parentheses
Plug 'tpope/vim-surround' " quickly edit surroundings (brackets, html tags, etc)
Plug 'junegunn/vim-easy-align' " alignment plugin
Plug 'neomake/neomake' " run programs asynchronously and highlight errors
Plug 'Valloric/MatchTagAlways' " highlights html enclosing tags
Plug 'Twinside/vim-hoogle' " Hoogle search (Haskell) in Vim
Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' } " ghcid for Haskell
Plug 'Shougo/unite.vim' " Required by some haskell plugins
Plug 'ujihisa/unite-haskellimport' " Suggestions on imports
Plug 'vmchale/dhall-vim' " Syntax highlighting for Dhall lang
Plug 'terryma/vim-multiple-cursors' " Multiple cursors selection, etc
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} " LSP client + autocompletion plugin
Plug 'itchyny/lightline.vim' " configurable status line (can be used by coc)
Plug 'derekwyatt/vim-scala' " scala plugin
Plug 'jremmen/vim-ripgrep' " blazing fast search using ripgrep
Plug 'stefandtw/quickfix-reflector.vim' " make modifications right in the quickfix window
Plug 'Xuyuanp/nerdtree-git-plugin' " shows files git status on the NerdTree
Plug 'LnL7/vim-nix' " nix support (highlighting, etc)
" Plug 'easymotion/vim-easymotion'
" Plug 'tpope/vim-repeat'
call plug#end()
" End of plugins here
" ===================
" save when leaving insert mode
autocmd InsertLeave * write
" ripgrep smartcase (search with case insensitive)
let g:rg_command = 'rg --vimgrep -S'
" airline: status bar at the bottom
let g:airline_powerline_fonts=1
" if you want to disable auto detect, comment out those two lines (COC)
"let g:airline#extensions#disable_rtp_load = 1
"let g:airline_extensions = ['branch', 'hunks', 'coc']
let g:airline_section_error = '%{airline#util#wrap(airline#extensions#coc#get_error(),0)}'
let g:airline_section_warning = '%{airline#util#wrap(airline#extensions#coc#get_warning(),0)}'
" Highlighting for jsonc filetype
autocmd FileType json syntax match Comment +\/\/.\+$+
" Nerd commenter
filetype plugin on
" Better Unix support
set viewoptions=folds,options,cursor,unix,slash
set encoding=utf-8
" Handle window actions with Meta instead of <C-w>
" Switching
nnoremap <M-h> <C-w>h
nnoremap <M-j> <C-w>j
nnoremap <M-k> <C-w>k
nnoremap <M-l> <C-w>l
" Moving
nnoremap <M-H> <C-w>H
nnoremap <M-J> <C-w>J
nnoremap <M-K> <C-w>K
nnoremap <M-L> <C-w>L
nnoremap <M-x> <C-w>x
" Resizing
nnoremap <M-=> <C-w>=
nnoremap <M-+> <C-w>+
nnoremap <M--> <C-w>-
nnoremap <M-<> <C-w><
nnoremap <M->> <C-w>>
" Clear search highlighting
nnoremap <C-z> :nohlsearch<CR>
" Terminal mode exit shortcut
:tnoremap <Esc> <C-\><C-n>
" Nerdtree git plugin symbols
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "ᵐ",
\ "Staged" : "ˢ",
\ "Untracked" : "ᵘ",
\ "Renamed" : "ʳ",
\ "Unmerged" : "ᶴ",
\ "Deleted" : "ˣ",
\ "Dirty" : "˜",
\ "Clean" : "ᵅ",
\ "Unknown" : "?"
\ }
function! TrimWhitespace()
let l:save_cursor = getpos('.')
%s/\s\+$//e
call setpos('.', l:save_cursor)
endfun
command! TrimWhitespace call TrimWhitespace() " Trim whitespace with command
autocmd BufWritePre * :call TrimWhitespace() " Trim whitespace on every save
" Non-mapped function for tab toggles
function! TabToggle()
if &expandtab
set noexpandtab
else
set expandtab
endif
endfunc
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" Nerdtree
map <C-F> :NERDTreeToggle<CR>
map <C-S> :NERDTreeFind<CR>
" Other options
let mapleader=','
set backspace=2
colorscheme tender
syntax on
set shell=/bin/bash
set laststatus=2
set noshowmode
" Draw a line at 120 columns
" set colorcolumn=120
" highlight ColorColumn ctermbg=235 guibg=#2c2d27
" Fixes broken cursor on Linux
set guicursor=
" NerdTree config
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let g:NERDTreeMinimalUI = 1
let g:NERDTreeDirArrows = 1
" General editor options
set hidden " Hide files when leaving them.
set number " Show line numbers.
set numberwidth=1 " Minimum line number column width.
set cmdheight=2 " Number of screen lines to use for the commandline.
set textwidth=120 " Lines length limit (0 if no limit).
set formatoptions=jtcrq " Sensible default line auto cutting and formatting.
set linebreak " Don't cut lines in the middle of a word .
set showmatch " Shows matching parenthesis.
set matchtime=2 " Time during which the matching parenthesis is shown.
set background=dark " Color adapted to dark background.
set listchars=tab:▸\ ,eol:¬ " Invisible characters representation when :set list.
set clipboard=unnamedplus " Copy/Paste to/from clipboard
set cursorline " Highlight line cursor is currently on
set completeopt+=noinsert " Select the first item of popup menu automatically without inserting it
" Search
set incsearch " Incremental search.
set ignorecase " Case insensitive.
set smartcase " Case insensitive if no uppercase letter in pattern, case sensitive otherwise.
set nowrapscan " Don't go back to first match after the last match is found.
" Fold
" set foldmethod=indent
" set foldlevelstart=1
" Tabs
set expandtab " Tab transformed in spaces
set tabstop=2 " Sets tab character to correspond to x columns.
" x spaces are automatically converted to <tab>.
" If expandtab option is on each <tab> character is converted to x spaces.
set softtabstop=2 " column offset when PRESSING the tab key or the backspace key.
set shiftwidth=2 " column offset when using keys '>' and '<' in normal mode.
" Toggle display of tabs and EOF
nnoremap <leader>l :set list!<CR>
" Auto-commands
" Vimscript
augroup vimscript_augroup
autocmd!
autocmd FileType vim nnoremap <buffer> <M-z> :execute "help" expand("<cword>")<CR>
augroup END
" Spell check
au BufNewFile,BufRead *.md set spell
" Fuzzy finder shortcut
nnoremap <C-p> :FZF<CR>
" Disable touchpad on startup / Enable it back on exit (at the OS level)
"autocmd VimEnter * !~/development/touchpad-off.sh
"autocmd VimLeave * !~/development/touchpad-on.sh
nnoremap <silent> <F3> :!~/development/touchpad-toggle.sh <enter><CR>
" Disable arrow keys and page up / down
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
inoremap <Up> <nop>
inoremap <Down> <nop>
inoremap <Left> <nop>
inoremap <Right> <nop>
vnoremap <Up> <nop>
vnoremap <Down> <nop>
vnoremap <Left> <nop>
vnoremap <Right> <nop>
noremap <PageUp> <nop>
inoremap <PageUp> <nop>
vnoremap <PageUp> <nop>
noremap <PageDown> <nop>
inoremap <PageDown> <nop>
vnoremap <PageDown> <nop>
" Disable mouse / touchpad (only in vim)
set mouse=nicr
inoremap <ScrollWheelUp> <nop>
inoremap <S-ScrollWheelUp> <nop>
inoremap <C-ScrollWheelUp> <nop>
inoremap <ScrollWheelDown> <nop>
inoremap <S-ScrollWheelDown> <nop>
inoremap <C-ScrollWheelDown> <nop>
inoremap <ScrollWheelLeft> <nop>
inoremap <S-ScrollWheelLeft> <nop>
inoremap <C-ScrollWheelLeft> <nop>
inoremap <ScrollWheelRight> <nop>
inoremap <S-ScrollWheelRight> <nop>
inoremap <C-ScrollWheelRight> <nop>
" vim-scala
au BufRead,BufNewFile *.sbt set filetype=scala
" ------------------- COC config -----------------------
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Some server have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" Use <c-space> for trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> for confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` for navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Remap for do action format
"nmap <silent> F <Plug>(coc-action-format) "does not work
nnoremap <silent> F :call CocAction('format')<CR>
" Show signature help
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
" Use K for show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" close preview (shown for hover / signature help)
nnoremap <leader> <Esc> :pclose<CR>
nnoremap <silent> <M-B> :call CocRequest('metals', 'workspace/executeCommand', { 'command': 'build-import' })<CR>
"nnoremap <silent> <M-Z> :ccl<CR>
" COC Snippets
" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)
" No preview window on autocompletion (vim-lsc)
"set completeopt-=preview
" Close preview window on autocompletion (metals / vim-lsc)
"autocmd CompleteDone * silent! pclose
" Haskell plugins
nnoremap <silent> ;h :execute "Unite -start-insert haskellimport"<CR>
"nnoremap <silent> <C-h> :execute "Unite hoogle"<CR> " too slow
" Diagnostics highlighting
"hi link ALEError Error
"hi Warning term=underline cterm=underline ctermfg=Yellow gui=undercurl guisp=Gold
"hi link ALEWarning Warning
"hi link ALEInfo SpellCap