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 let g:startify_custom_header = [ \ ' _ __ _ __ ___ __ ___ ', \ ' / |/ / __(_)_ _ / |/ /__ _____/ / |_ |', \ ' / / |/ / / ` \ / /|_/ / _ `/ __/ _ \ / __/ ', \ '/_/|_/|___/_/_/_/_/ /_/ /_/\_,_/\__/_//_/ /____/ ', \] call plug#begin('~/.vim/plugged') Plug 'junegunn/vim-easy-align/' Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim', Plug 'pbogut/fzf-mru.vim', Plug 'junegunn/gv.vim' Plug 'jreybert/vimagit' Plug 'janko/vim-test' Plug 'NLKNguyen/papercolor-theme' Plug 'vim-airline/vim-airline' " Plug 'vim-airline/vim-airline-themes' Plug 'dracula/vim', { 'as': 'dracula' } Plug 'lifepillar/vim-solarized8' Plug 'scrooloose/nerdtree' Plug 'wesQ3/vim-windowswap' Plug 'majutsushi/tagbar' Plug 'tpope/vim-obsession' Plug 'tpope/vim-dispatch' Plug 'tmux-plugins/vim-tmux-focus-events' Plug 'moll/vim-bbye' Plug 'mhinz/vim-startify' Plug 'AndrewRadev/tagalong.vim' Plug 'junegunn/goyo.vim' Plug 'junegunn/limelight.vim' Plug 'amix/vim-zenroom2' if version >= 800 Plug 'neoclide/coc.nvim', {'branch': 'release'} endif Plug 'tpope/vim-surround' Plug 'pelodelfuego/vim-swoop' Plug 'dense-analysis/ale' Plug 'tpope/vim-commentary' " Plug 'kovisoft/slimv' Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } Plug 'posva/vim-vue' Plug 'ap/vim-css-color' Plug 'pangloss/vim-javascript' Plug 'othree/html5.vim' Plug 'matthew-brett/vim-rst-sections' Plug 'cespare/vim-toml' Plug 'mustache/vim-mustache-handlebars' Plug 'Glench/Vim-Jinja2-Syntax' Plug 'evanleck/vim-svelte' Plug 'leafgarland/typescript-vim' Plug 'HerringtonDarkholme/yats.vim' Plug 'elixir-editors/vim-elixir' Plug 'elzr/vim-json' Plug 'rust-lang/rust.vim' Plug 'delphinus/vim-firestore' Plug 'sebdah/vim-delve' Plug 'guns/vim-clojure-static' Plug 'regedarek/ZoomWin' call plug#end() let g:coc_disable_startup_warning = 1 " set guifont="Inconsolata-dz Medium 12" if has("gui_running") if has("gui_gtk3") :set guifont="Fira Code Medium 11,Monospace 11" elseif has('macunix') set guifont="FiraCode-Retina:h14,Fira Code Medium,Inconsolata-dz:h12" elseif has("x11") " Also for GTK 1 :set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-* elseif has("gui_win32") :set guifont=Fira\ Code\ Medium\ 11;Luxi_Mono:h12:cANSI endif endif " set guifont="Fira Code Medium" " if has('macunix') " set guifont="Fira Code Medium 11,Inconsolata-dz:h12" " else " set guifont="Inconsolata-dz Medium 12" " endif let mapleader = ' ' let maplocalleader = ',' " Edit another file in the same directory as the current file. Uses expression " to extract path from current file's path (thanks to Douglas Potts) if has("unix") map ,e :e =expand("%:p:h") . "/" else map ,e :e =expand("%:p:h") . "\\" endif map ww 0v$gq map =j :%!jq . set backupdir=/tmp//,. set directory=/tmp//,. " Enable visible line numbers set number " When we return to Vim, or re-enter a buffer, check if it's been modified. set autoread au FocusGained,BufEnter * :checktime " Make the current word upper-case; useful for constants. nnoremap wu viwU nnoremap wl viwu nnoremap viwU nnoremap viwu nnoremap td :colorscheme dracula nnoremap ts :colorscheme solarized8 nnoremap tp :colorscheme PaperColor nnoremap bd :set background=dark nnoremap bl :set background=light nnoremap dd2kp nnoremap ddp nnoremap ,m :Make nnoremap q :Bdelete " Repeat the last macro nnoremap Q @@ " Close all folds nnoremap c- zM nnoremap cw y/ nnoremap wp 0v$gq inoremap jk " inoremap " Use 'p' to mean 'inside parantheses' in commands. onoremap p i( let g:magit_discard_untracked_do_delete=1 nnoremap ,gr :!git review nnoremap ,gp :!git push nnoremap ,gl :!git pull nnoremap ,gb :!git branch -l nnoremap ,gc :!git checkout -b nnoremap ,yt :!yarn test nnoremap ,m :Make " colorscheme PaperColor set background=dark " colorscheme dracula colorscheme solarized8 " For packages, versions 8.2 and later will autoload `start` packages " correctly even in your vimrc. if v:version < 802 packadd! dracula_pro endif syntax enable let g:dracula_colorterm = 0 " colorscheme dracula_pro set ignorecase smartcase set incsearch set complete=.,b,u,] set wildignore+=deps/*,node_modules/*,*.sw? " Turn off the beeping ('cause it's annoying) set noerrorbells set visualbell set t_vb= " Auto-indent code set autoindent " do not redraw the screen during macro execution set lazyredraw " Open new panes to right and bottom. set splitbelow set splitright map :pop " tabbing and indent options function! TabSize (size) if a:size==8 set noexpandtab else set expandtab endif exe 'set shiftwidth=' . a:size exe 'set tabstop=' . a:size return "Tab size = " . a:size endfunction call TabSize(2) map ,t2 :echo TabSize(2) map ,t3 :echo TabSize(3) map ,t4 :echo TabSize(4) map ,t8 :echo TabSize(8) " Explicitly set certain filetypes. augroup filetype au! au BufRead,BufNewFile *.S set filetype=c au bufRead,BufNewFile *.cc set filetype=cpp au bufRead,BufNewFile *.cpp set filetype=cpp au bufRead,BufNewFile *.inc set filetype=make au BufRead,BufNewFile *.eex set filetype=html au BufRead,BufNewFile *.bss set filetype=vb au BufRead,BufNewFile *.asm set filetype=nasm augroup END augroup java au! inoremap sop System.out.println( augroup END augroup cppprog au! au BufRead,BufNewFile *.h set cindent au BufRead,BufNewFile *.cc set cindent au BufRead,BufNewFile *.cpp set cindent augroup END augroup cprog au! au BufRead,BufNewFile *.[ch] set cindent augroup END augroup xml autocmd! autocmd FileType xml let g:xml_syntax_folding=1 autocmd FileType xml setlocal foldmethod=syntax autocmd FileType xml :syntax on autocmd FileType xml :%foldopen! augroup END " Apply the muttrc colouring to mutt setup files: au BufNewFile,BufRead .mutt.* set ft=muttrc augroup elixir autocmd! autocmd BufRead,BufNewFile *.ex,*.exs inoremap ii IO.inspect( autocmd BufRead,BufNewFile *.ex,*.exs inoremap ip IO.puts( augroup END augroup filetype vue autocmd! autocmd BufRead,BufNewFile *.vue inoremap cll console.log() iabbrev template export default {name: ""}; iabbrev iff if() augroup END augroup filetype typescript autocmd! autocmd BufRead,BufNewFile *.ts inoremap cll console.log() iabbrev iff if() iabbrev hsig async function NAME(request: Request, h: ResponseToolkit) {?NAME augroup END " augroup filetype make " autocmd! " " call TabSize(8) " set noexpandtab " augroup END " Automatic typo fixing iab compomemt component iab seahores seahorse iab KREN_EMERG KERN_EMERG " Disable the command 'K' (keyword lookup) " map K " List current buffers map :buffers " Reformat selected text; normal mode only so we don't accidentally wrap a " paragraph by typing that string! nmap wp 0v$gq " Copy word. nmap cw y/ " Save map :w " Needed because PuTTY doesn't seem to send the usual ctrl-up/down sequences map [A map [B map [C map [D " And these are for Mobaxterm map [1;5A map [1;5B map [1;5C map [1;5D map [H map [F map :wincmd k map :wincmd j map :wincmd h map :wincmd l " Don't automatically resize windows to be the same. set noequalalways " Fix the width of the window nnoremap wfw :set winfixwidth " Fix the height of the window nnoremap wfh :set winfixheight " map :wincmd k " map :wincmd j " Replay keystrokes map @a " map ?"v/""*y:e "*p " Set swapsync to 'nothing' - potentially more data loss (no forced write to disk " on swap write), but makes writes faster. I'm willing to take the chance. :-) " Not supported on Neovim. if !has("nvim") set sws= endif " Set showmatch - this flashes the cursor briefly at the matching ( or { " when ) or } is entered. (If user keeps typing, cursor just pops up very " quickly, then comes back.) set showmatch " The command {number}CTRL-G show the current nuffer number, too. " This is yet another feature that vi does not have. " As I always want to see the buffer number I map it to CTRL-G. " Pleae note that here we need to prevent a loop in the mapping by " using the comamnd "noremap"! noremap 2 " =================================================================== " VIM - Editing and updating the vimrc: " Re-source and edit vimrc, respectively nnoremap ,u :source $MYVIMRC nnoremap ,v :edit $MYVIMRC nnoremap ,i :PlugInstall nn ,s :mks! Session.vim " For some reason, the control-up/down doesn't work through putty, so create " alternates as well. nn ,k :wincmd h nn ,l :wincmd j nn ,p :wincmd k nn ,; :wincmd l " =================================================================== " ;rcm = remove "control-m"s - for those mails sent from DOS: nn ,rcm :%s/$//g " ,ksr = "kill space runs" " substitutes runs of two or more space to a single space: nmap ,ksr :%s/ \+/ /g vmap ,ksr :s/ \+/ /g " ,Sel = "squeeze empty lines" " Convert blocks of empty lines (not even whitespace included) " into *one* empty line (within current visual): map ,Sel :g/^$/,/./-j " ,Sbl = "squeeze blank lines" " Convert all blocks of blank lines (containing whitespace only) " into *one* empty line (within current visual): map ,Sbl :g/^\s*$/,/\S/-j " make backspace more like a 'normal' editor (help options / backspace) set backspace=1 " make the mouse active when run in an XTerm (this may disable middle click " pasting) if has("mouse") set mouse=ac endif " automatically write files on :make set autowrite " automatically indent code etc set autoindent " show file position set ruler " Don't highlight search targets (irritating) " set nohlsearch " Return makes a new line at the cursor without entering insert mode nmap i " Cut text down to size (C-J does not pre-join the lines) map 74\|bi map J74\|bi " Use fzf to find files map :Files map :Files =expand("%:p:h") " nnoremap m :FZFMru nnoremap n :NERDTreeToggle " Use F6 to swap buffers map :b # nnoremap b :b # map // gc$ nnoremap ss :syntax sync fromstart nnoremap t :TagbarToggle " date functions nnoremap ,dn ik!!date +'\%d/\%m/\%y'kJJ nnoremap ,dw ik!!date +'\%V'kJJ " xterm title magic if "$TERM" != "dumb" set title endif " set up cscope support (:help cscope) if has("cscope") set cscopetag set cscopetagorder=0 set nocsverb " compress the path display to only the final 2 elements if has("cscopepathcomp") set cscopepathcomp=2 endif set csverb map ,scs0 :cs add cscope.out map ,kcs0 :cs kill 0 map ,ccs0 :!cscope -b -q -R map ,fs :cs find s =expand("") map ,fg :cs find g =expand("") map ,fd :cs find d =expand("") map ,fc :cs find c =expand("") map ,fa :cs find t =expand("") map ,fi :cs find i =expand("%:t") map ,ss :cs find s map ,sg :cs find g map ,sd :cs find d map ,sc :cs find c map ,sa :cs find t endif " Avoids printing anything by accident... set printexpr=PrintFile(v:fname_in) function! PrintFile(fname) "call system("ghostview " . a:fname) "call system("lpr " . a:fname) call delete(a:fname) return v:shell_error endfunction function! ToggleWindowHorizontalVerticalSplit() if !exists('t:splitType') let t:splitType = 'vertical' endif if t:splitType == 'vertical' " is vertical switch to horizontal windo wincmd K let t:splitType = 'horizontal' else " is horizontal switch to vertical windo wincmd H let t:splitType = 'vertical' endif endfunction nnoremap wst :call ToggleWindowHorizontalVerticalSplit() " COC configuration if version >= 800 " if hidden is not set, TextEdit might fail. set hidden " Some servers have issues with backup files, see #649 set nobackup set nowritebackup " Better display for messages set cmdheight=2 " You will have bad experience for diagnostic messages when it's default 4000. set updatetime=300 " don't give |ins-completion-menu| messages. set shortmess+=c " always show signcolumns set signcolumn=yes " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. inoremap coc#refresh() " Use to confirm completion, `u` means break undo chain at current position. " Coc only does snippet and additional edit on confirm. inoremap pumvisible() ? "\" : "\u\" " Or use `complete_info` if your vim support it, like: " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') " Remap for rename current word nmap rn (coc-rename) " Remap for format selected region " xmap f (coc-format-selected) nmap rf (coc-format-selected) augroup mygroup autocmd! " Setup formatexpr specified filetype(s). autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') " Update signature help on jump placeholder autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end " Remap for do codeAction of selected region, ex: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap for do codeAction of current line nmap ac (coc-codeaction) " Fix autofix problem of current line nmap qf (coc-fix-current) " Create mappings for function text object, requires document symbols feature of languageserver. xmap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap if (coc-funcobj-i) omap af (coc-funcobj-a) " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python nmap (coc-range-select) xmap (coc-range-select) " Use `:Format` to format current buffer command! -nargs=0 Format :call CocAction('format') " Use `:Fold` to fold current buffer command! -nargs=? Fold :call CocAction('fold', ) " use `:OR` for organize import of current buffer command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') " Add status line support, for integration with other plugin, checkout `:h coc-status` set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Using CocList " Show all diagnostics nnoremap a :CocList diagnostics " Manage extensions nnoremap e :CocList extensions " Show commands nnoremap c :CocList commands " Find symbol of current document nnoremap o :CocList outline " Search workspace symbols nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev " Resume latest coc list nnoremap p :CocListResume endif " and indent and unindent code nmap :> vmap :> nmap :< vmap :< nnoremap f :Ag =expand("") " these "Ctrl mappings" work well when Caps Lock is mapped to Ctrl nmap tN :TestNearest nmap tF :TestFile nmap tS :TestSuite nmap tL :TestLast nmap tG :TestVisitd " Opening with the default program if has('macunix') " Open in default program nnoremap gF :!open " Open Finder nnoremap gH :!open %:p:h " Open in Safari nnoremap gB :!open -a Safari % elseif has('unix') " Open in default program nnoremap gF :!xdg-open " Open file manager nnoremap gH :!xdg-open %:p:h " Open in Browser nnoremap gB :!xdg-open % else echom "Don't know how to open on this platform." endif match Todo /\s\+$/ " Markdown folding let g:markdown_fold_style = 'nested' syntax on filetype on filetype plugin on filetype plugin indent on nnoremap :cn nnoremap :cp nnoremap z :Goyo " nmap ,l (Limelight) " xmap ,l (Limelight) nmap ,l :Limelight!! set textwidth=120