Skip to content

Instantly share code, notes, and snippets.

@dropofwill
Last active July 19, 2017 15:24
Show Gist options
  • Save dropofwill/b64e4620b0d9877c3100 to your computer and use it in GitHub Desktop.
Save dropofwill/b64e4620b0d9877c3100 to your computer and use it in GitHub Desktop.
bash stuff
" Use Vim settings, not compatible with legacy Vi
set nocompatible
call plug#begin('~/.local/share/nvim/plugged')
" Commenting plugins
Plug 'tomtom/tcomment_vim'
" Pair quotes, tags, etc.
Plug 'jiangmiao/auto-pairs'
" Vim repl for neovim
Plug 'hkupty/iron.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'mhinz/vim-startify'
Plug 'szw/vim-tags'
Plug 'jamessan/vim-gnupg'
" Syntax plugins
Plug 'slim-template/vim-slim', { 'for': 'slim' }
Plug 'raichoo/purescript-vim', { 'for': 'slim' }
Plug 'cakebaker/scss-syntax.vim', { 'for': 'slim' }
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
Plug 'noprompt/vim-yardoc', { 'for': 'ruby' }
Plug 'glts/vim-texlog', { 'for': 'latex' }
Plug 'digitaltoad/vim-jade', { 'for': 'jade' }
Plug 'othree/yajs.vim', { 'for': 'js' }
Plug 'kchmck/vim-coffee-script', { 'for': 'coffeescript' }
Plug 'mustache/vim-mustache-handlebars', { 'for': 'mustache' }
Plug 'elixir-lang/vim-elixir', { 'for': 'elixir' }
Plug 'derekwyatt/vim-scala', { 'for': 'scala' }
Plug 'artur-shaik/vim-javacomplete2', { 'for': 'java' }
" Visual plugins
Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Functionality plugins
Plug 'mxw/vim-jsx', { 'for': ['jsx', 'js'] }
Plug 'pangloss/vim-javascript', { 'for': 'js' }
Plug 'majutsushi/tagbar'
" Plug 'ervandew/supertab'
Plug 'jeetsukumaran/vim-filebeagle'
Plug 'editorconfig/editorconfig-vim'
Plug 'Konfekt/FastFold'
Plug 'janko-m/vim-test'
" Tim Pope's plugins
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-abolish'
call plug#end()
" Nice, compact default tab settings
set tabstop=2
set shiftwidth=2
set expandtab
set autoindent
" set nowrap
set breakindent
" Let me know when my lines are too damn long
set colorcolumn=80
" Backspace anything in insert mode
set backspace=indent,eol,start
autocmd FileType java setlocal omnifunc=javacomplete#Complete
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git'
set laststatus=2
set ttimeoutlen=0
" Interface settings
" set relativenumber " Line numbers relative to cursor
" set number " But ignore the current line
" set numberwidth=3 " How wide the line number column should be by default
set showcmd " Show incomplete commands
set noerrorbells " No dinging!
set scrolloff=4 " Pad lines vertically by 4
set hidden " Hide buffers instead of yelling at me about it
set ruler " Tells you the coords of the cursor in the status line
set wildmenu " Tab complete vim commands
set wildmode=longest,list,full
" Better tab completion, esp. nice for buffer navigation
set wildchar=<Tab>
set laststatus=2 " Always show status line
let g:loaded_matchparen=1
"
" http://bit.ly/1GGgRd2
set completeopt=longest,menuone
" In many terminal emulators the mouse works just fine, so I enable it.
if has('mouse')
set mouse=a
endif
" Code fold settings
set foldmethod=indent " Create folds based on syntax highlighting
set foldlevelstart=20 " Arbitrary high number of folds open on load
" Search/Regex settings
nnoremap <leader><space> :noh<cr>
set gdefault " Regex global by default
set incsearch " Show matches as you type
set showmatch " Visually flash matching brackets when typing
set hlsearch " Highlight all search matches not just the current one
set spell " Spell checker for Vim!
set linebreak " Break lines by word when using wrap
" :Wrap command to force wrap mode
command! -nargs=* Wrap set wrap linebreak nolist
" vim-test config
let test#strategy = "basic"
let test#java#maven#executable = "mvnc"
" File management
" set history=100
set undolevels=1000
" I don't like dealing with backups in the same directory
" set backupdir=~/.vim/tmp
set nobackup
set directory=~/.vim/tmp
set undodir=~/.vim/tmp
set noswapfile
" Copy/Paste settings
set copyindent
set pastetoggle=<f2>
" Misc. Settings
set ttyfast
set modelines=0
" Hide all the GUI
set guioptions=aem
" Make Y work as intended, despite not being y compatible
" Remap capital Y to yank (copy) to the end of a line
map Y y$
" Don't overwrite the paste register when pasting over something
" This lets you paste repeatedly, etc.
xnoremap p pgvy
xnoremap P Pgvy
" I don't use arrow keys so I remapped them to other things
" Open last Vim command
nnoremap <Right> :<Up>
" Open last search result
nnoremap <Left> /\v<Up>
" Bubble single lines, move a line up or down
nnoremap <Up> ddkP
nnoremap <Down> ddp
" Bubble multiple lines, do it with visual selections
vnoremap <Up> xkP`[V`]
vnoremap <Down> xp`[V`]
" TagBar Toggle support
nmap <Leader>t :TagbarToggle<CR>
call denite#custom#map(
\ 'insert',
\ '<C-j>',
\ '<denite:move_to_next_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<C-k>',
\ '<denite:move_to_previous_line>',
\ 'noremap'
\)
call denite#custom#alias('source', 'file_rec/git', 'file_rec')
call denite#custom#var('file_rec/git', 'command',
\ ['git', 'ls-files', '-co', '--exclude-standard'])
nnoremap <silent> <C-p> :<C-u>Denite
\ `finddir('.git', ';') != '' ? 'file_rec/git' : 'file_rec'`<CR>
nnoremap <silent> <C-b> :Denite buffer<CR>
set omnifunc=syntaxcomplete#Complete
let g:deoplete#enable_at_startup = 1
let g:deoplete#auto_completion_start_length = 2
let g:deoplete#omni_patterns = {}
let g:deoplete#omni_patterns.java = '[^. *\t]\.\w*'
let g:deoplete#sources = {}
let g:deoplete#sources._ = []
let g:deoplete#file#enable_buffer_path = 1
let g:netrw_banner = 0
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
" Jump around brackets with tab as well
nnoremap <tab> %
vnoremap <tab> %
" Move screen lines not actual ones
nnoremap j gj
nnoremap k gk
" Set my leader to space except for x,i modes
map <Space> <Leader>
noremap <Leader>x i
" ; for faster commands
"nnoremap ; :
" Jump to new split with <space>w
nnoremap <leader>w <C-w>v<C-w>l
nnoremap <leader>e <C-w>s<C-w>j
" nnoremap <leader>E :Emmet
if has('nvim')
" Move around window splits with ctrl movement keys
tnoremap <C-h> <C-\><C-n><C-w>h
tnoremap <C-j> <C-\><C-n><C-w>j
tnoremap <C-k> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
" When entering a NeoVim terminal window enter insert mode
autocmd BufWinEnter,WinEnter term://* startinsert
" When leaving a NeoVim terminal window enter normal mode
autocmd BufLeave term://* stopinsert
endif
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Leader , or . (think < >) for previous/next buffer
map <leader>, :bp<CR>
map <leader>. :bn<CR>
map <leader>< :BufSurfBack<CR>
map <leader>> :BufSurfForward<CR>
" Exit insert mode with 'kj'
inoremap kj <Esc>
" Close a buffer without closing the window split
map <leader>v :bp<bar>sp<bar>bn<bar>bd<CR>
"
" Trim all trailing whitespace in the current buffer/file
command! Trim :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" Ariline / Color config
set background=dark
" set t_Co=256
set t_Co=256
colorscheme base16-phd
let g:airline_theme='base16_chalk'
" Show where my cursor is with a horizontal line
set cursorline
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep=''
let g:airline_right_sep=''
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.maxlinenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.spell = 'Ꞩ'
let g:airline_symbols.notexists = '∄'
let g:airline_symbols.whitespace = 'Ξ'
let g:airline_left_sep = ''
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:airline_powerline_fonts = 1
" Show tabline for buffers when only one tab is being used
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#whitespace#trailing_format = 't[%s]'
let g:airline#extensions#whitespace#mixed_indent_format = 'm[%s]'
let g:airline#extensions#whitespace#symbol = '•'
let g:airline#extensions#whitespace#mixed_indent_algo = 1
# Path to your oh-my-zsh installation.
export ZSH=/Users/wpaul/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# This adds a lot of git aliases, to look at them all run: `alias | grep git` there are some nice commands in there.
plugins=(git)
# My prompt looks like this
# (working_directory) master [146] λ
PROMPT='$fg[blue]$(git_current_branch) %(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )%B($(pwd | tr "/" "\n" | tail -n 1))%b %{$fg[yellow]%}λ%{$reset_color%} '
# Alias / functions
alias gdca='git diff --cached'
alias v='vim'
# nvim aka neovim is a rewrite of vim which I generally use
alias n='nvim'
# git shortcut for looking at the diff of staged changes
alias gdca='git diff --cached'
# tree is a command to look at a recursive file structure
# Run: brew install tree
# These aliases filter out common files for different languages
alias tree-js='tree -I node_modules'
alias tree-java="tree -P '*.java' --prune"
alias tree-java-test="tree -P '*.java' --prune -I 'main'"
alias tree-java-code="tree -P '*.java' --prune -I 'test'"
alias tree-java-bean="tree -P '*.xml'"
# Open all git unstaged changes in your configured editor
# usage: gfix
function gfix() {
$EDITOR $(git diff --name-only --relative $(pwd) | uniq)
}
# ag is a command to search files in the current directory
# brew install the_silver_searcher
# Open all files that match an ag query
# usage: afix ContactsService
function afix() {
$EDITOR $(ag -l $1)
}
# Run a simple ruby server on port 3000 in the current dir
# or another port that you pass in
function serve {
port="${1:-3000}"
ruby -run -e httpd . -p $port
}
# Show dotfiles in Finder or not?
# hidefiles: hides hidden files in Finder
function hidefiles(){
defaults write com.apple.finder AppleShowAllFiles -bool NO
killall Finder
}
# showfiles: shows hidden files in Finder
function showfiles(){
defaults write com.apple.finder AppleShowAllFiles -bool YES
killall Finder
}
# Swap between vim and zsh with <C-z> seamlessly
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
export EDITOR='nvim'
# These make your shell behave somewhat like vim
bindkey -v
# This remaps `kj` to esc
bindkey -M viins 'kj' vi-cmd-mode
# This makes ctrl + R let you search history
bindkey "^R" history-incremental-search-backward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment