" set x=y [[[ " set autoindent set autoread set background=dark " set colorcolumn=80 set clipboard+=unnamedplus set diffopt=filler,context:3 if has('nvim-0.3.2') || has("patch-8.1.0360") set diffopt=filler,internal,algorithm:histogram,indent-heuristic endif set encoding=utf-8 set expandtab " set foldmethod=indent set foldmethod=marker set hlsearch " set ignorecase set linebreak set linespace=5 set mouse=a " set mouse=c set nofixendofline " set noswapfile set relativenumber set shiftwidth=4 set smartcase set tabstop=4 " set t_Co=256 " set termguicolors set timeoutlen=350 " set timeoutlen=200 " set tw=75 " set tw=70 set tw=60 set undodir=~/.vim/undo set undofile " set updatetime=1000 " set updatetime=500 set updatetime=0 autocmd VimResized * wincmd = filetype plugin on filetype indent on syntax on autocmd CursorHold * if !bufexists("[Command Line]") | checktime | endif " cursor indicator [[[ " " set listchars=tab:\|\ " set list " set cursorcolumn " set cursorline " ]]] cursor indicator " " ]]] set x=y " " commands for file types [[[ " autocmd BufNewFile,BufRead .* set syntax=sh autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown autocmd FileType *css,gitcommit,haskell,htmldjango,html,graphql,javascript,javascriptreact,json,lisp,markdown, \racket,tex,text,yaml set tabstop=2 shiftwidth=2 " autocmd BufNewFile,BufRead *.md set filetype=markdown " autocmd Filetype markdown set textwidth=0 " autocmd Filetype html set foldmarker=0 autocmd BufNewFile,BufRead *.gd set expandtab! autocmd Filetype go set noexpandtab sw=4 " autocmd FileType go,html,java,javascript,python,lua set fdm=indent " autocmd FileType go,html,java,javascript,javascriptreact,Jenkinsfile,python,lua set fdm=indent autocmd FileType go,html,java,Jenkinsfile,python,lua set fdm=indent " autocmd FileType html,javascript,Jenkinsfile,python,lua set fdm=indent autocmd BufNewFile,BufRead *.gql setfiletype graphql autocmd Filetype markdown let g:AutoPairs = {'(':')', '[':']', '{':'}','"':'"', "`":"`", '```':'```', '"""':'"""', "'''":"'''", "*":"*"} " autocmd Filetype markdown map :LivedownToggle autocmd Filetype markdown let g:AutoPairs={'(':')', '[':']', '{':'}','"':'"', "`":"`", '```':'```', '"""':'"""', "'''":"'''","*":"*"} autocmd Filetype markdown map :InstantMarkdownPreview autocmd Filetype markdown map :InstantMarkdownStop:InstantMarkdownPreview autocmd Filetype markdown inoremap < < >>A autocmd Filetype markdown inoremap >> > " autocmd Filetype markdown set commentstring= " format options [[[ " " a = auto-format paragraphs " c = wrap comments " j = remove comment header when joining lines " M = don't add space when joining lines " q = format comments with gq " t = wrap lines " v = break lines in insert " w = whitespace continues paragraph " ]]] format options " " autocmd FileType markdown,tex,text set spell spelllang=en_us formatoptions=acjMqtvw autocmd FileType markdown,tex,text set spell spelllang=en_us formatoptions=cjMqtvw autocmd Filetype groovy,Jenkinsfile,taskdata set tw=0 autocmd Filetype json nnoremap j :%!python -m json.tool autocmd Filetype json set foldmethod=marker autocmd Filetype racket set commentstring=;%s; autocmd Filetype racket let g:AutoPairs = {'(':')', '[':']', '{':'}','"':'"', "`":"`", '```':'```', '"""':'"""', "'''":"'''"} autocmd FileType sh map :!clear && shellcheck % autocmd FileType tex set updatetime=1000 timeoutlen=300 autocmd FileType tex map :VimtexCompile autocmd VimEnter *.tex VimtexCompile autocmd VimLeave *.tex !tex-clean %:p autocmd BufNewFile,BufRead *.tmpl set tw=0 sw=2 ft=go-template fmr=[[[,]]] " " auto-reload vimrc [[[ " " augroup myvimrc " au! " au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif " augroup END " " ]]] auto-reload vimrc " " ]]] commands for file types " " commands for specific files [[[ " autocmd BufNewFile,BufRead watson*.fish set tabstop=2 shiftwidth=2 expandtab autocmd BufWritePost config.def.h silent !cd %:p:h; sudo rm config.h; sudo bear make install " autocmd BufRead config.def.h map :silent !cd %:p:h; sudo rm config.h; sudo bear make install autocmd BufRead config.def.h map :silent !cd %:p:h:!sudo rm config.h; sudo bear make install autocmd BufRead config.def.h set updatetime=3000 autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72 autocmd VimLeave /etc/default/grub !sudo grub-mkconfig -o /boot/grub/grub.cfg " autocmd BufWritePost key_* !sync-shortcuts autocmd BufNewFile,BufRead key_* map :w:silent !sync-shortcuts " map :silent !scp %:p k@192.168.0.17:/home/k/a1 " map :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1 " map :make -C ~/Documents/resume cv " ]]] commands for specific files " " vim-plug [[[ " plug auto-install 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 call plug#begin('~/.vim/plugged') " prequisite for other plugins Plug 'vim-scripts/L9' " find files from within Vim " Plug 'vim-scripts/FuzzyFinder' {{ if not .gui }} " Gotham color scheme Plug 'whatyouhide/vim-gotham' {{ end }} " " collection of Vim color schemes " Plug 'flazz/vim-colorschemes' " " preview Vim color scheme easily within Vim " Plug 'xolox/vim-colorscheme-switcher' " " prerequisite for above plugin " Plug 'xolox/vim-misc' " automatically save buffers upon returning to normal mode Plug '907th/vim-auto-save' let g:auto_save = 1 " let g:auto_save_events = ["CursorHold", "CursorHoldI"] let g:auto_save_events = ["CursorHold"] " autocmd VimEnter *.tex let g:auto_save = 0 " provides various functionality for writing LaTeX in Vim Plug 'lervag/vimtex' " au BufWritePost *.tex silent call Tex_RunLaTeX() au BufWritePost *.tex silent !pkill -USR1 xdvi.bin let g:Tex_MultipleCompileFormats = 'dvi,pdf' " let g:vimtex_view_general_viewer = 'evince' let g:vimtex_view_general_viewer = 'zathura' " let g:vimtex_quickfix_latexlog = { " \ 'overfull' : 0, " \ 'underfull' : 0, " \ 'global' : 0, " \ 'packages' : { " \ 'biblatex' : 0, " \ 'gensymb' : 0, " \ }, " \ 'references' : 0, " \ 'unused' : 0, " \} let g:vimtex_quickfix_ignore_filters = [ \'Overfull', \] let g:vimtex_quickfix_autoclose_after_keystrokes = 5 let g:vimtex_compiler_latexmk = { \ 'continuous' : 1, \} " \ 'continuous' : 0, {{ if not (eq .chezmoi.username "root") }} " auto-completion for various languages " arc Plug 'Valloric/YouCompleteMe' let g:ycm_filetype_blacklist = { \ 'tagbar': 1, \ 'qf': 1, \ 'notes': 1, \ 'unite': 1, \ 'vimwiki': 1, \ 'pandoc': 1, \ 'infolog': 1, \ 'mail': 1 \} {{ end }} " wrote short bits of text that expand into whatever you want " demo: https://www.youtube.com/watch?v=Zik6u0klD40 Plug 'SirVer/ultisnips' " better key bindings for UltiSnipsExpandTrigger let g:UltiSnipsExpandTrigger = "" let g:UltiSnipsJumpForwardTrigger = "" let g:UltiSnipsJumpBackwardTrigger = "" let g:ultisnips_javascript = { \ 'keyword-spacing': 'always', \ 'semi': 'never', \ 'space-before-function-paren': 'never', \ } " custom snippets Plug 'Kevin-Mok/vim-snippets' " to make YouCompleteMe work with UltiSnips (both use Tab) Plug 'ervandew/supertab' " make YCM compatible with UltiSnips (using supertab) let g:ycm_key_list_select_completion = ['', ''] let g:airline_powerline_fonts = 1 let g:airline_theme='supernova' " continue Markdown lists when started " arc Plug 'dkarter/bullets.vim' " coordinate Vim color scheme with terminal color scheme Plug 'dylanaraps/wal.vim' " Plug 'morhetz/gruvbox' Plug 'bluz71/vim-nightfly-colors', { 'as': 'nightfly' } " repeat plugin commands Plug 'tpope/vim-repeat' " better Django support Plug 'tweekmonster/django-plus.vim' " auto-close brackets Plug 'jiangmiao/auto-pairs' let g:AutoPairsMapSpace = 0 Plug 'henrik/vim-indexed-search' Plug 'PotatoesMaster/i3-vim-syntax' " vim file explorer Plug 'terryma/vim-multiple-cursors' " let g:multi_cursor_select_all_word_key='' let g:multi_cursor_exit_from_visual_mode=0 let g:multi_cursor_exit_from_insert_mode=0 Plug 'dag/vim-fish' " live preview Markdown" Plug 'suan/vim-instant-markdown', {'for': 'markdown'} let g:instant_markdown_autostart = 0 let g:instant_markdown_port = 8888 " Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } " let g:mkdp_auto_start = 1 " let g:mkdp_browser = 'firefox' " let g:mkdp_echo_preview_url = 1 " git helper Plug 'tpope/vim-fugitive' " auto reload file Plug 'djoshea/vim-autoread' " Plug 'mustache/vim-mustache-handlebars' " Plug 'trapd00r/vim-syntax-vidir-ls' Plug 'calviken/vim-gdscript3' " display hex colors in Vim " Plug 'RRethy/vim-hexokinase' Plug 'junegunn/goyo.vim' " prevent commands being executed through modelines " Plug 'ciaranm/securemodelines/' " different colors for each layer of surrounding brackets Plug 'luochen1990/rainbow' let g:rainbow_active = 1 " easy custom text objects Plug 'kana/vim-textobj-user' " latex custom text objects Plug 'rbonvall/vim-textobj-latex' " swap words Plug 'tommcdo/vim-exchange' " Plug 'scrooloose/nerdtree' " let NERDTreeQuitOnOpen=1 " let NERDTreeShowHidden=1 " Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " Plug 'junegunn/fzf.vim' Plug 'christoomey/vim-tmux-navigator' " mappings [[[ " let g:tmux_navigator_no_mappings = 1 nnoremap :TmuxNavigateDown nnoremap :TmuxNavigateUp nnoremap :TmuxNavigateLeft nnoremap :TmuxNavigateRight " nnoremap :TmuxNavigateDown " nnoremap :TmuxNavigateUp " nnoremap :TmuxNavigateLeft " nnoremap :TmuxNavigateRight " ]]] mappings " " highlight multiple words " TODO: mapping conflicts " " Plug 'inkarkat/vim-mark' " Plug 'jceb/vim-orgmode' " let g:org_todo_keywords=['TODO', 'STARTED', '|', 'DONE'] Plug 'junegunn/vim-easy-align' " Start interactive EasyAlign in visual mode (e.g. vipga) xmap ga (EasyAlign) " Start interactive EasyAlign for a motion/text object (e.g. gaip) nmap ga (EasyAlign) Plug 'wlangstroth/vim-racket' Plug 'neovimhaskell/haskell-vim' " Plug 'masukomi/vim-markdown-folding' Plug 'mikeboiko/vim-markdown-folding' autocmd FileType markdown set foldexpr=NestedMarkdownFolds() Plug 'cespare/vim-toml' Plug 'dpelle/vim-LanguageTool' " increment dates with C-a Plug 'tpope/vim-speeddating' Plug 'martinda/Jenkinsfile-vim-syntax' Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } let g:go_fmt_command = "" Plug 'buoto/gotests-vim' Plug 'tomlion/vim-solidity' Plug 'jparise/vim-graphql' Plug 'maxmellon/vim-jsx-pretty' Plug 'mlaursen/vim-react-snippets', { 'branch': 'main' } Plug 'cristianoliveira/vim-react-html-snippets' Plug 'jidn/vim-dbml' " Plug 'FuDesign2008/emoji-snippets.vim' Plug 'tpope/vim-surround' " ]]] vim-plug " " Mappings [[[ " call plug#end() {{ if .gui }} " autocmd vimenter * ++nested colorscheme gruvbox " colorscheme wal colorscheme nightfly {{ else }} colorscheme gotham256 {{ end }} " normal mappings [[[ " nnoremap nnoremap nnoremap Y yy " visual select across lines by default " nnoremap v " last macro " nnoremap Q @@ " toggle fold " nnoremap , za " jump to horizontal position for mark " nnoremap ' ` " indenting nnoremap > >> nnoremap < << inoremap << <a /^ nnoremap ac :.s/\(\w\w\)/\u\1\U\2/g " replace until end of line nnoremap c c$ " delete until end of line nnoremap d d$ " delete entire buffer nnoremap dg ggdG " delete entire line nnoremap dl 0d$ " delete lines matching pattern " nnoremap dls :g//d nnoremap dls q:ig//d " show docstring for cur word nnoremap do :YcmCompleter GetDoc " delete line into system clipboard nnoremap D "+dd " delete entire buffer into system clipboard nnoremap DA "+ggdG " find copied text nnoremap f q/p " find merge conflicts nnoremap fc /[<>=\|]\{7\} " reload folds nnoremap fmi :set foldmethod=indent zM nnoremap fmm :set foldmethod=marker zM " add marker foldmethod modeline nnoremap fi :YcmCompleter FixIt " check filetype nnoremap ft :se ft? " check todo's nnoremap ftd /TODO " nnoremap g :YcmCompleter GoTo nnoremap g :vs \| YcmCompleter GoTo " nnoremap gb nnoremap gb :Git blame " vimdiff split nnoremap gd :Gvdiff nnoremap gdh :Gvdiff HEAD^ nnoremap gdm :Gvdiff master nnoremap gdo :Gvdiff orig/master " toggle search highlighting nnoremap h :set hlsearch! hlsearch? " help nnoremap he :vert help nnoremap ht :set tabstop=2 shiftwidth=2 expandtab nnoremap vhe :vert help " don't add space when joining lines " " nnoremap j gJ " jump forward nnoremap j " join all paragraphs into single line " nnoremap jl :set tw=9999999gggqG " jump back nnoremap k " format current line nnoremap l Vgq " format this and next line nnoremap ll Vjgq " move cursor to middle of line " nnoremap m :call cursor(0, len(getline('.'))/2) nnoremap m :vert Man " apply normal command to selection vnoremap n q:anorm " turn off autoformat" nnoremap na :set spell spelllang=en_us formatoptions=cjMqtvw nnoremap nt :NERDTree " check if in neovim nnoremap nv :echo has('nvim') " don't wrap lines nnoremap nw :set nowrap " recursively open fold nnoremap o zO " paste from? " nnoremap p "*p " format paragraph nnoremap p gqip " Plug commands nnoremap pli :PlugInstall nnoremap plc :PlugClean nnoremap plu :PlugUpdate " don't break lines nnoremap py :set tw=0 " replace in next x lines " nnoremap r q:i.,.+s///gFsi " replace in line nnoremap r q:i.s///g " replace in visual selection vnoremap r q:is///g3ha " replace in entire file " nnoremap R q:i%s///g2F/i nnoremap ra q:i%s///g2F/i " remove italics tags nnoremap rmi :%s/<\/\?i>//g nnoremap rn :YcmCompleter RefactorRename nnoremap rs :res " reload vim config nnoremap rv :source $MYVIMRC vnoremap s :sort nnoremap sc :set spell spelllang=en_us " run current file in shell nnoremap sh :!%:p " sort lines until end of file nnoremap so q:i.,$sort " vertical split " nnoremap sp :sp " sort lines nnoremap sol q:i.,.+sortFsi " set syntax to shell (for dotfiles) nnoremap sys :set syn=sh vnoremap t :!tac " capitalize letter nnoremap u vU " comment visual block " nnoremap vcc Vcc " uncomment visual block " nnoremap vcu Vcu " horizontal split " nnoremap vs :vs " open vimrc in vertical split nnoremap vv :vsp ~/.vimrc " copy next thing to system clipboard " nnoremap y "+ " nnoremap Y "+Y nnoremap y y$ nnoremap yo :Goyo " yank entire buffer nnoremap yg ggyG " toggle fold nnoremap z za " close all folds nnoremap zm zM " open all folds nnoremap zr zR " ]]] leader mappings " " function keys [[[ " map :wa map :xa map :q! map :qa! map :AutoSaveToggle " reload file nnoremap :e nnoremap :set paste"+p:set nopaste nnoremap :set paste"*p:set nopaste " ]]] function keys " map O " swap text visually vnoremap `.``gvP``P ino yiW==0 " splits [[[ " nnoremap nnoremap nnoremap nnoremap " Maximize height/width. nnoremap _ nnoremap | " ]]] splits " " ]]] Mappings " " Local Mappings [[[ " let maplocalleader="\\" " tex [[[ " autocmd Filetype tex noremap i$ :normal! T$vt$ autocmd Filetype tex noremap i$ :normal vi$ autocmd Filetype tex xnoremap a$ : normal!F$vf$ autocmd Filetype tex onoremap a$ :normal va$ autocmd Filetype tex inoremap bt \bowtie autocmd Filetype tex inoremap c \checkmark autocmd Filetype tex inoremap d \div autocmd Filetype tex inoremap D \Delta autocmd Filetype tex inoremap e \exists autocmd Filetype tex inoremap ep \epsilon autocmd Filetype tex inoremap fa \forall autocmd Filetype tex inoremap g \geq autocmd Filetype tex inoremap i \in autocmd Filetype tex inoremap la \leftarrow autocmd Filetype tex inoremap le \leq autocmd Filetype tex inoremap ln \log n autocmd Filetype tex inoremap lr \Leftrightarrow autocmd Filetype tex inoremap m \mu " autocmd Filetype tex inoremap n \neg autocmd Filetype tex inoremap n \neq autocmd Filetype tex inoremap N \mathbb{N} autocmd Filetype tex inoremap pg \pagebreak autocmd Filetype tex inoremap ph [,phantom] autocmd Filetype tex inoremap q \qquad autocmd Filetype tex inoremap r \rightarrow autocmd Filetype tex inoremap R \Rightarrow " autocmd Filetype tex inoremap s \subset autocmd Filetype tex inoremap s \text{s} autocmd Filetype tex inoremap st such that autocmd Filetype tex inoremap S \Sigma autocmd Filetype tex inoremap t \times " autocmd Filetype tex inoremap T $T$ autocmd Filetype tex inoremap T \Theta " replace bars/underscores in URL autocmd Filetype tex inoremap url :.s/\([-_]\)/\\\1/g autocmd Filetype tex inoremap v \vee autocmd Filetype tex inoremap w \wedge autocmd Filetype tex inoremap x $x$-axis autocmd Filetype tex inoremap y $y$-axis autocmd Filetype tex inoremap Z \mathbb{Z} " par3 autocmd Filetype tex inoremap wx $w(x)$ autocmd Filetype tex inoremap tx $t(x)$ " ]]] tex " autocmd Filetype c inoremap uc unsigned char autocmd BufNewFile,BufRead *.h nnoremap x 0iextern f{hc$; autocmd BufNewFile,BufRead ~/.habitctl/log nnoremap d Gy3kGp5e3j$rnj.j.j$. autocmd BufNewFile,BufRead ~/.habitctl/log nnoremap n $rn autocmd BufNewFile,BufRead ~/.habitctl/log nnoremap y $ry autocmd Filetype fish inoremap 1 $argv[1] autocmd Filetype fish inoremap 2 $argv[2] autocmd Filetype javascript inoremap x process.exit() autocmd Filetype markdown inoremap c - [ ] autocmd Filetype markdown nnoremap e 0f[lr autocmd Filetype markdown inoremap t TODO: autocmd Filetype markdown vnoremap r q:is/\[x/[ /g:set nohlsearch autocmd Filetype markdown vnoremap x q:is/\[ /[x/g:set nohlsearch autocmd Filetype markdown nnoremap x 0f[lrx " nnoremap x 0f[lrx autocmd Filetype go nnoremap f :GoTestFunc autocmd Filetype go nnoremap l :GoLint autocmd Filetype go nnoremap m :GoTests autocmd Filetype go nnoremap r yawq:iGoRename p autocmd Filetype go nnoremap t :GoTest autocmd Filetype go-template inoremap e {{"{{ else }}"}} autocmd Filetype go-template inoremap hd {{"{{ .chezmoi.homeDir }}"}} autocmd Filetype go-template nnoremap fp :%s/{{"{{{"}}/[[[/g:%s/}}}/]]]/g autocmd Filetype Jenkinsfile nnoremap q :.s/"/'/g autocmd Filetype Jenkinsfile vnoremap q :s/"/'/g autocmd Filetype python inoremap bp breakpoint() autocmd Filetype python inoremap ip from pprint import pprint autocmd Filetype python inoremap s self. " ]]] Local Mappings " " vim: fdm=marker ft=vim.go-template