" ------- PLUGINS ------- " First init : installation des plugins if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif " Debut de chargement des plugins call plug#begin('~/.vim/plugged') " Verif de la syntaxe du code Plug 'scrooloose/syntastic' " Navigateur de fichiers Plug 'preservim/nerdtree' " Gestion des sessions Plug 'mhinz/vim-startify' " Git plugin with commands 'G' Plug 'tpope/vim-fugitive' " Modal git editing with g Plug 'jreybert/vimagit' " Affiche les symboles de modifs git dans la marge Plug 'airblade/vim-gitgutter' " Theme Plug 'drewtempelmeyer/palenight.vim' " Theme de barre de statut en bas Plug 'itchyny/lightline.vim' " Add syntax highlighting for a large range of filetypes Plug 'sheerun/vim-polyglot' call plug#end() " ------- TRUE COLORS ------- if (has("nvim")) let $NVIM_TUI_ENABLE_TRUE_COLOR=1 endif if (has("termguicolors")) set termguicolors endif " ------- CONF ------- " Use Vim settings, rather than Vi set nocompatible " Encodage set encoding=UTF-8 " Ouvre les fichiers sur plusieurs onglets au lieu de plusieurs buffers if !&diff | silent tab all | tabfirst | endif " Affiche la barre d'info en bas set laststatus=2 " Largeur maxi : 0 = desactive set textwidth=0 " Nombre de cmd dans l'historique set history=50 " Options du fichier ~/.viminfo set viminfo='20,\"50 " Active la touche Backspace set backspace=2 " Garde toujours X ligne(s) visible(s) à l'écran au dessus du curseur set scrolloff=5 " Affiche les commandes dans la barre de status set showcmd " Affiche la paire de parenthèses set showmatch " Essaye de garder le curseur dans la même colonne quand on change de ligne set nostartofline " Option de la complétion automatique set wildmode=list:full set wildignore+=*.o,*.obj,*.exe,*.so,*.dll,*.pyc,*.swp,*.jpg,*.png,*.gif,*.pdf,*.bak,.svn,.hg,.bzr,.git, "find the next match as we type the search set incsearch "highlight searches by default set hlsearch "set search to be case insensitive set ignorecase "unless you typed uppercase letters in your query set smartcase "add line numbers set number "turn on syntax highlighting syntax on filetype plugin on " Desactive le visualbell set visualbell t_vb= " Active la souris set mouse=a " Performances set hidden set lazyredraw set ttyfast " ------- THEME ------- set background=dark colorscheme palenight "let g:palenight_terminal_italics=1 " Surligne la ligne en cours set cursorline " N'affiche pas le mode en cours en bas, vu qu'il est sur la lightline set noshowmode let g:lightline = { \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { \ 'gitbranch': 'FugitiveHead' \ }, \ } " ------- INDENTATION ------- set shiftwidth=2 set tabstop=2 set softtabstop=2 set expandtab filetype indent plugin on " Desactive l'autoindent le temps d'un copier-coller set pastetoggle= " Change l'indentation nnoremap >> vnoremap >gv nnoremap << vnoremap >gv " ------- AUTOCOMPLETION ------- set omnifunc=syntaxcomplete#Complete set completeopt=menuone " Autocompletion avec la touche function! Smart_TabComplete() " Current line let line = getline('.') " from the start of the current line to one character right of the cursor let substr = strpart(line, -1, col('.')+1) " word till cursor let substr = matchstr(substr, "[^ \t]*$") " nothing to match on empty string if (strlen(substr)==0) return "\" endif " position of slash, if any let has_slash = match(substr, '\/') != -1 if (has_slash) " file matching return "\\" else " plugin matching return "\\" endif endfunction inoremap =Smart_TabComplete() " ------- FOLDS SETTINGS ------- set foldcolumn=3 set foldmethod=manual set foldlevelstart=99 autocmd BufWinLeave *.php,*.htm,*.html,*.css,*.c,*.cc,*.h,*.cpp,*.py,*.rb,*.js mkview autocmd BufWinEnter *.php,*.htm,*.html,*.css,*.c,*.cc,*.h,*.cpp,*.py,*.rb,*.js silent loadview " Cree un fold du prochain/precedent {, jusqu'au } de fermeture nmap ?{zf%za:noh nmap /{zf%za:noh nnoremap ?{zf%za:noh " Toggle le fold en cours nmap za " Ouvre tous les folds nnoremap zR " Ferme tous les folds nnoremap zM " ------- PLUGIN: NerdTree ------- let NERDTreeQuitOnOpen=1 let NERDTreeShowHidden=1 " Affiche/Cache l'explorateur NerdTree noremap e :NERDTreeToggle " ------- PLUGIN: Syntastic ------- let g:syntastic_always_populate_loc_list = 1 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 " Infos de syntaxe nmap :SyntasticInfo nmap :Errors " ------- PLUGIN: GitGutter ------- let g:gitgutter_terminal_reports_focus = 0 let g:gitgutter_async = 0 autocmd BufWritePost * GitGutter " ------- PLUGIN: Magit ------- map :Magit imap :Magit " ------- PLUGIN: Startify (sessions) ------- let g:startify_session_persistence = 1 let g:startify_enable_special = 0 let g:startify_files_number = 10 let g:startify_relative_path = 0 let g:startify_change_to_dir = 1 let g:startify_update_oldfiles = 1 let g:startify_session_autoload = 1 let g:startify_custom_header = 'startify#pad([ " VIM - STARTIFY"] + [" [e] Empty file" ])' let g:startify_lists = [ \ { 'type': 'sessions', 'header': [' Sessions'] }, \ { 'type': 'files', 'header': [' MRU'] }, \ { 'type': 'dir', 'header': [' MRU '. getcwd()] }, \ { 'type': 'bookmarks', 'header': [' Bookmarks'] }, \ { 'type': 'commands', 'header': [' Commands'] }, \ ] let g:startify_session_before_save = [ \ 'echo "Cleaning up before saving.."', \ 'silent! NERDTreeTabsClose' \ ] function! SessionCreate() if empty(v:this_session) if tabpagenr("$") > 1 SSave! endif endif endfunction " Quitte quand plusieurs onglets sont ouverts, et cree une session si elle n'existe pas noremap q :call SessionCreate():qa " Supprime la session en cours noremap d :SDelete " ------- CLAVIER ------- map ; A; " Enregistre tous les onglets en meme temps noremap w :wa " Commente la ligne courante autocmd VimEnter *.php,*.js,*.c,*.cc,*.h,*.cpp noremap 0i// autocmd VimEnter *.sh noremap 0i# " Clear search highlighting nnoremap :noh " ------- TABS ------- " Creer un nouveau tab et ouvre l'explorateur NerdTree noremap t :$tabe:NERDTreeToggle noremap :$tabe:NERDTreeToggle inoremap :$tabe:NERDTreeToggle " Passer au precedent/suivant tab noremap gT inoremap gT noremap gt inoremap gt " Deplacer le tab courant vers la gauche/droite noremap :tabm -1 noremap :tabm +1