"" Download vim-plug if necessary {{{1 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 "" Leader and Localleader {{{1 let mapleader = " " let maplocalleader = "," "" Plugins {{{1 call plug#begin('~/.vim/plugged') Plug 'PotatoesMaster/i3-vim-syntax' Plug 'SirVer/ultisnips' Plug 'airblade/vim-gitgutter' Plug 'AndrewRadev/splitjoin.vim' Plug 'honza/vim-snippets' Plug 'jamessan/vim-gnupg', { 'branch': 'main' } Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' Plug 'junegunn/gv.vim' Plug 'junegunn/heytmux' Plug 'junegunn/vim-easy-align' Plug 'junegunn/vim-peekaboo' Plug 'junegunn/vim-slash' Plug 'justinmk/vim-dirvish' Plug 'justinmk/vim-sneak' Plug 'kshenoy/vim-signature' Plug 'lervag/vimtex' Plug 'machakann/vim-highlightedyank' Plug 'mg979/vim-visual-multi' Plug 'neomake/neomake' Plug 'sjl/Gundo.vim', { 'on' : 'GundoToggle' } Plug 'tommcdo/vim-exchange' Plug 'tommcdo/vim-ninja-feet' Plug 'tpope/vim-abolish' Plug 'tpope/vim-apathy' Plug 'tpope/vim-commentary' Plug 'tpope/vim-dispatch' Plug 'tpope/vim-eunuch' Plug 'tpope/vim-flagship' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-obsession' Plug 'tpope/vim-projectionist' Plug 'tpope/vim-repeat' Plug 'tpope/vim-rsi' Plug 'tpope/vim-scriptease' Plug 'tpope/vim-sensible' Plug 'tpope/vim-surround' Plug 'tpope/vim-unimpaired' Plug 'troydm/zoomwintab.vim' Plug 'vim-scripts/ReplaceWithRegister' Plug 'vim-scripts/gmsh.vim' Plug 'wellle/targets.vim' if isdirectory($HOME."/dotfiles/plugins") Plug '~/dotfiles/plugins/vim-remembrall' Plug '~/dotfiles/plugins/vim-tmux-pilot' Plug '~/dotfiles/plugins/vim-ripple' Plug '~/dotfiles/plugins/vim-darjeeling' Plug '~/dotfiles/plugins/vim-macaw' endif if has("nvim") && hostname() != "peuplier" Plug '~/dotfiles/plugins/nvim-i3scratchpad' Plug 'neovim/nvim-lspconfig' " Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Plug 'nvim-treesitter/playground' endif " Colors Plug 'altercation/vim-colors-solarized' Plug 'junegunn/seoul256.vim' Plug 'romainl/Apprentice' Plug 'JuliaEditorSupport/julia-vim' " Plug 'axvr/zepl.vim' call plug#end() "" Plugin configuration {{{1 " Toggles nnoremap cpg :GitGutterToggle nnoremap cpu :GundoToggle " Fuzzy finder nnoremap b :Buffers nnoremap f :Files nnoremap g :GitFiles nnoremap r :History nnoremap : :History: nnoremap / :History/ nnoremap l :BLines nnoremap :Buffers nnoremap :Files nnoremap :GitFiles " Fugitive nnoremap gs :Git nnoremap gc :Gcommit nnoremap gr :Gread nnoremap gd :Gdiff " Multiple cursors let g:VM_maps = {} let g:VM_maps["Select Cursor Down"] = "" let g:VM_maps["Select Cursor Up"] = "" " Heytmux function! Call_heytmux(vm) call feedkeys(":'[,']Heytmux! ") endfunction nnoremap gh :set opfunc=Call_heytmuxg@ xnoremap gh :Heytmux! " Easy align xmap ga (EasyAlign) nmap ga (EasyAlign) xmap gl (LiveEasyAlign) nmap gl (LiveEasyAlign) " Plug nnoremap ,pi :PlugInstall nnoremap ,pu :PlugUpdate nnoremap ,pc :PlugClean " Remembrall if &runtimepath =~ 'remembrall' let g:remembrall_auto_accept = 1 nnoremap ,p Remembrall(',p') nnoremap ,, Remembrall('') augroup remembrall autocmd FileType tex nnoremap ,l Remembrall(',l') augroup END endif let g:remembrall_suffixes = [] let g:ripple_winpos = "vertical" let g:ripple_term_name = "term: ripple" nmap ,w (ripple_send_motion)iw:Ripple nmap , :Ripple " Ultisnips nnoremap cps :UltiSnipsEdit " Neomake nnoremap gm :Make nnoremap gM :Neomake! if &runtimepath =~ 'neomake' call neomake#configure#automake('w') endif let g:neomake_gcc_args=[ \ '-Wall', \ '-Wextra', \ '-Wpedantic', \ '-I.', '-I..', '-I../..' \ ] let g:neomake_python_enabled_makers = ['python', 'pylint'] " FZF.vim let $FZF_DEFAULT_OPTS='--layout=reverse' let g:fzf_buffers_jump = 1 let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } " Gundo let g:gundo_prefer_python3 = 1 " Ultisnips let g:UltiSnipsEditSplit="horizontal" let g:UltiSnipsExpandTrigger="" let g:UltiSnipsJumpBackwardTrigger="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsListSnippets="" " Vimtex let g:vimtex_fold_manual=1 let g:vimtex_fold_enabled=1 let g:vimtex_fold_bib_enabled=1 let g:vimtex_view_method='zathura' let g:vimtex_quickfix_mode=2 let g:vimtex_compiler_progname='nvr' let g:vimtex_syntax_enabled=1 let g:vimtex_toc_config={ \ 'layer_status': { \ 'content': 1, \ 'label': 0, \ 'todo': 1, \ 'include': 1 }, \ 'show_help': 0} let g:vimtex_delim_toggle_mod_list = [ \ ['\left', '\right'], \ ['\bigl', '\bigr'], \ ['\Bigl', '\Bigr'], \ ['\biggl', '\biggr'], \ ['\Biggl', '\Biggr'], \] nmap :setf txti\begin{align}0i\end{align} nmap m`gcc`` " Pilot let g:pilot_boundary='ignore' let g:pilot_mode='wintab' " let g:pilot_split_or_new='new' " let g:pilot_key_h='' " let g:pilot_key_j='' " let g:pilot_key_k='' " let g:pilot_key_l='' " let g:pilot_key_p='' "" Vim variables {{{1 let g:netrw_bufsettings='relativenumber' " Latex configuration let g:tex_conceal= '' let g:tex_flavor='latex' augroup latex autocmd! autocmd FileType tex let b:surround_124 = "\\lvert \r \\rvert" autocmd FileType tex let b:surround_110 = "\\lVert \r \\rVert" autocmd FileType tex let b:surround_101 = "\\begin{\1environment: \1}\r\\end{\1\1}" autocmd FileType tex let b:surround_99 = "\\\1command\1{\r}" augroup END "" Vim options {{{1 set backup set undofile set backupdir^=~/.vim/backup// set directory^=~/.vim/swap// " ^= : prepends to list " // : store absolute path " set complete+=k set conceallevel=0 set cursorline set diffopt=filler,vertical,hiddenoff set expandtab set exrc set foldmethod=marker set hidden set ignorecase set lazyredraw set laststatus=2 set listchars+=eol:$ set wildcharm= set mouse=a set equalalways set nojoinspaces set nowrap set path+=$PWD/** set shiftwidth=4 set showcmd set splitright set smartcase set nosmartindent set softtabstop=-1 " set sotftabstop=&shiftwidth " set formatoptions+=orw silent! set breakindent let &showbreak='--> ' set clipboard^=unnamedplus,unnamed " set spellfile="$HOME/.vim/spell/en.utf-8.add" set spelllang=fr,en if !has("nvim") set encoding=utf-8 endif if has("nvim") set inccommand="" endif "" Mappings {{{1 " .rst headings nnoremap 1 m`yypVr=`` nnoremap 2 m`yypVr-`` nnoremap m :.m nnoremap n nzz nnoremap N Nzz nnoremap AddWhiteSpaceAfter a h:silent call repeat#set("\AddWhiteSpaceAfter") nnoremap AddWhiteSpaceBefore i l:silent call repeat#set("\AddWhiteSpaceBefore") nmap ]w AddWhiteSpaceAfter nmap [w AddWhiteSpaceBefore nnoremap w :update nnoremap q :q nnoremap d :bd! nnoremap :q nnoremap ,bd :ls:bd nnoremap gl :+tabmove nnoremap gh :-tabmove " Delete cache nnoremap c :call delete($HOME."/.vim/swap/".substitute(expand('%:p'), '/', '%', 'g').".swp") " Dispatch nnoremap r :Start %:p nnoremap R :Start! %:p " Quickfix nnoremap cqo :copen nnoremap cqh :colder nnoremap cqc :cclose " Terminal and file manager nnoremap got :call system('urxvt -cd '.shellescape(getcwd()).' &') nnoremap goT :call system('urxvt -cd '.shellescape(expand("%:p:h")).' &') nnoremap gof :call system('urxvt -e vifm '.shellescape(getcwd()).' '.shellescape(getcwd()).' &') nnoremap goF :call system('urxvt -e vifm '.shellescape(expand("%:p:h")).' '.shellescape(expand("%:p:h")).' &') " Header files nnoremap \h :e %:p:s,.hpp$,.X123X,:s,.cpp$,.hpp,:s,.X123X$,.cpp, " Make Y behave like C, D nnoremap Y y$ " Formatting nnoremap fw :%s/\s\+$// nnoremap ft :%s/^ \+//g " Swap / and / cnoremap cnoremap cnoremap cnoremap " Alternate file nnoremap  " Buffers nnoremap + :Buffers " Align nnoremap yA vip:EasyAlign * :w " Source current file nnoremap ,s :source % " Shebang inoreabbrev #!! "#!/usr/bin/env" . (empty(&filetype) ? '' : ' '.&filetype) " Spell inoremap h1z=ea nnoremap s 1z= " Projectionist nnoremap ,e :E " Unimpaired nmap co yo "" Autocommands {{{1 augroup vimrc autocmd! autocmd BufWritePost *vimrc,*exrc :call feedkeys(":source %\") autocmd BufNewFile,Bufread /tmp/mutt-* setlocal tw=72 autocmd BufWritePre * \ if !isdirectory(expand(':p:h')) | \ call mkdir(expand(':p:h'), 'p') | \ endif " Detect filetypes (! 'setf freefem' does not override...) autocmd BufNewFile,BufRead *.geo,*.msh set filetype=gmsh autocmd BufNewFile,BufRead *.pde set filetype=freefem autocmd BufNewFile,BufRead *.plt set filetype=gnuplot " Filetype specific autocmd FileType cmake setlocal commentstring=#%s autocmd FileType cpp setlocal commentstring=//%s autocmd FileType freefem comp freefem autocmd FileType gmsh setlocal makeprg=gmsh\ % autocmd FileType gnuplot setlocal commentstring=#%s autocmd FileType gnuplot setlocal makeprg=gnuplot\ % autocmd FileType python setlocal makeprg=python\ % autocmd FileType julia setlocal makeprg=julia\ % autocmd FileType tex setlocal spell spelllang=en_us " Dirvish autocmd FileType dirvish nnoremap t :!touch % autocmd FileType dirvish setlocal errorformat=%f autocmd FileType dirvish setlocal relativenumber autocmd FileType dirvish silent! unmap augroup END "" Colorscheme {{{1 nnoremap ,cd :colorscheme darjeeling nnoremap ,cs :colorscheme seoul256 set notermguicolors colo darjeeling "" Neovim {{{1 if has("nvim") nnoremap goh :let @a=getcwd() \| lcd %:h \| terminal:execute 'lcd '.@aA tnoremap :bd! # nnoremap :b # \| norm A tnoremap nnoremap t :b term \| norm A endif if has("nvim") && &runtimepath =~ 'treesitter' lua < Remembrall('') nnoremap h lua vim.lsp.buf.hover() nnoremap a lua vim.lsp.buf.declaration() nnoremap d lua vim.lsp.buf.definition() nnoremap i lua vim.lsp.buf.implementation() nnoremap s lua vim.lsp.buf.signature_help() nnoremap t lua vim.lsp.buf.type_definition() nnoremap lua vim.lsp.stop_client(vim.lsp.get_active_clients()) catch echom "Error with LPS configuration" endtry endif " Tests {{{1 let g:ripple_repls = { \ "python": { \ "command": "ipython", \ "pre": "\[200~", \ "post": "\[201~", \ "addcr": 1, \ "filter": function('ripple#remove_leading_whitespaces'), \ }, \ "r": "radian" \ } " Vim sensible fix inoremap