Skip to content

Instantly share code, notes, and snippets.

@bufordtaylor
Created October 21, 2019 20:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bufordtaylor/bac07030d7df66963acc0f2c2da3564f to your computer and use it in GitHub Desktop.
Save bufordtaylor/bac07030d7df66963acc0f2c2da3564f to your computer and use it in GitHub Desktop.
call plug#begin('~/.vim/plugged')
Plug 'christoomey/vim-tmux-navigator'
Plug 'christoomey/vim-tmux-runner'
Plug 'Shougo/neocomplcache'
Plug 'airblade/vim-gitgutter'
Plug 'chriskempson/base16-vim'
Plug 'easymotion/vim-easymotion'
Plug 'endel/vim-github-colorscheme'
Plug 'flazz/vim-colorschemes'
Plug 'junegunn/fzf'
Plug 'kchmck/vim-coffee-script'
Plug 'ngmy/vim-rubocop'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'quanganhdo/grb256'
Plug 'rking/ag.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/syntastic'
Plug 'slim-template/vim-slim'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'vim-scripts/Align'
Plug 'vim-scripts/rubycomplete.vim'
Plug 'w0rp/ale'
Plug 'reedes/vim-wordy'
Plug 'reedes/vim-pencil'
call plug#end()
" tmux Meta key to navigate. iterm alt key as +Esc (for meta)
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <Esc>h :TmuxNavigateLeft<cr>
nnoremap <silent> <Esc>j :TmuxNavigateDown<cr>
nnoremap <silent> <Esc>k :TmuxNavigateUp<cr>
nnoremap <silent> <Esc>l :TmuxNavigateRight<cr>
nnoremap <silent> <M-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <M-j> :TmuxNavigateDown<cr>
nnoremap <silent> <M-k> :TmuxNavigateUp<cr>
nnoremap <silent> <M-l> :TmuxNavigateRight<cr>
" force non-graphical tabs
set guioptions=
" default backspace to normal
set backspace=indent,eol,start
" Color scheme
if has("gui_running")
set background=dark
colorscheme base16-default
else
colorscheme tomorrow-night
endif
set guifont=Menlo:h18
" mappings
let mapleader=','
let maplocalleader='\'
inoremap jj <Esc>
" run code from tmux pane
" Attach runner pane
map <Leader>va :VtrAttachToPane<CR>
" Open runner pane (needed for the other command below)
map <Leader>vo :VtrOpenRunner {'percentage': 50}<CR>
" Send lines to buffer
map <Leader>vs :VtrSendLinesToRunner<CR>
" Prompt for a command to run
map <Leader>vc :VtrSendCommandToRunner<Space>
" Clear runner
map <Leader>vcr :VtrClearRunner<CR>
" Run last command executed by VtrSendCommandToRunner
map <Leader>vl :VtrSendCommandToRunner<CR>
" Focus runner pane
map <Leader>vf :VtrFocusRunner<CR>
" Close runner pane
map <Leader>vq :VtrKillRunner<CR>
" Send Ctrl-D to Pane
map <Leader>vd :VtrSendCtrlD<CR>
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :source $MYVIMRC<CR>
noremap <C-p> :FZF<CR>
noremap <leader>, :w<CR>
noremap <leader><space> :noh<CR>
noremap <leader>q :q<CR>
noremap <leader>Q :q!<CR>
noremap <leader>W :call TrimWhitespace()<CR>
nnoremap <leader>f :Ag --ignore={Tags} --ignore-dir={log,tmp,vendor,temp,sql,public}
map <leader>t :NERDTreeToggle<CR>
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=0
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ }
let g:ale_fixers = {
\ 'javascript': ['eslint'],
\ 'ruby': ['rubocop'],
\ 'scss': ['stylelint'],
\ }
map <Leader>af :ALEFix<cr>
let g:ale_set_highlights = 0
map q: :q
" ; is an alias for :
nnoremap ; :
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
nmap j gj
nmap k gk
" Open new splits easily
map vv <C-W>v
map ss <C-W>s
nnoremap <leader>n :new<CR>
" tab settings
" ctrl-t makes a new tab
noremap <C-t> <Esc>:tabnew<CR>
inoremap <C-t> <Esc>:tabnew<CR>
nnoremap <C-t> <Esc>:tabnew<CR>
vnoremap <C-t> <Esc>:tabnew<CR>
" ctrl h and l moves left and right between tabs
noremap <C-l> <Esc>gt<CR>
inoremap <C-l> <Esc>gt<CR>
nnoremap <C-l> <Esc>gt<CR>
vnoremap <C-l> <Esc>gt<CR>
noremap <C-h> <Esc>gT<CR>
inoremap <C-h> <Esc>gT<CR>
nnoremap <C-h> <Esc>gT<CR>
vnoremap <C-h> <Esc>gT<CR>
" shift T turns a split window into it's own tab
noremap <S-T> <Esc><C-w>T
nnoremap <S-T> <Esc><C-w>T
"easymotion
" Gif config
nmap s <Plug>(easymotion-s2)
nmap t <Plug>(easymotion-t2)
" Gif config
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
" These `n` & `N` mappings are options. You do not have to map `n` & `N` to EasyMotion.
" Without these mappings, `n` & `N` works fine. (These mappings just provide
" different highlight method and have some other features )
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
map <Leader> <Plug>(easymotion-prefix)
set ttyfast
set clipboard=unnamed " yank from system clipboard
set t_Co=256 " Support for xterm with 256 colors (gets overriden in .gvimrc)
"set relativenumber " Show line numbers relative to each other
set number " Show the current lines number w/ relative numbers around it
set ruler " Show ruler
set listchars=trail:.,tab:>-,eol:¬ " Change the invisible characters
set noswapfile " Don't create annoying *.swp files
set scrolloff=5 " Start scrolling the file 5 lines before the end of the window
set spelllang=en_us " Set default spelling language to English
set hidden " Allow hiding buffers with unsaved changes
set wildmenu " Make tab completion act more like bash
set wildmode=list:longest " Tab complete to longest common string, like bash
set showcmd " Display an incomplete command in the lower right corner
set showmode " Show current mode down the bottom
set laststatus=2 " Always show the status line
set history=10000
set autoread
set noerrorbells visualbell t_vb= " No more error bells
set iskeyword+=\- " Auto complete words with dashes
autocmd FileType gitcommit set spell " Turn on spell check in Git commits.
" Set Mouse Mode
" set mouse=a
" set ttymouse=xterm2
" Treat dashed words as whole words in stylesheets
autocmd Filetype css,scss,sass setlocal iskeyword+=-
" Searching
set hlsearch " Highlight searches
set incsearch " Highlight search results instantly
set ignorecase " Ignore case
set smartcase " Override 'ignorecase' option if the search contains upper case characters.
" Indentation
set shiftwidth=2 " Number of spaces to use in each autoindent step
set tabstop=2 " Two tab spaces
set softtabstop=2 " Number of spaces to skip or insert when <BS>ing or <Tab>ing
set expandtab " Spaces instead of tabs for better cross-editor compatibility
set autoindent " Keep the indent when creating a new line
set smarttab " Use shiftwidth and softtabstop to insert or delete (on <BS>) blanks
set cindent " Recommended seting for automatic C-style indentation
" Color column at 110 characters
set colorcolumn=119
set wrap
set linebreak
set nolist
set showbreak=…
" Undo
if !isdirectory(expand("~/.vim/.undo/"))
silent !mkdir -p ~/.vim/.undo/
endif
set undodir=$HOME/.vim/.undo
set undofile
set undolevels=1000
set undoreload=10000
" Colorscheme
syntax enable
"highlight SignColumn ctermbg=8
"let &colorcolumn='80,120'
" Set wildcard ignore for ctrlp and ack/ag
set wildignore+=*/tmp/*,vendor/bundle/*,*/build/*,*/Resources/*,*.so,*.swp,*.zip,*.png,*.jpg,*.jpeg,*.gif,.gitkeep
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" vp doesn't replace paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
vmap <silent> <expr> p <sid>Repl()
" Whitespace
function! Preserve(cmd)
" Prep: save last search + cursor position
let _s=@/
let l = line(".")
let c = col(".")
" Execute command
execute a:cmd
" Clean up: restore last search + cursor position
let @/=_s
call cursor(l, c)
endfunction
function! TrimWhitespace()
call Preserve("%s/\\s\\+$//e")
endfunction
" highlight bad whitespace
autocmd BufReadPost * match BadWhitespace /\s\+$/
autocmd InsertEnter * match BadWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match BadWhitespace /\s\+$/
highlight BadWhitespace ctermbg=1
if executable("ag")
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --ignore ''.git'' --ignore ''.DS_Store'' --ignore ''node_modules'' --hidden -g ""'
endif
"au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
"au BufRead,BufNewFile *.md setlocal textwidth=80
autocmd FileType markdown highlight markdownListMarker ctermfg=NONE
autocmd FileType markdown highlight markdownItalic ctermbg=NONE ctermfg=143
autocmd FileType markdown highlight markdownBold ctermbg=NONE ctermfg=143
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType notes setlocal omnifunc=xolox#notes#user_complete
let g:pencil#textwidth = 74
augroup wrapMarkdown
autocmd!
autocmd FileType markdown,mkd,md setlocal wrap
autocmd FileType markdown,mkd,md setlocal spell
autocmd FileType markdown,mkd,md setlocal spelllang=en_us
autocmd FileType text setlocal wrap
augroup END
" Easy Tags
map <leader><C-]> :vsp <CR><C-w><C-w>:exec("tag ".expand("<cword>"))<CR>
set wildignore+=*/tmp/*,vendor/bundle/*,*/build/*,*/Resources/*,*.so,*.swp,*.zip,*.png,*.jpg,*.jpeg,*.gif,.gitkeep
set tags=./.tags;/
let g:easytags_auto_highlight = 0
let g:easytags_dynamic_files = 1
" Neocomplcache
let g:neocomplcache_enable_at_startup=1
let g:neocomplcache_enable_smart_case=1
let g:neocomplcache_force_overwrite_completefunc=1
"let g:airline_highlighting_cache=1
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<BS>"
inoremap <expr><Space> neocomplcache#smart_close_popup()."\<Space>"
autocmd filetype gitcommit nested NeoComplCacheLock
" get colorscheme of where your cursor is
function! GetSyntaxID()
return synID(line('.'), col('.'), 1)
endfunction
function! GetSyntaxParentID()
return synIDtrans(GetSyntaxID())
endfunction
function! GetSyntax()
echo synIDattr(GetSyntaxID(), 'name')
exec "hi ".synIDattr(GetSyntaxParentID(), 'name')
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment