" designed for vim 8+ if has("eval") " vim-tiny lacks 'eval' let skip_defaults_vim = 1 endif set nocompatible "####################### Vi Compatible (~/.exrc) ####################### " automatically indent new lines set autoindent " automatically write files when changing when multiple files open set autowrite " activate line numbers set number " turn col and row position on in bottom right set ruler " see ruf for formatting " show command and insert mode set showmode set tabstop=2 "####################################################################### set softtabstop=2 " mostly used with >> and << set shiftwidth=2 set smartindent set smarttab if v:version >= 800 " stop vim from silently messing with files that it shouldn't set nofixendofline " better ascii friendly listchars set listchars=space:*,trail:*,nbsp:*,extends:>,precedes:<,tab:\|> " i hate automatic folding set foldmethod=manual set nofoldenable endif " mark trailing spaces as errors if has("match") match ErrorMsg '\s\+$' endif " enough for line numbers + gutter within 80 standard set textwidth=72 " replace tabs with spaces automatically set expandtab " disable relative line numbers, remove no to sample it set norelativenumber " makes ~ effectively invisible "highlight NonText guifg=bg " turn on default spell checking "set spell " more risky, but cleaner set nobackup set noswapfile set nowritebackup set icon " center the cursor always on the screen "set scrolloff=999 " highlight search hits set hlsearch set incsearch set linebreak " avoid most of the 'Hit Enter ...' messages set shortmess=aoOtTI " prevents truncated yanks, deletes, etc. set viminfo='20,<1000,s1000 " not a fan of bracket matching or folding if has("eval") " vim-tiny detection let g:loaded_matchparen=1 endif set noshowmatch " wrap around when searching set wrapscan " Just the defaults, these are changed per filetype by plugins. " Most of the utility of all of this has been superceded by the use of " modern simplified pandoc for capturing knowledge source instead of " arbitrary raw text files. set fo-=t " don't auto-wrap text using text width set fo+=c " autowrap comments using textwidth with leader set fo-=r " don't auto-insert comment leader on enter in insert set fo-=o " don't auto-insert comment leader on o/O in normal set fo+=q " allow formatting of comments with gq set fo-=w " don't use trailing whitespace for paragraphs set fo-=a " disable auto-formatting of paragraph changes set fo-=n " don't recognized numbered lists set fo+=j " delete comment prefix when joining set fo-=2 " don't use the indent of second paragraph line set fo-=v " don't use broken 'vi-compatible auto-wrapping' set fo-=b " don't use broken 'vi-compatible auto-wrapping' set fo+=l " long lines not broken in insert mode set fo+=m " multi-byte character line break support set fo+=M " don't add space before or after multi-byte char set fo-=B " don't add space between two multi-byte chars set fo+=1 " don't break a line after a one-letter word " requires PLATFORM env variable set (in ~/.bashrc) if $PLATFORM == 'mac' " required for mac delete to work set backspace=indent,eol,start endif " stop complaints about switching buffer with changes set hidden " command history set history=100 " here because plugins and stuff need it if has("syntax") syntax enable endif " faster scrolling set ttyfast " allow sensing the filetype filetype plugin on " high contrast for streaming, etc. set background=dark " base default color changes (gruvbox dark friendly) hi StatusLine ctermfg=black ctermbg=NONE hi StatusLineNC ctermfg=black ctermbg=NONE hi Normal ctermbg=NONE hi Special ctermfg=cyan hi LineNr ctermfg=black ctermbg=NONE hi SpecialKey ctermfg=black ctermbg=NONE hi ModeMsg ctermfg=black cterm=NONE ctermbg=NONE hi MoreMsg ctermfg=black ctermbg=NONE hi NonText ctermfg=black ctermbg=NONE hi vimGlobal ctermfg=black ctermbg=NONE hi ErrorMsg ctermbg=234 ctermfg=darkred cterm=NONE hi Error ctermbg=234 ctermfg=darkred cterm=NONE hi SpellBad ctermbg=234 ctermfg=darkred cterm=NONE hi SpellRare ctermbg=234 ctermfg=darkred cterm=NONE hi Search ctermbg=236 ctermfg=darkred hi vimTodo ctermbg=236 ctermfg=darkred hi Todo ctermbg=236 ctermfg=darkred hi IncSearch ctermbg=236 cterm=NONE ctermfg=darkred hi MatchParen ctermbg=236 ctermfg=darkred " color overrides au FileType * hi StatusLine ctermfg=black ctermbg=NONE au FileType * hi StatusLineNC ctermfg=black ctermbg=NONE au FileType * hi Normal ctermbg=NONE au FileType * hi Special ctermfg=cyan au FileType * hi LineNr ctermfg=black ctermbg=NONE au FileType * hi SpecialKey ctermfg=black ctermbg=NONE au FileType * hi ModeMsg ctermfg=black cterm=NONE ctermbg=NONE au FileType * hi MoreMsg ctermfg=black ctermbg=NONE au FileType * hi NonText ctermfg=black ctermbg=NONE au FileType * hi vimGlobal ctermfg=black ctermbg=NONE au FileType * hi ErrorMsg ctermbg=234 ctermfg=darkred cterm=NONE au FileType * hi Error ctermbg=234 ctermfg=darkred cterm=NONE au FileType * hi SpellBad ctermbg=234 ctermfg=darkred cterm=NONE au FileType * hi SpellRare ctermbg=234 ctermfg=darkred cterm=NONE au FileType * hi Search ctermbg=236 ctermfg=darkred au FileType * hi vimTodo ctermbg=236 ctermfg=darkred au FileType * hi Todo ctermbg=236 ctermfg=darkred au FileType * hi IncSearch ctermbg=236 cterm=NONE ctermfg=darkred au FileType * hi MatchParen ctermbg=236 ctermfg=darkred au FileType markdown,pandoc hi Title ctermfg=yellow ctermbg=NONE au FileType markdown,pandoc hi Operator ctermfg=yellow ctermbg=NONE au FileType bash set sw=2 au FileType c set sw=8 set cinoptions+=:0 " Edit/Reload vimr configuration file nnoremap confe :e $HOME/.vimrc nnoremap confr :source $HOME/.vimrc set ruf=%30(%=%#LineNr#%.50F\ [%{strlen(&ft)?&ft:'none'}]\ %l:%c\ %p%%%) " only load plugins if Plug detected if filereadable(expand("~/.vim/autoload/plug.vim")) " github.com/junegunn/vim-plug call plug#begin('~/.local/share/vim/plugins') Plug 'sheerun/vim-polyglot' Plug 'vim-pandoc/vim-pandoc' Plug 'rwxrob/vim-pandoc-syntax-simple' Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } Plug 'tpope/vim-fugitive' Plug 'hashivim/vim-terraform' Plug 'morhetz/gruvbox' call plug#end() " terraform let g:terraform_fmt_on_save = 1 " pandoc let g:pandoc#formatting#mode = 'h' " A' let g:pandoc#formatting#textwidth = 72 " golang let g:go_fmt_fail_silently = 0 let g:go_fmt_command = 'goimports' let g:go_fmt_autosave = 1 let g:go_gopls_enabled = 1 let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_function_calls = 1 let g:go_highlight_operators = 1 let g:go_highlight_extra_types = 1 let g:go_highlight_variable_declarations = 1 let g:go_highlight_variable_assignments = 1 let g:go_highlight_build_constraints = 1 let g:go_highlight_diagnostic_errors = 1 let g:go_highlight_diagnostic_warnings = 1 "let g:go_auto_type_info = 1 " forces 'Press ENTER' too much let g:go_auto_sameids = 0 "let g:go_metalinter_command='golangci-lint' "let g:go_metalinter_command='golint' "let g:go_metalinter_autosave=1 set updatetime=100 "let g:go_gopls_analyses = { 'composites' : v:false } au FileType go nmap t :GoTest! au FileType go nmap v :GoVet! au FileType go nmap b :GoBuild! au FileType go nmap c :GoCoverageToggle au FileType go nmap i :GoInfo au FileType go nmap l :GoMetaLinter! else autocmd vimleavepre *.go !gofmt -w % " backup if fatih fails endif " format perl on save if has("eval") " vim-tiny detection fun! s:Perltidy() let l:pos = getcurpos() silent execute '%!perltidy -i=2' call setpos('.', l:pos) endfun "autocmd FileType perl autocmd BufWritePre call s:Perltidy() endif "autocmd vimleavepre *.md !perl -p -i -e 's,(? [some thing](https://duck.com/lite?kae=t&q=some thing) " s,/foo,/bar,g "autocmd vimleavepre *.md !perl -p -i -e 's,\[([^\]]+)\]\(\),[\1](https://duck.com/lite?kd=-1&kp=-1&q=\1),g' % autocmd BufWritePost *.md silent !toemoji % autocmd BufWritePost *.md silent !toduck % " fill in anything beginning with @ with a link to twitch to it " autocmd vimleavepre *.md !perl -p -i -e 's, @(\w+), [\\@\1](https://twitch.tv/\1),g' % " make Y consitent with D and C (yank til end) map Y y$ " better command-line completion set wildmenu " disable search highlighting with when refreshing screen nnoremap :nohl " enable omni-completion set omnifunc=syntaxcomplete#Complete " force some files to be specific file type au bufnewfile,bufRead $SNIPPETS/md/* set ft=pandoc au bufnewfile,bufRead $SNIPPETS/sh/* set ft=sh au bufnewfile,bufRead $SNIPPETS/bash/* set ft=bash au bufnewfile,bufRead $SNIPPETS/go/* set ft=go au bufnewfile,bufRead $SNIPPETS/c/* set ft=c au bufnewfile,bufRead $SNIPPETS/html/* set ft=html au bufnewfile,bufRead $SNIPPETS/css/* set ft=css au bufnewfile,bufRead $SNIPPETS/js/* set ft=javascript au bufnewfile,bufRead $SNIPPETS/python/* set ft=python au bufnewfile,bufRead $SNIPPETS/perl/* set ft=perl au bufnewfile,bufRead user-data set ft=yaml au bufnewfile,bufRead meta-data set ft=yaml au bufnewfile,bufRead *.bash* set ft=bash au bufnewfile,bufRead *.{peg,pegn} set ft=config au bufnewfile,bufRead *.profile set filetype=sh au bufnewfile,bufRead *.crontab set filetype=crontab au bufnewfile,bufRead *ssh/config set filetype=sshconfig au bufnewfile,bufRead .dockerignore set filetype=gitignore au bufnewfile,bufRead *gitconfig set filetype=gitconfig au bufnewfile,bufRead /tmp/psql.edit.* set syntax=sql au bufnewfile,bufRead *.go set spell "fix bork bash detection if has("eval") " vim-tiny detection fun! s:DetectBash() if getline(1) == '#!/usr/bin/bash' || getline(1) == '#!/bin/bash' set ft=bash set shiftwidth=2 endif endfun autocmd BufNewFile,BufRead * call s:DetectBash() endif " displays all the syntax rules for current position, useful " when writing vimscript syntax plugins if has("syntax") function! SynStack() if !exists("*synstack") return endif echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') endfunc endif " start at last place you were editing au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif "au BufWritePost ~/.vimrc so ~/.vimrc " functions keys map :set number! :set relativenumber! nmap :call SynStack() set pastetoggle= map :set list! map :set cursorline! map :set spell! map :set fdm=indent nmap 2 :set pastei " disable arrow keys (vi muscle memory) "noremap :echoerr "Umm, use k instead" "noremap :echoerr "Umm, use j instead" "noremap :echoerr "Umm, use h instead" " noremap :echoerr "Umm, use l instead" " inoremap " inoremap " inoremap " inoremap " " better use of arrow keys, number increment/decrement nnoremap nnoremap " Better page down and page up noremap noremap " Set TMUX window name to name of file "au fileopened * !tmux rename-window TESTING " read personal/private vim configuration (keep last to override) set rtp^=~/.vimpersonal set rtp^=~/.vimprivate set rtp^=~/.vimwork