Skip to content

Instantly share code, notes, and snippets.

@hirochachacha
Created February 1, 2018 01:42
Show Gist options
  • Save hirochachacha/1769ea9e38ead3df08bb8df09ccde3ae to your computer and use it in GitHub Desktop.
Save hirochachacha/1769ea9e38ead3df08bb8df09ccde3ae to your computer and use it in GitHub Desktop.
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" On-demand loading
Plug 'Townk/vim-autoclose'
Plug 'fatih/vim-go'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'mileszs/ack.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'dart-lang/dart-vim-plugin'
Plug 'rust-lang/rust.vim'
Plug 'racer-rust/vim-racer'
Plug 'mattn/emmet-vim'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'w0rp/ale'
Plug 'ternjs/tern_for_vim'
Plug 'bumaociyuan/vim-swift'
" Add plugins to &runtimepath
call plug#end()
colorscheme solarized
"Edit
set autoindent
set expandtab
" set shiftwidth=4
" set tabstop=8
" set tabstop=4
set iminsert=0
set imsearch=0
set tabpagemax=30
set number
set incsearch
set hlsearch
set autowrite
set noswapfile
if (exists('+colorcolumn'))
set colorcolumn=80
highlight ColorColumn ctermbg=10
endif
"emacs like key bindings
noremap! <silent> <C-f> <Right>
noremap! <silent> <C-b> <Left>
noremap! <silent> <C-a> <HOME>
noremap! <silent> <C-e> <END>
"vimperator like key bindings
nnoremap <silent> <Space>d :q!<CR>
nnoremap <silent> <Space>e :Lex<CR>
nnoremap <silent> <Space>o :Explore<CR>
nnoremap <silent> <Space>t :tabnew .<CR>
nnoremap <silent> <Space>r :edit!<CR>
nnoremap <silent> <Space>l gt
nnoremap <silent> <Space>h gT
nnoremap <silent> <Space>y "*y
nnoremap <silent> <Space>p "*p
vnoremap <silent> <Space>y "*y
vnoremap <silent> <Space>p "*p
nnoremap <silent> <C-l> :tabmove+1<CR>
nnoremap <silent> <C-h> :tabmove-1<CR>
"quickfix
nnoremap <silent> <C-j> :Cnext<CR>
nnoremap <silent> <C-k> :Cprev<CR>
nnoremap <silent> <C-c> :cclose<CR>
command! Cnext try | cnext | catch | cfirst | catch | endtry
command! Cprev try | cprev | catch | clast | catch | endtry
command! Lnext try | lnext | catch | lfirst | catch | endtry
command! Lprev try | lprev | catch | llast | catch | endtry
" command! CLnext try | :Cnext | catch | :Lnext | endtry
" command! CLprev try | :Cprev | catch | :Lprev | endtry
" command! CLclose try | cclose | catch | lclose | endtry
"split and focus window
nnoremap <silent> <C-w>v <C-w>v<C-w>l
nnoremap <silent> <C-w>s <C-w>s<C-w>j
"cleanup high light
nnoremap <silent> <ESC><ESC> :nohlsearch<CR><ESC>
"nerdcommenter
let g:NERDCreateDefaultMappings = 0
let NERDSpaceDelims = 1
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle
"delete needless spaces before writing
autocmd BufEnter * silent! lcd %:p:h
au FileType dart nmap <silent> ,r :!dart %<CR>
"tern_for_vim
au FileType javascript nmap <C-i> :TernDef<CR>
au FileType javascript nmap ,e :TernRename<CR>
au FileType javascript nmap ,< :TernRefs<CR>
"vim-go
au FileType go nmap <C-i> <Plug>(go-def)
au FileType go nmap <silent> ,r :GoRun %<CR>
au FileType go nmap ,b <Plug>(go-build)
au FileType go nmap ,t <Plug>(go-test)
au FileType go nmap ,c <Plug>(go-coverage-toggle)
au FileType go nmap ,e <Plug>(go-rename)
au FileType go nmap ,< <Plug>(go-referrers)
au FileType go nmap <silent> ,p :GoPlay<CR>
au FileType go vmap <silent> ,p :GoPlay<CR>
setlocal cindent
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal textwidth=79
setlocal fo-=ro fo+=cql
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
let g:go_list_type = "quickfix"
let g:go_def_reuse_buffer = 1
let g:go_asmfmt_autosave = 0
"rust.vim
au FileType rust nmap <C-i> <Plug>(rust-def)
au FileType rust nmap <silent> ,r :RustRun %<CR>
au FileType rust nmap <silent> ,p :RustPlay<CR>
au FileType rust vmap <silent> ,p :RustPlay<CR>
let g:rustfmt_command = 'rustup run nightly rustfmt'
let g:rustfmt_autosave = 1
"vim-airline
let g:airline#extensions#tabline#enabled = 1
"ack.vim
let g:ackprg = 'ag --vimgrep --smart-case'
nnoremap <silent> ,g :exec "Ack ".expand("<cword>")[2:-3]<CR>
" set encoding=utf-8
" set fileencodings=iso-2022-jp,euc-jp,sjis,utf-8
let g:user_emmet_leader_key='<C-e>'
let g:jsx_ext_required = 0
let g:ale_fixers = {
\ 'javascript': [
\ 'prettier',
\ 'remove_trailing_lines',
\ 'trim_whitespace',
\ ],
\}
let g:ale_lint_on_text_changed = 'never'
let g:ale_fix_on_save = 1
let g:ale_lint_on_enter = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_pattern_options = {'.go$': {'ale_enabled': 0}}
" let g:ale_open_list = 1
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.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="arrow"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment to change how often before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want to disable command autocorrection
# DISABLE_CORRECTION="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# Uncomment following line if you want to disable marking untracked files under
# VCS as dirty. This makes repository status check for large repositories much,
# much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=()
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
source ~/.profile
typeset -A myabbrev
myabbrev=(
"ll" "| less"
"lt" "| tail"
"lg" "| grep"
)
my-expand-abbrev() {
local left prefix
left=$(echo -nE "$LBUFFER" | sed -e "s/[_a-zA-Z0-9]*$//")
prefix=$(echo -nE "$LBUFFER" | sed -e "s/.*[^_a-zA-Z0-9]\([_a-zA-Z0-9]*\)$/\1/")
LBUFFER=$left${myabbrev[$prefix]:-$prefix}" "
}
bindkey \^U backward-kill-line
zle -N my-expand-abbrev
bindkey " " my-expand-abbrev
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# eval `dircolors ~/.dircolors/dircolors.256dark`
# . /usr/share/autojump/autojump.zsh
. /usr/local/share/autojump/autojump.zsh
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
if which pyenv > /dev/null; then eval "$(pyenv init -)"; eval "$(pyenv virtualenv-init -)"; fi
# source ~/.nvm/nvm.sh
alias ls="ls -G"
# alias vi="nvim"
alias vi="vim"
alias ag="ag --color"
alias goprof="rlwrap go tool pprof"
eval "$(hub alias -s)"
google(){ w3m "www.google.com/search?q=$*"; }
yubnub(){ w3m "yubnub.org/parser/parse?command=$*"; }
alc(){ w3m eow.alc.co.jp/"$*"/UTF-8/; }
wiki(){ w3m ja.wikipedia.org/wiki/"$*"; }
pudb(){ python -m pudb.run $*; }
gemcd(){
cd $(ruby -e "
name = \"$1\"
begin
print Gem::Specification.find_by_name(name).full_gem_path
rescue Gem::LoadError
\$LOAD_PATH.each do |load_path|
if File.exist?(\"#{load_path}/#{name}\")
print \"#{load_path}/#{name}\"
exit
elsif File.exist?(\"#{load_path}/#{name}.rb\")
print \"#{load_path}/#{name}.rb\".split('/')[0...-1].join('/')
exit
end
end
print Dir.getwd
end
");
}
pycd(){
cd $(python -c "
import os
try:
import $1
except ImportError:
print(os.getcwd())
exit()
else:
print(os.path.dirname($1.__file__))
");
}
# gocd(){ cd $(find $(go env GOPATH)/src $(go env GOROOT)/src -type d -name .hg -prune -o -type d -name .git -prune -o -type d -name .bzr -prune -o -type d -name "$1" -print | percol --auto-match --auto-fail || echo $PWD); }
gocd(){ cd $(find $(go env GOPATH)/src $(go env GOROOT)/src -type d -name .hg -prune -o -type d -name .git -prune -o -type d -name .bzr -prune -o -type d -name "$1" -print | peco || echo $PWD); }
# gofind(){ find $(go env GOPATH)/src $(go env GOROOT)/src/pkg -type d -name .hg -prune -o -type d -name .git -prune -o -type d -name .bzr -prune -o -type d -name "*$1*" -print; }
# gocd() { cd $(gofind $1 | percol --auto-match --auto-fail || echo $PWD); }
umask 022
ulimit -c 0
# The next line updates PATH for the Google Cloud SDK.
# source '/home/hiro/google-cloud-sdk/path.zsh.inc'
# The next line enables bash completion for gcloud.
# source '/home/hiro/google-cloud-sdk/completion.zsh.inc'
# source ~/.xsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment