Skip to content

Instantly share code, notes, and snippets.

@mrshll
Created February 8, 2016 14:34
Show Gist options
  • Save mrshll/dfa5d293f3817d9beb41 to your computer and use it in GitHub Desktop.
Save mrshll/dfa5d293f3817d9beb41 to your computer and use it in GitHub Desktop.
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
" Autoreload vimrc
autocmd! bufwritepost .vimrc source %
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
let mapleader = ","
noremap ; :
call plug#begin('~/.vim/plugged')
Plug 'ervandew/supertab'
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' | Plug 'justinj/vim-react-snippets'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'}
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'benekastah/neomake'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'morhetz/gruvbox'
Plug 'ap/vim-css-color'
Plug 'tpope/vim-commentary'
Plug 'glidenote/memolist.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Valloric/YouCompleteMe'
Plug 'kchmck/vim-coffee-script'
Plug 'wavded/vim-stylus'
" Add plugins to &runtimepath
call plug#end()
colorscheme gruvbox
set background=dark
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
noremap <tab> :NERDTreeToggle<CR>
noremap <Leader>a :Ag <cword><cr>
" Run neomake on every save
autocmd! BufWritePost * Neomake
let g:neomake_open_list = 2
function! s:fzf_statusline()
" Override statusline as you like
highlight fzf1 ctermfg=161 ctermbg=251
highlight fzf2 ctermfg=23 ctermbg=251
highlight fzf3 ctermfg=237 ctermbg=251
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endfunction
autocmd! User FzfStatusLine call <SID>fzf_statusline()
nmap <leader>t :FZF<enter>
nnoremap <Leader>mn :MemoNew<CR>
nnoremap <Leader>ml :MemoList<CR>
nnoremap <Leader>mg :MemoGrep<CR>
set expandtab
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set backupdir=~/.bak
set directory=~/.tmp
set undofile
set undodir='~/.tmp/undodir'
set undolevels=1000
set undoreload=10000
set hidden
function! ClipboardYank()
call system('pbcopy', @@)
endfunction
function! ClipboardPaste()
let @@ = system('pbpaste')
endfunction
noremap <Leader>[ :set nopaste<cr>
noremap <Leader>] :set paste<cr>
noremap <Leader>vi :tabe ~/.vimrc<CR>
noremap <Leader>r :%s/\<<C-r><C-w>\>//g<Left><Left>
function! Browser()
let line = getline (".")
let line = matchstr (line,"http[^ ]*")
exec "!chrome ".line
endfunction
map <Leader>w :call Browser ()<CR>
function! DelEmptyLineAbove()
if line(".") == 1
return
endif
let l:line = getline(line(".") - 1)
if l:line =~ '^\s*$'
let l:colsave = col(".")
.-1d
silent normal! <C-y>
call cursor(line("."), l:colsave)
endif
endfunction
function! AddEmptyLineAbove()
let l:scrolloffsave = &scrolloff
" Avoid jerky scrolling with ^E at top of window
set scrolloff=0
call append(line(".") - 1, "")
if winline() != winheight(0)
silent normal! <C-e>
endif
let &scrolloff = l:scrolloffsave
endfunction
function! DelEmptyLineBelow()
if line(".") == line("$")
return
endif
let l:line = getline(line(".") + 1)
if l:line =~ '^\s*$'
let l:colsave = col(".")
.+1d
''
call cursor(line("."), l:colsave)
endif
endfunction
function! AddEmptyLineBelow()
call append(line("."), "")
endfunction
function! SetArrowKeysAsTextShifters()
" normal mode
nmap <silent> <Left> <<
nmap <silent> <Right> >>
nnoremap <silent> <Up> <Esc>:call DelEmptyLineAbove()<CR>
nnoremap <silent> <Down> <Esc>:call AddEmptyLineAbove()<CR>
nnoremap <silent> <C-Up> <Esc>:call DelEmptyLineBelow()<CR>
nnoremap <silent> <C-Down> <Esc>:call AddEmptyLineBelow()<CR>
nnoremap <silent> <C-S-Right> <Esc>:RightAlign<CR>
" visual mode
vmap <silent> <Left> <
vmap <silent> <Right> >
vnoremap <silent> <Up> <Esc>:call DelEmptyLineAbove()<CR>gv
vnoremap <silent> <Down> <Esc>:call AddEmptyLineAbove()<CR>gv
vnoremap <silent> <C-Up> <Esc>:call DelEmptyLineBelow()<CR>gv
vnoremap <silent> <C-Down> <Esc>:call AddEmptyLineBelow()<CR>gv
vnoremap <silent> <C-S-Right> <Esc>:RightAlign<CR>gv
" insert mode
imap <silent> <Left> <C-D>
imap <silent> <Right> <C-T>
inoremap <silent> <Up> <Esc>:call DelEmptyLineAbove()<CR>a
inoremap <silent> <Down> <Esc>:call AddEmptyLineAbove()<CR>a
inoremap <silent> <C-Up> <Esc>:call DelEmptyLineBelow()<CR>a
inoremap <silent> <C-Down> <Esc>:call AddEmptyLineBelow()<CR>a
inoremap <silent> <C-S-Right> <Esc>:RightAlign<CR>a
" disable modified versions we are not using
nnoremap <S-Up> <NOP>
nnoremap <S-Down> <NOP>
nnoremap <S-Left> <NOP>
nnoremap <S-Right> <NOP>
vnoremap <S-Up> <NOP>
vnoremap <S-Down> <NOP>
vnoremap <S-Left> <NOP>
vnoremap <S-Right> <NOP>
inoremap <S-Up> <NOP>
inoremap <S-Down> <NOP>
inoremap <S-Left> <NOP>
inoremap <S-Right> <NOP>
endfunction
call SetArrowKeysAsTextShifters()
noremap <C-J> <C-W>j
noremap <C-K> <C-W>k
noremap <C-H> <C-W>h
noremap <C-L> <C-W>l
" Always show line numbers and current position. ALWAYS!
set ruler
set number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment