-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
365 lines (268 loc) · 8.25 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
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
"""""""""""""""""""""""""""""""""""""
" "
" VIMRC "
" author: eliott.beguet "
" "
" Thx Chewie for your vimrc :D "
" And random SO post. "
" "
"""""""""""""""""""""""""""""""""""""
"""""""""""""""""
" PLUGINS "
"""""""""""""""""
" Install vim plug if not already installed"
if empty(glob("~/.vim/autoload/plug.vim"))
execute '!mkdir -p ~/.vim/plugged'
execute '!mkdir -p ~/.vim/autoload'
execute '!curl -fLo ~/.vim/autoload/plug.vim https://raw.github.com/junegunn/vim-plug/master/plug.vim'
endif
call plug#begin('~/.vim/plugged')
" auto comments
Plug 'preservim/nerdcommenter'
" quickfix buffer
Plug 'romainl/vim-qf'
" Haskell specific plugins
Plug 'neovimhaskell/haskell-vim'
Plug 'alx741/vim-hindent'
" Tab number and only shows basename
Plug 'mkitt/tabline.vim'
" tree on current buffer
Plug 'tpope/vim-vinegar'
" Them
Plug 'nanotech/jellybeans.vim'
Plug 'wadackel/vim-dogrun'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" 'IDE' features
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-dispatch'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'iRyukizo/tiger-syntax'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
call plug#end()
"""""""""""""
" CMD stuff "
"""""""""""""
" Silently execute any command and redraw buffers
command! -nargs=1 Silent execute ':silent !'.<q-args> | execute ':redraw!'
" Reload a file when it is changed from the outside
set autoread
" Write the file when we leave the buffer
set autowrite
" Disable backups, hello git
set nobackup
" Force to utf-8 encoding (Windows)
set encoding=utf-8
" Disable swapfiles
set noswapfile
" Hide buffers instead of closing them
set hidden
" default is too slow (4000ms)
set updatetime=300
" For some stupid reason, vim requires the term to begin with "xterm", so the
" automatically detected "rxvt-unicode-256color" doesn't work.
set term=xterm-256color
" zsh term
autocmd vimenter * let &shell='/bin/zsh -i'
""""""""""""
" UI Stuff "
""""""""""""
" Set the minimal amount of lignes under and above the cursor
set scrolloff=6
" Show current mode
set showmode
" Show command being executed
set showcmd
" Show line number (relative)
set number
set relativenumber
" Always show status line
set laststatus=2
" Enhance command line completion
set wildmenu
" Set completion behavior, see :help wildmode for details
set wildmode=longest:full,list:full
" Color the column after textwidth (80th here)
if version >= 703
set colorcolumn=+1
endif
" Display whitespace characters
set list
set listchars=tab:>─,eol:¬,trail:\ ,nbsp:¤
set fillchars=vert:│
" Basic syntax highlighting
syntax on
" Enable Doxygen highlighting
let g:load_doxygen_syntax=1
" Allow mouse use in vim
set mouse=a
" Show matching parenthesis etc
set showmatch
" Enable line wrapping
set wrap
" Wrap on column 80
set textwidth=79
" Disable preview window on completion
set completeopt=longest,menuone
" Highlight current line
set cursorline
""""""""""""""""
" Search Stuff "
""""""""""""""""
" Ignore case on search
set ignorecase
" Ignore case unless there is an uppercase letter in the pattern
set smartcase
" Move cursor to the matched string
set incsearch
" Don't highlight matched strings
set nohlsearch
"""""""""""""""""""""
" Indentation Stuff "
"""""""""""""""""""""
" The length of a tab (don't change it)
set tabstop=8
" Number of spaces inserted/removed when using < or >
set shiftwidth=4
" Number umber of spaces inserted when tabbing
" -1 means same value as shiftwidth
set softtabstop=-1
" Insert spaces instead of tabs
set expandtab
" When tabbing manually, use shiftwidth instead of tabstop and softtabstop
set smarttab
" Basic indenting (ie indent from previous line)
set autoindent
" :help cinoptions-values for details
set cinoptions=(0,u0,U0,t0,g0,N-s
"""""""""""""""""
" Mapping stuff "
"""""""""""""""""
" Set ù as map leader with an azerty keyboard
" Change it to , on qwerty
let mapleader = 'ù'
" Move between rows in wrapped lines
noremap j gj
noremap k gk
" Remap Q to A (I often missclick and don't really use Q anyway)
nmap Q A
" Remap space to enter in normal (usefull for tree)
noremap <space> <CR>
" Remove all trailing whitespace by pressing F5
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" Map F1 to source current buffer
map <F1> :w<CR>:so %<CR>
" From https://github.com/neoclide/coc.nvim
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
" let g:asyncomplete_auto_popup = 0
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ asyncomplete#force_refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
set completeopt=menuone,noinsert,noselect,preview
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
:set guitablabel=%N\ %f
" Mapping tabs and listing
" t[h/g] moveto[next/previous] tabs
" ty show all tabs
" tt close current tab
" Ctrl t to create a new tab
nnoremap ty :tabs<CR>
nnoremap th :tabnext<CR>
nnoremap tg :tabprev<CR>
nnoremap tt :tabclose<CR>
nnoremap <C-t> :tabnew<CR>
inoremap <C-t> <Esc>:tabnew<CR>
" Ctrl S to save all tabs and go back to the first one
" TODO: fix it
let curr_tab=tabpagenr()
nnoremap <C-S> :tabdo w <bar><Esc> :execute curr_tab .. "gt"<CR>
" <space>cl to apply .clang-format
nnoremap <space>cl :Silent clfe<CR>
" Map easy move to new tab on azerty
" Change t<symbol> to t<number> on qwerty
nnoremap t& 1gt
nnoremap té 2gt
nnoremap t" 3gt
nnoremap t' 4gt
nnoremap t( 5gt
nnoremap t- 6gt
" Yank from cursor to end of line, to be consistent with C and D
nnoremap Y y$
" Write as root, when you forgot to sudoedit
cnoreabbrev w!! w !sudo tee % >/dev/null
" Open the quickfix window if there are errors, or close it if there are no
" errors left
noremap <leader>cw :botright :cw<cr>
" Run make silently, then skip the 'Press ENTER to continue'
noremap <leader>m :silent! :make! \| :redraw!<cr>
" Run clanf-format-epita silently
noremap <space>c :Silent !clfe<cr>
" Map auto closing char (comas, braces, etc)
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
""""""""""""""""""""""""
" plugins etc options "
""""""""""""""""""""""""
" Launch fugitive's gstatus
noremap <space>gs :Git<CR>
" Add curent buffer to repo
noremap <space>ga :w<CR>:Git add %<bar>echom "Added" expand("%")<CR>
" Commit with buffer prompt for msg
noremap <space>gc :Git commit -v<CR>
" Remap space gp to basic push
noremap <space>gp :Git push<CR>
" Simple Git log
noremap <space>gl :Git log --pretty=format:'%h %ad %s (%an)' --date=short<CR>
" Mappings for vim-test
" Uncomment if using vim test
" nmap <silent> <space>ts :TestSuite<CR>
" Display a short path
let g:airline_stl_path_style = 'short'
" Create the vim airline symbols directory (if it doesn't exist yet)
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
"
" use ascii symnols for status bar
let g:airline_symbols_ascii = 1
" airline theme
let g:airline_theme = 'jellybeans'
" tabline.vim plugin add close button on tab
" it's ugly af nvm
"let g:tablineclosebutton=1
let g:jellybeans_background_color_256='232'
colorscheme dogrun
" map vimairline symbols
" unicode symbols
let g:airline_left_sep = ''
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_right_sep = ''
let g:airline_symbols.colnr = ' | c'
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '☰'
let g:airline_symbols.linenr = ' | '
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.maxlinenr = '㏑'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.spell = 'Ꞩ'
let g:airline_symbols.notexists = 'Ɇ'
let g:airline_symbols.whitespace = 'Ξ'