-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinit.vim
375 lines (268 loc) · 9.91 KB
/
init.vim
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
" nvimrc
" Author: Theo Delrieu <[email protected]>
" Source: https://github.com/delrieutheo/dotnvim/blob/master/nvimrc
" Plugins ------------------------------------------------------------------ {{{
let g:polyglot_disabled = ['c', 'cpp']
filetype plugin indent on
syntax on
set nocompatible
set packpath^=~/.config/nvim/pack/minpac/start
packadd minpac
set runtimepath+=~/.fzf
call minpac#init()
call minpac#add('k-takata/minpac', {'type': 'opt'})
call minpac#add('sjl/gundo.vim')
call minpac#add('airblade/vim-gitgutter')
call minpac#add('tomtom/tcomment_vim')
call minpac#add('Konfekt/FastFold')
call minpac#add('derekwyatt/vim-fswitch')
call minpac#add('sheerun/vim-polyglot')
call minpac#add('danro/rename.vim')
call minpac#add('junegunn/fzf', {'dir': '~/.fzf', 'do': '!./install --all'})
call minpac#add('ctrlpvim/ctrlp.vim')
call minpac#add('ciaranm/securemodelines')
call minpac#add('rhysd/vim-clang-format')
" Go
call minpac#add('fatih/vim-go')
" Javascript
call minpac#add('pangloss/vim-javascript')
" Kotlin
call minpac#add('udalov/kotlin-vim')
" Swift
call minpac#add('bumaociyuan/vim-swift')
" Snippets
call minpac#add('SirVer/ultisnips')
" Markdown
call minpac#add('dhruvasagar/vim-table-mode')
" tpope
call minpac#add('tpope/vim-fugitive')
call minpac#add('tpope/vim-unimpaired')
call minpac#add('tpope/vim-surround')
" vim-scripts
call minpac#add('vim-scripts/vim-stay') " Open a previously closed file where you left it
" Colors
call minpac#add('nanotech/jellybeans.vim')
call minpac#add('w0ng/vim-hybrid')
call minpac#add('altercation/vim-colors-solarized')
" Syntax
call minpac#add('octol/vim-cpp-enhanced-highlight')
" Completion
call minpac#add('Valloric/YouCompleteMe', {'do': {-> system('./install.py --clang-completer')}})
call minpac#add('Valloric/ListToggle')
call minpac#add('ervandew/supertab')
" Cosmetics
call minpac#add('vim-airline/vim-airline')
call minpac#add('vim-airline/vim-airline-themes')
call minpac#add('ryanoasis/vim-devicons')
" }}}
packloadall
" Options ------------------------------------------------------------------ {{{
""" Basic ------------------------------------------------------------------ {{{
let mapleader = ","
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
set clipboard=unnamed
set completeopt-=preview " Hide scratch buffer on completion
set cursorline " Highlight current line
set foldmethod=syntax
set notimeout " No timeout on key codes
set number
set relativenumber
set scrolloff=999 " Keep the cursor centered
set showbreak=↪ " Show line wrapping character
set mouse=a
set background=dark
set mps+=<:>
colorscheme jellybeans
""" }}}
""" Search ----------------------------------------------------------------- {{{
set backup
set undofile
set noswapfile
set undodir=~/.nvim/tmp/undo/
set backupdir=~/.nvim/tmp/backup/
set directory=~/.nvim/tmp/swap/
" Create those directories if needed
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
""" Search ----------------------------------------------------------------- {{{
set ignorecase
set smartcase
""" }}}
""" Tabs ------------------------------------------------------------------- {{{
set shiftwidth=2 " Number of spaces for auto-indent
set smartindent
set tabstop=2
set expandtab " Insert spaces instead of tabs
""" }}}
" }}}
" Functions ---------------------------------------------------------------- {{{
let s:highlight_flag = 0
" Toggle the 80+ columns highlight with <leader>w
function! ToggleWidthHighlight()
if !s:highlight_flag
let &colorcolumn="80,".join(range(120,999),",") " Highlight 80th column and 120th+
let s:highlight_flag = 1
else
let &colorcolumn=""
let s:highlight_flag = 0
endif
endfunction
" Visual search. Stolen from @sjl.
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
" }}}
" Mappings ----------------------------------------------------------------- {{{
" Stop pressing that shift button (qwerty keyboards)
nnoremap ; :
vnoremap ; :
" Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
" ListToggle
nnoremap <silent> <leader>q :QToggle<CR>
nnoremap <silent> <leader>l :LToggle<CR>
" Buffer switching
nnoremap <leader>n :bnext<CR>
nnoremap <leader>p :bprevious<CR>
" Calls ToggleWidthHighlight
nnoremap <leader>w :call ToggleWidthHighlight()<CR>
" Remove search highlight with //
nnoremap <silent> // :nohlsearch<CR>
" Switch to alternate file.
nnoremap <Leader><Leader> <C-^>
" Splits
nnoremap <silent> ss :split<CR><C-W>j
nnoremap <silent> vv :vsplit<CR><C-W>l
" Search
nnoremap / /\v
vnoremap / /\v
nnoremap ? ?\v
vnoremap ? ?\v
" Tabs
nnoremap T :tabnew<cr>
nnoremap H :tabprev<cr>
nnoremap L :tabnext<cr>
" Convenience
command! W w
command! Q q
" Exit insert mode
inoremap jk <ESC>
" Folds
nnoremap <Space> za
" TComment
map <Leader>c <C-_><C-_>
" }}}
" Plugin configuration ----------------------------------------------------- {{{
""" Ctrl-P ----------------------------------------------------------------- {{{
let g:ctrlp_working_path_mode = 'ra'
" Ignore files in .gitignore
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_mruf_relative = 1
let g:ctrlp_clear_cache_on_exit = 0
""" }}}
""" FastFold --------------------------------------------------------------- {{{
let g:fastfold_savehook = 1
let g:fastfold_fold_command_suffixes = []
""" }}}
""" Gundo ------------------------------------------------------------------ {{{
nnoremap <F5> :GundoToggle<CR>
let g:gundo_prefer_python3 = 1
""" }}}
""" Hybrid ------------------------------------------------------------------ {{{
let g:hybrid_custom_term_colors = 1
""" }}}
""" SuperTab --------------------------------------------------------------- {{{
let g:SuperTabDefaultCompletionType = '<C-j>'
let g:SuperTabMappingForward = '<C-j>'
let g:SuperTabMappingBackward = '<C-k>'
let g:SuperTabClosePreviewOnPopupClose = 1
""" }}}
""" UltiSnips -------------------------------------------------------------- {{{
let g:UltiSnipsSnippetDirectories = [$HOME.'/.config/nvim/UltiSnips/']
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
""" }}}
""" vim-airline ------------------------------------------------------------ {{{
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#tab_nr_type = 1
let g:airline_powerline_fonts = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
""" }}}
""" vim-cpp-enhanced-highlight --------------------------------------------- {{{
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_concepts_highlight = 1
""" }}}
""" vim-go --------------------------------------------- {{{
let g:go_imports_mode='gopls'
let g:go_imports_autosave=1
let g:go_fmt_autosave = 1
let g:go_fmt_options = {
\ 'gofmt': '-s',
\ }
""" }}}
""" vim-fswitch --------------------------------------------- {{{
let g:fsnonewfiles = "on"
augroup my_fswitch_au_group
au!
au BufEnter *.h let b:fswitchlocs = 'reg:/include/src/,reg:|include/[^/]\+|src|,reg:|include\(/[^/]\+\)\{2\}|src|'
au BufEnter *.hh let b:fswitchlocs = 'reg:/include/src/,reg:|include/[^/]\+|src|,reg:|include\(/[^/]\+\)\{2\}|src|'
au BufEnter *.hpp let b:fswitchlocs = 'reg:/include/src/,reg:|include/[^/]\+|src|,reg:|include\(/[^/]\+\)\{2\}|src|'
au BufEnter *.hxx let b:fswitchlocs = 'reg:/include/src/,reg:|include/[^/]\+|src|,reg:|include\(/[^/]\+\)\{2\}|src|'
au BufEnter *.H let b:fswitchlocs = 'reg:/include/src/,reg:|include/[^/]\+|src|,reg:|include\(/[^/]\+\)\{2\}|src|'
au BufEnter *.c let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
au BufEnter *.cc let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
au BufEnter *.cpp let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
au BufEnter *.cxx let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
au BufEnter *.C let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
au BufEnter *.m let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
au BufEnter *.mm let b:fswitchlocs = 'reg:/src/include/,reg:|src|include/*|,reg:|src|include/*/*|'
augroup END
command A FSHere
""" }}}
""" vim-javascript --------------------------------------------- {{{
let g:javascript_plugin_flow = 1
""" }}}
""" vim-clang-format --------------------------------------------- {{{
let g:clang_format#detect_style_file = 1
let g:clang_format#auto_format = 1
""" }}}
""" YouCompleteMe ---------------------------------------------------------- {{{
nnoremap <leader>d :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>f :YcmCompleter GoToDefinition<CR>
nnoremap <leader>e :YcmCompleter GoToInclude<CR>
nnoremap <leader>t :YcmCompleter GetType<CR>
nnoremap <leader>i :YcmCompleter FixIt<CR>
let g:ycm_key_list_select_completion = ['<C-j>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<Up>']
let g:ycm_always_populate_location_list = 1
let g:ycm_extra_conf_globlist = ['~/*']
let g:ycm_filetype_blacklist = { 'go': 1 }
" basic config
let g:ycm_global_ycm_extra_conf = '${HOME}/.config/nvim/.ycm_extra_conf.py'
""" }}}
" }}}