Created
October 11, 2022 12:42
-
-
Save binarymason/4e782cc9d0b3a0e912697f9525bac16c to your computer and use it in GitHub Desktop.
Revisions
-
binarymason created this gist
Oct 11, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,482 @@ set nocompatible call plug#begin('~/.vim/plugged') " Plug 'MarcWeber/vim-addon-mw-utils' Plug 'ekalinin/Dockerfile.vim' Plug 'airblade/vim-gitgutter' " Shows a git diff in the gutter (sign column) and stages/undoes hunks Plug 'altercation/vim-colors-solarized' Plug 'bronson/vim-trailing-whitespace' " Highlights trailing whitespace in red and provides :FixWhitespace to fix it Plug 'christoomey/vim-tmux-navigator' " Seamless navigation between tmux panes and vim splits Plug 'ctrlpvim/ctrlp.vim', " Fuzzy file, buffer, mru, tag, etc finder. Plug 'ervandew/supertab' " Perform all your vim insert mode completions with Tab Plug 'gioele/vim-autoswap' " Stop the swap file messages. Just switch to the correct window! Plug 'jgdavey/vim-blockle', { 'for': 'ruby' } " Quickly toggle ruby blocks with Leader b Plug 'jiangmiao/auto-pairs' " Insert or delete brackets, parens, quotes in pair Plug 'junegunn/vim-easy-align', { 'for': ['ruby', 'python'] } " A Vim alignment plugin " Plug 'MaxMEllon/vim-jsx-pretty', " React JSX syntax highlighting and indenting for vim. Plug 'othree/html5.vim', { 'for': ['javascript', 'html'] } " HTML5 omnicomplete and syntax Plug 'mxw/vim-jsx' Plug 'pangloss/vim-javascript' " Vastly improved Javascript indentation and syntax support Plug 'panozzaj/vim-autocorrect' " Correct common typos and misspellings as you type Plug 'pbrisbin/vim-mkdir' " Automatically create any non-existent directories before writing the buffer. Plug 'rking/ag.vim' " Vim plugin for the_silver_searcher, 'ag' Plug 'scrooloose/nerdcommenter' " Vim plugin for intensely orgasmic commenting Plug 'scrooloose/nerdtree' " A tree explorer plugin for vim. Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' Plug 'tpope/gem-ctags' " Automatic ctags generation on gem install Plug 'tpope/rbenv-ctags' " Automatic ctags generation on gem install Plug 'tpope/vim-bundler' " Lightweight support for Bundler Plug 'tpope/vim-endwise' " Wisely add 'end' in ruby, endfunction/endif/more in vim script Plug 'tpope/vim-eunuch' " helpers for UNIX Plug 'tpope/vim-fugitive' " Git wrapper so awesome, it should be illegal Plug 'tpope/vim-rails' " Ruby on Rails power tools Plug 'tpope/vim-rbenv' " Tell vim to use correct ruby version Plug 'tpope/vim-repeat' " enable repeating supported plugin maps with '.' Plug 'tpope/vim-surround' " quoting/parenthesizing made simple Plug 'tpope/vim-unimpaired' " Pairs of handy bracket mappings Plug 'vim-airline/vim-airline' " lean & mean status/tabline for vim that's light as air Plug 'vim-airline/vim-airline-themes' " A collection of themes for vim-airline Plug 'vim-scripts/Highlight-UnMatched-Brackets' Plug 'fatih/vim-go' Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } " Show git status on NERDTree Plug 'w0rp/ale' " Asynchronous lint engine Plug 'skywind3000/asyncrun.vim' Plug 'google/vim-jsonnet' Plug 'hashivim/vim-terraform' Plug 'Chiel92/vim-autoformat' call plug#end() " ----------------------------------------------------------------------------- " User Interface " ----------------------------------------------------------------------------- filetype plugin indent on syntax enable " Use silent to squelch warnings when solarized is not installed. "silent! colorscheme solarized set background=dark set ttyfast " faster redraw set relativenumber " show relative numbers by default instead of line numbers set showcmd " show command in bottom bar set cursorline " highlight current line set wildmenu " visual autocomplete for command menu set showmatch " highlight matching [{()}] set laststatus=2 " always show the status bar set lazyredraw " Don't redraw screen when running macros. set scrolloff=2 " Show at least 2 lines around cursor set splitright " Vertical splits go on right set splitbelow " Horizontal splits go below set diffopt+=vertical " View diffs in vertical panes " Highlight character in 81st column red instead of set colorcolumn highlight ColorColumn ctermbg=red ctermfg=white " Make vertical splits look less obtrusive set fillchars+=vert:│ " Solid line instead of dashed silent! highlight VertSplit ctermbg=bg ctermfg=darkgrey " A slightly better version than vim-unimpaired's cob " Changing background color removes vertsplit styling. " Add back manually. nnoremap cob :set background=<C-R>=&background == 'dark' ? 'light' : 'dark'<CR><CR> \ :highlight VertSplit ctermbg=bg ctermfg=darkgrey<CR> " Change cursor shape between insert and normal mode in iTerm2.app let $NVIM_TUI_ENABLE_CURSOR_SHAPE=2 " let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" " let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" " if has("nvim") " set termguicolors " endif " NERDTree let NERDTreeMinimalUI=1 " remove the 'press ? for help' let NERDTreeShowHidden=1 " show hidden files by default let NERDTreeAutoDeleteBuffer=1 " auto remove deleted file from buffer let NERDTreeIgnore=['npm.debug.log'] let g:NERDTreeWinSize=50 " Set ultisnips triggers let g:UltiSnipsExpandTrigger="<tab>" let g:UltiSnipsJumpForwardTrigger="<tab>" let g:UltiSnipsJumpBackwardTrigger="<s-tab>" " NERDCommenter let g:NERDSpaceDelims=1 " pad one space with comments let g:NERDDefaultAlign='left' " align left instead of following indentation let g:NERDCommentEmptyLines=1 let g:NERDTrimTrailingWhitespace=1 " trim whitespace on uncomment " Airline config let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#show_buffers = 0 let g:airline_powerline_fonts=1 if !exists('g:airline_symbols') let g:airline_symbols={} endif let g:airline_symbols.space="\ua0" let g:airline_left_sep='' let g:airline_right_sep='' let g:airline_section_z='' let g:airline#extensions#tabline#left_sep = '' let g:airline#extensions#tabline#left_alt_sep = '' let g:airline#extensions#tabline#right_sep = '' let g:airline#extensions#tabline#right_alt_sep = '' " " " " Disable tabline close button let g:airline#extensions#tabline#show_close_button = 0 let g:airline#extensions#tabline#show_tab_type = 0 let g:airline#extensions#tabline#show_tab_nr = 0 let g:airline#extensions#tabline#buffer_min_count = 1 " " " Just show the file name let g:airline#extensions#tabline#fnamemod = ':t' let g:airline#extensions#tabline#tabs_label = '' let g:airline#extensions#tabline#show_splits = 0 let g:autoswap_detect_tmux=1 " Tell autoswap to switch to correct tmux window let g:used_javascript_libs = 'jquery,underscore,backbone,react' let g:jsx_ext_required = 0 " Allow JSX in normal JS files " set wildignore+=*/tmp/*,*.so,*.swp,*.zip " Persist CTRLP cache in ~/.cache/ctrlp let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp' let g:ctrlp_clear_cache_on_exit = 0 if executable('ag') let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' else let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] endif " Start interactive EasyAlign in visual mode (e.g. vipga) xmap ga <Plug>(EasyAlign) " Start interactive EasyAlign for a motion/text object (e.g. gaip) nmap ga <Plug>(EasyAlign) " ----------------------------------------------------------------------------- " Utilities " ----------------------------------------------------------------------------- " Spaces and Tabs set smartindent " new lines indent automatically " set smarttab " change indent amount depending on context set softtabstop=0 " number of spaces in tab when editing set shiftwidth=2 " Calling >> or << is 2 spaces set tabstop=2 " hardcode the default number of visual spaces per TAB set shiftround " When at 3 spaces and I hit >>, go to 4, not 5. set expandtab " tabs are spaces " Similiar to bash completion set wildmode=list:full " Allow vim yank and delete to go to clipboard " set clipboard=unnamed set clipboard=unnamedplus " Searching set incsearch " search as characters are entered set hlsearch " highlight matches set ignorecase smartcase " ignore case by default but not for autocomplete " ----------------------------------------------------------------------------- " Key Mappings " ----------------------------------------------------------------------------- " Quicker window movement nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-h> <C-w>h nnoremap <C-l> <C-w>l " Execute last macro nnoremap mm @@ " Always paste with indent nnoremap p p=`] " Quicker window replacement nnoremap <C-w><Up> <C-w>K nnoremap <C-w><Down> <C-w>J nnoremap <C-w><Left> <C-w>H nnoremap <C-w><Right> <C-w>L " Center the cursor vertically when doing large scrolling nnoremap <C-d> <C-d>zz nnoremap <C-u> <C-u>zz nnoremap <C-f> <C-f>zz nnoremap <C-b> <C-b>zz " move buffer to new tab nnoremap <C-w>t <C-W>T " move vertically by visual line nnoremap j gj nnoremap k gk " move to beginning/end of line nnoremap B ^ nnoremap E $ " $/^ doesn't do anything nnoremap $ <nop> nnoremap ^ <nop> " Ctrl + s writes the file nnoremap <C-s> :w<cr> nnoremap <C-q> :q<cr> " Highlight last inserted text nnoremap gV `[v`] " ; is aliased to : nnoremap ; : " Open NERDTree in the directory of the current file (or /home if no file is open) nnoremap <C-n> :call NERDTreeToggleInCurDir()<cr> " Yank all in buffer nnoremap yab ggyG " Delete all in buffer nnoremap dab ggdG nnoremap <leader>j 0v3e"jdi[]<Esc>"jPA()<Esc>ihttps://technekes.atlassian.net/browse/<Esc>"jp " 0v3e"jdi[]"jPA()ihttps://technekes.atlassian.new/browse/"jp " " let jiramapping='0v3e"jdi[]"jPA()ihttps://technekes.atlassian.new/browse/"jp' " vnoremap <leader>j :normal jiramapping " Git grep current word nnoremap <silent> <leader>gp yiw:Ggrep <c-r>"<cr> " Git grep current selection vnoremap <silent> <leader>gp y:Ggrep <c-r>"<cr> " Don't use arrow keys in insert mode (don't do it in normal mode either!) inoremap <Left> <C-o>:echoe 'Think Vim'<CR> inoremap <Right> <C-o>:echoe 'Think Vim'<CR> inoremap <Up> <C-o>:echoe 'Think Vim'<CR> inoremap <Down> <C-o>:echoe 'Think Vim'<CR> " jk is aliased to ESC inoremap jk <esc> " Create a newline while in insert mode inoremap <C-o> <C-O>o " Go to end of word in insert mode inoremap <C-e> <esc>ea inoremap <Leader><cr> <C-O>o " Keep highlighted text selected after indenting vnoremap > ><CR>gv vnoremap < <<CR>gv " ----------------------------------------------------------------------------- " Leader key mappings " ----------------------------------------------------------------------------- let mapleader = "\<Space>" nnoremap <Leader>w :w<cr> nnoremap <Leader>q :q<cr> nnoremap <Leader>Q :q!<cr> nnoremap <Leader>wq :wq<cr> " Leader Leader creates visual linewise nnoremap <Leader><Leader> V nnoremap <leader>ev :tabedit $MYVIMRC<cr> nnoremap <leader>sv :source $MYVIMRC<cr> nnoremap <Leader>t :tabnew<cr> " Remove over 80 characters highlight nnoremap <leader><esc> :call clearmatches()<cr> " Edit Ruby Snippets nnoremap <leader>ers :tabedit ~/.vim/UltiSnips/ruby.snippets<cr> " View current file in browser and render markdown nnoremap <leader>md :! cat % \| pandoc -f markdown_github \| sensible-browser<cr> " Quicker window resizing nnoremap <silent> <leader>= :exe "resize " . (winheight(0) * 3/2)<CR> nnoremap <silent> <leader>- :exe "resize " . (winheight(0) * 2/3)<CR> nnoremap <silent> <leader>0 :exe "vertical resize " . (winwidth(0) * 3/2)<CR> nnoremap <silent> <leader>9 :exe "vertical resize " . (winwidth(0) * 2/3)<CR> " Search via tag in project by comma f nnoremap <leader>f :CtrlPTag<cr> " List buffers nnoremap <leader>l :ls<cr> " Strip trailing whitespaces nnoremap <leader>c :call <SID>StripTrailingWhitespaces()<cr> " Change hashrocket style hashes to json style with surrounding space. nnoremap <leader>rh :%s/:\([^ ]*\)\(\s*\)=>/ \1: /g<CR>:%s/\(\S\)\(}\)/\1 \2/g<CR> " ----------------------------------------------------------------------------- " Functions " ----------------------------------------------------------------------------- function! NERDTreeToggleInCurDir() " If NERDTree is open in the current buffer if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1) exe ":NERDTreeClose" else exe ":NERDTreeFind" endif endfunction " This strips trailing whitespace at the end of files. It " is called on buffer write in the autogroup above. function! <SID>StripTrailingWhitespaces() " save last search & cursor position let _s=@/ let l = line(".") let c = col(".") %s/\s\+$//e let @/=_s call cursor(l, c) endfunction " ----------------------------------------------------------------------------- " Auto commands " ----------------------------------------------------------------------------- " (Language specific settings) augroup configgroup " Clear any lingering autcmd options autocmd! " Strip trailing whitespace on write " autocmd BufWritePre * :call <SID>StripTrailingWhitespaces() autocmd BufEnter *.zsh-theme setlocal filetype=zsh autocmd BufEnter Guardfile,.pryrc setlocal filetype=ruby autocmd BufEnter *Dockerfile* setlocal filetype=dockerfile autocmd BufEnter,FocusGained * checktime " Make ?s and :s part of words autocmd FileType ruby,eruby,yaml setlocal iskeyword+=?,: " autocmd FileType go setlocal softtabstop=2 tabstop=10 " Use absolute line numbers or relative depending on mode autocmd InsertEnter * :set number norelativenumber nohlsearch autocmd InsertLeave * :set nonumber relativenumber " autocmd BufEnter * retab " automatically fix typos for markdown files autocmd filetype markdown \ :call AutoCorrect() | \ :setlocal spell " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif autocmd VimEnter,BufEnter,WinEnter * call matchadd('ColorColumn', '\%81v', 100) augroup END " ----------------------------------------------------------------------------- " Configurations " ----------------------------------------------------------------------------- set shell=bash let g:go_bin_path = "/home/m/go/bin" let g:go_fmt_command = "goimports" " Recursively add everything to path to use helpful file commands set path+=client/**,lib/**,app/** " Backup Settings " Save your backup files to a less annoying place than the current directory. " If you have .vim-backup in the current directory, it'll use that. " Otherwise it saves it to ~/.vim/backup or . if isdirectory($HOME . '/.vim/backup') == 0 :silent !mkdir -p ~/.vim/backup >/dev/null 2>&1 endif set backupdir-=. set backupdir+=. set backupdir-=~/ set backupdir^=~/.vim/backup/ set backupdir^=./.vim-backup/ set backup " Save your swap files to a less annoying place than the current directory. " If you have .vim-swap in the current directory, it'll use that. " Otherwise it saves it to ~/.vim/swap, ~/tmp or . if isdirectory($HOME . '/.vim/swap') == 0 :silent !mkdir -p ~/.vim/swap >/dev/null 2>&1 endif set directory=./.vim-swap// set directory+=~/.vim/swap// set directory+=~/tmp// set directory+=. " viminfo stores the the state of your previous editing session set viminfo+=n~/.vim/viminfo if exists("+undofile") " undofile - This allows you to use undos after exiting and restarting " This, like swap and backup files, uses .vim-undo first, then ~/.vim/undo " :help undo-persistence " This is only present in 7.3+ if isdirectory($HOME . '/.vim/undo') == 0 :silent !mkdir -p ~/.vim/undo > /dev/null 2>&1 endif set undodir=./.vim-undo// set undodir+=~/.vim/undo// set undofile endif " Find tags in locations, priority is from left to right set tags=.git/tags,tags set suffixesadd+=.js,.jsx " Auto reload file if changed outside of vim set autoread " Allow multiple buffers to open without saving set hidden " Enable matchit to extend % for html tags runtime macros/matchit.vim autocmd BufWritePost *.js AsyncRun -post=checktime ./node_modules/.bin/eslint --fix % let g:ale_linters = { \ 'javascript': ['eslint'], \ 'python': ['pylint'], \} " Only run linters named in ale_linters settings. let g:ale_linters_explicit = 1 au BufWrite *.py :Autoformat