"" 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 'easymotion/vim-easymotion' Plug 'honza/vim-snippets' Plug 'jamessan/vim-gnupg' Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' Plug 'junegunn/goyo.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', {'commit': '8287981'} Plug 'machakann/vim-highlightedyank' Plug 'majutsushi/tagbar' 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' let g:zoomwintab_hidetabbar=0 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") Plug 'neovim/nvim-lsp' endif " Colors Plug 'altercation/vim-colors-solarized' Plug 'KKPMW/sacredforest-vim' Plug 'junegunn/seoul256.vim' Plug 'romainl/Apprentice' Plug 'arcticicestudio/nord-vim' " Plug 'axvr/zepl.vim' call plug#end() "" Plugin configuration {{{1 " Toggles nnoremap cpg :GitGutterToggle nnoremap cpn :NERDTreeToggle nnoremap cpt :TagbarToggle nnoremap cpu :GundoToggle nnoremap cp Remembrall('cp') " Fuzzy finder nnoremap a :Ag nnoremap b :Buffers nnoremap C :Colors nnoremap f :Files nnoremap g :GitFiles nnoremap r :History nnoremap : :History: nnoremap / :History/ nnoremap l :BLines nnoremap a :Ag nnoremap :Buffers nnoremap :Files nnoremap :GitFiles " Fugitive nnoremap gs :Gstatus 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 = 0 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" " 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="" let g:UltiSnipsSnippetDirectories=['UltiSnips', 'mySnippets'] let g:UltiSnipsSnippetsDir="~/.vim/mySnippets" " let g:UltiSnipsUsePythonVersion=3 " Vimtex let g:vimtex_fold_enabled=1 " Makes %s slow! 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_fold_types = { " \ 'preamble' : {'enabled' : 0}, " \ 'envs' : { " \ 'blacklist' : ['lemma', 'proposition', 'theorem', 'equation'], " \ 'whitelist' : ['proof'], " \ }, " \} " 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' let g:tex_conceal= '' let g:tex_flavor='latex' "" Vim options {{{1 set backup set undofile set backupdir^=~/.vim/backup// set directory^=~/.vim/swap// set undodir^=~/.vim/undo// " ^= : prepends to list " // : store absolute path " set complete+=k set conceallevel=2 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 noequalalways set nojoinspaces set nowrap set path+=$PWD/** set shiftwidth=4 set showcmd set splitright set smartcase set smartindent 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" if !has("nvim") set encoding=utf-8 endif if has("nvim") set inccommand=split 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 ,te :tabedit nnoremap ,tl :+tabmove nnoremap ,th :-tabmove nnoremap ,t0 :tabmove 0 nnoremap ,t$ :tabmove nnoremap c :call delete($HOME."/.vim/swap/".substitute(expand('%:p'), '/', '%', 'g').".swp") nnoremap r :Start %:p nnoremap R :Start! %:p nnoremap cqo :copen nnoremap cqh :colder nnoremap cqc :cclose nnoremap got :call system('urxvt -cd '.getcwd().' &') nnoremap goT :call system('urxvt -cd '.expand("%:p:h").' &') nnoremap gof :call system('urxvt -e vifm '.getcwd().' '.getcwd().' &') nnoremap goF :call system('urxvt -e vifm '.expand("%:p:h").' '.expand("%:p:h").' &') nnoremap h :e %:p:s,.hpp$,.X123X,:s,.cpp$,.hpp,:s,.X123X$,.cpp, nnoremap Y y$ nnoremap fw :%s/\s\+$// nnoremap ft :%s/^ \+//g cnoremap cnoremap cnoremap cnoremap " Alternate file nnoremap  nnoremap + :Buffers " 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 ColorScheme * highlight String ctermfg=192 guifg=#d7ff87 " autocmd ColorScheme * highlight Folded ctermbg=23 ctermfg=185 guibg=#005f5f guifg=#d7d75f 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 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 "" My search {{{1 " http://vim.wikia.com/wiki/Searching_for_files function! MySearch(...) let l:prevgrepprg=&grepprg let l:prevgrepformat=&grepformat if a:1 == "Rg" set grepprg=rg\ -uu\ --vimgrep set grepformat=%f:%l:%c:%m elseif a:1 == "Gnufind" set grepprg=find\ .\ -name set grepformat=%f elseif a:1 == "Gitfind" set grepprg=git\ ls-files\ -i\ -x set grepformat=%f endif execute 'silent grep!' a:2 | cwindow | redraw! let &grepprg=l:prevgrepprg let &grepformat=l:prevgrepformat endfun command! -nargs=+ -complete=file_in_path Rg call MySearch("Rg", ) command! -nargs=+ -complete=file_in_path Gnufind call MySearch("Gnufind", ) command! -nargs=+ -complete=file_in_path Gitfind call MySearch("Gitfind", ) command! -nargs=+ -complete=file_in_path GitGrep execute 'silent Ggrep!' | cw | redraw! command! -nargs=+ -complete=file_in_path VimGrep execute 'silent vimgrep!' | cw | redraw! " Default search and find programs function! FillSearch(...) if a:0 == 0 let l:filltext = "" else let l:is_visual=(a:1 == "v") let l:line=getline(l:is_visual ? "'<" : "'[") let [line1,col1] = getpos(l:is_visual ? "'<" : "'[")[1:2] let [line2,col2] = getpos(l:is_visual ? "'>" : "']")[1:2] let l:filltext =l:line[col1 - 1: col2 - 1] endif call feedkeys(':' . g:my_fillprg . ' "' . l:filltext . '"'."\") endfunction let g:my_searchprgs = ['Rg', 'GitGrep', 'VimGrep'] let g:my_findprgs = ['Gnufind', 'Gitfind'] let g:my_searchprg = 0 let g:my_findprg = 0 nnoremap g/ :let g:my_fillprg=g:my_searchprgs[g:my_searchprg]:set opfunc=FillSearchg@ nnoremap ,g :let g:my_fillprg=g:my_searchprgs[g:my_searchprg]:call FillSearch() xnoremap ,g :let g:my_fillprg=g:my_searchprgs[g:my_searchprg]:call FillSearch(visualmode()) nnoremap ,f :let g:my_fillprg=g:my_findprgs[g:my_findprg]:call FillSearch() " Cycle search / find prgs nnoremap cog :let g:my_searchprg=(g:my_searchprg+1)%len(g:my_searchprgs):let &ro = &ro nnoremap cof :let g:my_findprg=(g:my_findprg+1)%len(g:my_findprgs):let &ro = &ro "" Status line {{{1 function! Mixed_indent() let l:spaces=search('\v(^ +)','n') let l:tabs=search('\v(^\t+)','n') return (l:spaces * l:tabs > 0) endfunction function! GlobalCwd() return getcwd(-1, -1) endfunction function! TabCwd(number) if haslocaldir(-1, a:number) return getcwd(-1, a:number) endif return "" endfunction function! WinCwd() if haslocaldir(0) return getcwd() endif return "" endfunction set showtabline=2 let g:tabprefix = "" let g:tablabel = "%N%{flagship#tabmodified()} %{TabCwd(v:lnum) != '' ? pathshorten(TabCwd(v:lnum)) : ''}" let g:flagship_skip = 'FugitiveStatusline' augroup myflags autocmd! autocmd CmdwinEnter,BufEnter,BufRead,BufWritePost * let b:trailing=search('\s\+$','n') autocmd CmdwinEnter,BufEnter,BufRead,BufWritePost * let b:mixed=Mixed_indent() autocmd User Flags call Hoist("buffer", "%{FugitiveHead('') != '' ? '['.FugitiveHead('').']' : ''}") autocmd User Flags call Hoist("buffer", "%{b:trailing?'[tw]':''}") autocmd User Flags call Hoist("buffer", "%{b:mixed?'[mixed]':''}") autocmd User Flags call Hoist("buffer", "%{&paste?'[paste]':''}") autocmd User Flags call Hoist("window", "%{WinCwd() != '' ? '['.WinCwd().']' : ''}") highlight MyGlobals ctermfg=255 ctermbg=240 autocmd User Flags call Hoist("global", {"hl": "MyGlobals"}, "[%{pathshorten(GlobalCwd())}, %{g:my_searchprgs[g:my_searchprg]}, %{g:my_findprgs[g:my_findprg]}]") augroup END "" 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 "" Experimental {{{1 lua require'nvim_lsp'.pyls.setup{} autocmd Filetype python setlocal omnifunc=v:lua.vim.lsp.omnifunc nnoremap 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()) " highlight LineNr ctermbg=159 ctermfg=27 guibg=#afffff guifg=#005fff " highlight StatusLineNC ctermbg=22 ctermfg=121 guibg=#005f00 guifg=#87ffaf " highlight Comment ctermbg=159 ctermfg=195 guibg=#afffff guifg=#d7ffff " highlight Normal ctermbg=195 ctermfg=237 guibg=#d7ffff guifg=#3a3a3a " highlight Special ctermfg=96 guifg=#875f87 " highlight StatusLine ctermbg=131 ctermfg=223 guibg=#af5f5f guifg=#ffd7af " highlight Statement ctermfg=65 guifg=#5f875f " highlight Type ctermfg=254 guifg=#e4e4e4