-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc-conf
232 lines (197 loc) · 7.38 KB
/
vimrc-conf
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
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"Plugins installés depuis Vim Awesome avec le gestionnaire Vundle
Plugin 'preservim/nerdtree'
Plugin 'mbbill/undotree'
Plugin 'jeffkreeftmeijer/vim-numbertoggle'
Plugin 'jodosha/vim-devnotes'
Plugin 'joshdick/onedark.vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'ervandew/supertab'
Plugin 'tpope/vim-fugitive'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tpope/vim-commentary'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'liuchengxu/vim-which-key'
Plugin 'mhinz/vim-startify'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
call vundle#end() " required
filetype plugin indent on " required
" Active les raccourcis clavier pour fzf
nnoremap <C-p> :FZF<CR>
nnoremap <S-f> :Rg<CR>
nnoremap <S-b> :Buffers<CR>
nnoremap <S-m> :Marks<CR>
nnoremap <S-t> :Tags<CR>
"Parametre de vim
syntax on
set smartindent
set shiftwidth=2
set wildmenu
set cursorline
set ignorecase
set hlsearch
set mouse=a
set expandtab
set tabstop=2
" Configurer Airline
set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline_theme='onedark'
" Stocker le nom d'utilisateur dans une variable
let g:username = substitute(system('whoami'), '\n', '', '')
" Fonction pour mapper les modes
function! Mode()
let mode = mode()
if mode ==# 'n'
return 'NORMAL'
elseif mode ==# 'i'
return 'INSERT'
elseif mode ==# 'v'
return 'VISUAL'
elseif mode ==# "\<C-V>"
return 'VISUAL BLOCK'
elseif mode ==# 'V'
return 'VISUAL LINE'
elseif mode ==# 'R'
return 'REPLACE'
else
return mode()
endif
endfunction
" Configurer les sections personnalisées dans la barre d'état
let g:airline_section_a = '%<%{Mode()}'
let g:airline_section_b = '%#StatusLine#' . g:username . ' | %f'
let g:airline_section_c = '%#StatusLineNC#%{strftime("%H:%M")}'
" Configurer les symboles de séparation
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_alt_sep = ''
" Configurer les couleurs
hi StatusLine guifg=#ebdbb2 guibg=#3c3836 gui=NONE ctermfg=180 ctermbg=237 cterm=NONE
hi StatusLineNC guifg=#928374 guibg=#3c3836 gui=NONE ctermfg=146 ctermbg=237 cterm=NONE
hi User1 guifg=#282828 guibg=#98971a gui=NONE ctermfg=234 ctermbg=142 cterm=NONE
hi User2 guifg=#928374 guibg=NONE gui=NONE ctermfg=146 ctermbg=NONE cterm=NONE
hi User3 guifg=#d5c4a1 guibg=#3c3836 gui=NONE ctermfg=223 ctermbg=237 cterm=NONE
hi User4 guifg=#1d2021 guibg=NONE gui=NONE ctermfg=234 ctermbg=NONE cterm=NONE
hi User5 guifg=#689d6a guibg=NONE gui=NONE ctermfg=108 ctermbg=NONE cterm=NONE
hi User6 guifg=#fabd2f guibg=NONE gui=NONE ctermfg=214 ctermbg=NONE cterm=NONE
" Activer auto-pairs
let g:AutoPairsFlyMode = 1
let g:AutoPairsShortcutBackInsert = '<M-b>'
au FileType * let b:AutoPairs = AutoPairsDefine({'(':')', '[':']', '{':'}', '"':'"', "'":"'", '`':'`'})
"Numérotation avec numbertoggle
set number relativenumber
"Theme vim
colorscheme space-vim-dark
"Permet la sauvegarde automatique de l'historique...
set undofile
set undodir=~/.vim/
"Raccourci vertical split
nnoremap <c-a> :vsp<CR>
"Raccourci Note
nmap <F2> :call DevNotes()<CR>
"Raccourci NerdTree
nnoremap <F3> :NERDTreeToggle<CR>
"Raccourci historique
nnoremap <F4> :UndotreeToggle<CR>:wincmd p<CR>
"Raccourci terminal
nnoremap <F5> :call OpenResizableTerminals(input('Size of terminal : ', '10'))<CR>
tnoremap <F6> <c-w>N
"Raccourci vers une recherche duckduckgo
vmap g :<C-U> !firefox "https://duckduckgo.com/?q=<cword>&t=newext&atb=v372-6&ia=web" >& /dev/null <CR><CR>
"Raccourci vers aide vim
nmap <F7> :!elinks https://agreugr.eu<CR>
"Raccourci onglet
nnoremap <F8> :call OpenFileInNewTab()<CR>
nmap <F9> :tabnext<CR>
nnoremap <F10> :call SaveAndQuit()<CR>
"Raccourci plugin installer
nnoremap ² :call ClosePluginList()<CR>
"Raccourci au lancement de vim
au VimEnter *.cpp :NERDTreeToggle
au VimEnter *.cpp :call OpenResizableTerminals(input('Size of terminal : ', '10'))
au VimEnter *.ino :NERDTreeToggle
au VimEnter *.ino :call OpenResizableTerminals(input('Size of terminal : ', '10'))
" Exécuter la commande :PluginUpdate en arrière-plan chaque fois que Vim est ouvert
au VimEnter * silent! execute ':PluginUpdate | redraw!'
" Sauvegarde et Fermeture de vimscode
function! SaveAndQuit()
wa
qall!
endfunction
" Fermeture ou ouverture du pluginlisst
function! ClosePluginList()
if &buftype == 'help' && expand('%:t') == 'PluginList'
quit
else
:PluginList
endif
endfunction
" Configuration du terminal extensible
function! OpenResizableTerminals(size)
let size_arg = a:size != '' ? '++rows=' . a:size : ''
execute 'bot term ' . size_arg
endfunction
" Fonction pour la création d'un nouvel onglet
function! OpenFileInNewTab()
let user_choice = input("Do you want to open exist file ? (o/n): ")
if user_choice == 'o'
let file_name = input("Choose file to open : ", '', 'file')
if filereadable(file_name)
execute "tabnew " . fnameescape(file_name)
else
echo "File doesnt exist : " . file_name
endif
elseif user_choice == 'n'
let new_file = input("New name for file : ")
execute "tabnew " . new_file
else
echo "\nInvalid choice. Please enter 'o' to open an existing file, or 'n' to create a new file.."
endif
endfunction
" Configuration de la page d'accueil vim
let g:startify_lists = [
\ {'type': 'files', 'header': ['Recent files']},
\ ]
let g:startify_custom_header =
\ startify#center(split(system('figlet -w 100 VIMSCODE'), '\n'))
" Configuration WhichKey
call which_key#register('<Space>', "g:which_key_map")
nnoremap <c-l> :WhichKey '<Space>'<CR>
set timeoutlen=20
let g:which_key_map = {
\ 'name' : 'Raccourcis VimsCode' ,
\ '<F2>' : ['<F2>' , 'displays a note'] ,
\ '<F3>' : ['<F3>' , ' brings up the tree structure'] ,
\ '<F4>' : ['<F4>' , ' edit history'] ,
\ '<F5>' : ['<F5>' , ' brings up a terminal'] ,
\ '<F5> souris' : ['' , 'resizable with mouse'] ,
\ '<F6>' : ['' , 'scroll in terminal'] ,
\ '<F7>' : ['<F7>' , 'brings up a french help site'] ,
\ '<F8>' : ['<F8>' , 'create/open a new window'] ,
\ '<F9>' : ['<<F9>' , 'change window'] ,
\ '<F10>' : ['<F10>' , 'close VimsCode'] ,
\ 'Ctrl-a' : ['<c-a>' , 'divide into two vim'] ,
\ '²' : ['²' , 'display plugins'] ,
\ }
let g:which_key_map.a = {
\ 'name' : 'Raccourcis Vim' ,
\ 'Ctrl-w-w' : ['<C-W>w' , 'other-window'] ,
\ 'Ctrl-w-c' : ['<C-W>c' , 'delete-window'] ,
\ 'Ctrl-w-s' : ['<C-W>s' , 'split-window-below'] ,
\ 'Ctrl-w-v' : ['<C-W>v' , 'split-window-right'] ,
\ 'Ctrl-w-h' : ['<C-W>h' , 'window-left'] ,
\ 'Ctrl-w-j' : ['<C-W>j' , 'window-below'] ,
\ 'Ctrl-w-l' : ['<C-W>l' , 'window-right'] ,
\ 'Ctrl-w-k' : ['<C-W>k' , 'window-up'] ,
\ ':resize +5' : [':resize +5' , 'expand-window-below'] ,
\ ':resize -5' : [':resize -5' , 'expand-window-up'] ,
\ 'Ctrl-w-=' : ['<C-W>=' , 'balance-window'] ,
\ }