Skip to content

Instantly share code, notes, and snippets.

@he9lin
Last active July 15, 2016 01:23
Show Gist options
  • Save he9lin/86dc29b3a29981fb10b1ddd4b3d7a3ba to your computer and use it in GitHub Desktop.
Save he9lin/86dc29b3a29981fb10b1ddd4b3d7a3ba to your computer and use it in GitHub Desktop.
filetype on
filetype indent on
filetype plugin on
syntax on
call plug#begin('~/.vim/plugged')
Plug 'mileszs/ack.vim'
" Plug 'rking/ag.vim'
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'Shougo/neocomplete'
Plug 'Shougo/neosnippet'
Plug 'Shougo/neosnippet-snippets'
" Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-rails'
Plug 'elixir-lang/vim-elixir'
Plug 'thinca/vim-ref'
Plug 'awetzel/elixir.nvim', { 'do': 'yes \| ./install.sh' }
Plug 'tomtom/tcomment_vim'
Plug 'vim-ruby/vim-ruby'
Plug 'thoughtbot/vim-rspec'
Plug 'elzr/vim-json'
Plug 'benmills/vimux'
Plug 'neovimhaskell/nvim-hs'
call plug#end()
set cursorline
set cursorcolumn
set linespace=3
set number
set laststatus=2
set tabstop=2
set shiftwidth=2
set expandtab
set guioptions-=T
set guioptions-=L
set guioptions-=r
set directory=/tmp
set guifont=Monaco\ for\ Powerline:h15
set colorcolumn=80
colorscheme Apprentice
highlight ColorColumn ctermbg=235
" colorscheme PaperColor
" set background=light
" let g:airline_theme='light'
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:Powerline_symbols = 'fancy'
if exists("g:ctrlp_user_command")
unlet g:ctrlp_user_command
endif
if executable('ag')
let g:ackprg = 'ag --vimgrep'
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command =
\ 'ag %s --files-with-matches -g "" --ignore "\.git$\|\.hg$\|\.svn$"'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
else
" Fall back to using git ls-files if Ag is not available
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others']
endif
let g:ctrlp_by_filename = 1
let g:ctrlp_switch_buffer = 0
" Make nerdtree look nice
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:NERDTreeWinSize = 30
" bind K to grep word under cursor
nnoremap K :Ack<CR>
nnoremap \ :Ack<SPACE>
au BufWritePre * :%s/\s\+$//e " Clean up white spaces
au VimResized * :wincmd =
au BufEnter * set relativenumber
au InsertEnter * :set number
au InsertLeave * :set relativenumber
" Ruby
au FileType ruby call FileType_Ruby()
function! FileType_Ruby()
if exists("b:did_ftruby") | return | endif
let b:did_ftruby = 1
map <Leader>i :call VimuxRunCommand("bin/rspec " . bufname("%") . ":" . line("."))<CR>
map <Leader>m :call VimuxRunCommand("bin/rspec " . bufname("%"))<CR>
map <Leader>n :call VimuxRunCommand("bin/rspec spec/")<CR>
endfunction
" Haskell
au FileType haskell call FileType_Haskell()
function! FileType_Haskell()
if exists("b:did_fthaskell") | return | endif
let b:did_fthaskell = 1
map <Leader>n :call VimuxRunCommand("cabal test")<CR>
endfunction
au FileType elixir call FileType_Elixir()
function! FileType_Elixir()
if exists("b:did_ftelixir") | return | endif
let b:did_ftelixir = 1
map <Leader>i :call VimuxRunCommand("mix test " . bufname("%") . ":" . line("."))<CR>
map <Leader>m :call VimuxRunCommand("mix test " . bufname("%"))<CR>
map <Leader>n :call VimuxRunCommand("mix test")<CR>
endfunction
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
command! NumberToggle call NumberToggle()
function! PasteToggle()
if(&paste == 1)
set nopaste
echo "nopaste mode"
else
set paste
echo "paste mode"
endif
endfunc
command! PasteToggle call PasteToggle()
function! ClipboardYank()
call system('pbcopy', @@)
endfunction
function! ClipboardPaste()
let @@ = system('pbpaste')
endfunction
vnoremap <silent> y y:call ClipboardYank()<cr>
vnoremap <silent> d d:call ClipboardYank()<cr>
let mapleader = "\<Space>"
map <Leader>r :call VimuxRunLastCommand()<CR>
let g:ctrlp_map = '\<Space>o'
nnoremap <Leader>o :CtrlP<CR>
nnoremap <Leader>b :CtrlPBuffer<CR>
nnoremap <Leader>s :update<CR>
nnoremap <C-n> :NumberToggle<CR>
nnoremap <c-w>\| <c-w>t<c-w>H
nnoremap <C-t> :tabnew<CR>
nnoremap <silent> <C-l> :nohl<CR>
nnoremap <Leader>s :update<CR>
nnoremap <Leader>d :bp\|bd #<CR>
nnoremap <Leader>l <C-W><C-L>
nnoremap <Leader>h <C-W><C-H>
nnoremap <Leader>j <C-W><C-J>
nnoremap <Leader>k <C-W><C-K>
nnoremap <Leader>p :PasteToggle<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment