Skip to content

Instantly share code, notes, and snippets.

@pearofducks
Created August 21, 2017 12:54
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 pearofducks/68f1c481bac301875e62bee16a216e1d to your computer and use it in GitHub Desktop.
Save pearofducks/68f1c481bac301875e62bee16a216e1d to your computer and use it in GitHub Desktop.
vimrc
set nocp
call plug#begin('~/.vim/plugged')
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-haml', { 'for': 'haml' }
Plug 'tpope/vim-commentary'
Plug 'pearofducks/vim-mkdn', { 'for': 'markdown' }
Plug 'pearofducks/vim-ragtag', { 'for': 'html' }
Plug 'pearofducks/vim-quack'
Plug 'JulesWang/css.vim', { 'for': ['sass', 'css'] }
Plug 'othree/html5.vim', { 'for': 'html' }
Plug 'pearofducks/ansible-vim', { 'for': ['ansible','ansible_template','ansible_hosts'] }
Plug 'scrooloose/syntastic'
Plug 'sjl/vitality.vim' " tmux integration
Plug 'easymotion/vim-easymotion'
Plug 'nathanaelkane/vim-indent-guides', { 'for': ['python','slim','haml', 'html', 'ngtpml'] }
Plug 'milkypostman/vim-togglelist'
Plug 'junegunn/vim-easy-align'
Plug 'gcmt/wildfire.vim' " helps with text object selection
Plug 'svermeulen/vim-easyclip'
Plug 'rhysd/vim-crystal', { 'for': 'crystal' }
Plug 'othree/yajs.vim', { 'for': 'javascript' }
Plug 'posva/vim-vue', { 'for': 'vue' }
call plug#end()
filetype plugin indent on
syntax on
let t_Co=256
if $BACKGROUND_COLOR == 'light'
set background=light
else
set background=dark
endif
set encoding=utf-8
let mapleader=","
try
colorscheme solarized
catch /^Vim\%((\a\+)\)\=:E185/
" deal with it
endtry
"----------------------------------------------------
" PLUGIN SETTINGS
"----------------------------------------------------
let g:ansible_name_highlight = 'd'
let g:ansible_unindent_after_newline = 1
let g:jedi#documentation_command = "<C-K>"
let g:jedi#show_call_signatures = "2"
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
map <TAB><SPACE> <Plug>(wildfire-fuel)
map <TAB><RETURN> <Plug>(wildfire-water)
"ToggleList - toggles quickfix/location
let g:toggle_list_no_mappings = 1
nmap <script> <silent> <leader>q :call ToggleLocationList()<CR>
nmap <script> <silent> <leader>l :call ToggleQuickfixList()<CR>
"Ragtag
let g:ragtag_global_maps = 0
"Easyclip
map <leader>p <c-p>
"EasyMotion
let g:EasyMotion_leader_key = '<space>'
let g:EasyMotion_keys = "csdflkjwoieurnghyawpx,.;vz"
nmap \\ <Plug>CommentaryLine
vmap \\ <Plug>Commentary
"Syntastic
let g:syntastic_check_on_open=1
let g:syntastic_loc_list_height=2
let g:syntastic_auto_loc_list=2
let g:syntastic_enable_signs=1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_quiet_messages = {'level': 'warnings'}
let g:syntastic_mode_map = {
\ "mode": "active",
\ "active_filetypes": ["ruby"],
\ "passive_filetypes": ["html", "sass"] }
"CTRL-P
let g:ctrlp_map = '<leader>ef'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': 'ag %s -i --nogroup --nocolor --ignore .git --ignore out -g ""'
\ }
let g:ctrlp_working_path_mode = 'rc'
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 1
let g:ctrlp_cache_dir= $HOME.'/.vim/ctrlp/'
let g:ctrlp_arg_map = 1
let g:ctrlp_max_height = 10
let g:ctrlp_switch_buffer = 2
let g:ctrlp_max_history = 0
let g:ctrlp_open_multiple_files = '7t'
let g:ctrlp_prompt_mappings = {
\ 'PrtClearCache()': ['R'],
\ 'PrtSelectMove("j")': ['J'],
\ 'PrtSelectMove("k")': ['K'],
\ 'AcceptSelection("h")': ['H'],
\ 'AcceptSelection("t")': ['T'],
\ 'AcceptSelection("v")': ['V'],
\ 'ToggleFocus()': ['<tab>'],
\ 'ToggleByFname()': ['<c-f>'],
\ 'CreateNewFile()': ['N'],
\ 'MarkToOpen()': ['M'],
\ 'OpenMulti()': ['O'],
\ 'PrtExit()': ['<esc>', '<c-c>', 'Q'],
\ }
"----------------------------------------------------
" BINDINGS
"----------------------------------------------------
nnoremap <silent><C-l> :tabn<CR>
nnoremap <silent><C-h> :tabp<CR>
nnoremap <silent> <leader>j :join<CR>
nnoremap <leader>ef :CtrlP<CR>
nnoremap <leader>er :CtrlPMRUFiles<CR>
nnoremap <leader>eo :CtrlPBuffer<CR>
nnoremap <leader><space> :noh<CR>
nnoremap <tab>k :diffput 1<CR>
vnoremap <tab>k :diffput 1<CR>
nnoremap ; :
vnoremap ; :
nnoremap U :redo<CR>
nnoremap H ^
nnoremap L $
nnoremap J <PageDown>
nnoremap K <PageUp>
vnoremap J <PageDown>
vnoremap K <PageUp>
vnoremap <C-j> J
imap kj <ESC>
nnoremap <C-j> :wincmd w<CR>
vnoremap . :normal .<CR>
nnoremap Y y$
nmap M m$
cnoremap w!! %!sudo tee > /dev/null %
nnoremap <leader>kdos :call DosMustDie()<CR>
nnoremap <leader>kfind :noautocmd vimgrep
nnoremap <leader>kws :call TrimWhiteSpace()<CR>
nnoremap <leader>ans :set ft=ansible<CR>
"----------------------------------------------------
" CONJUNCTION JUNCTION
"----------------------------------------------------
function TrimWhiteSpace()
%s/\s*$//
''
endfunction
function DosMustDie()
:update
:e ++ff=dos
:setlocal ff=unix
:w
endfunction
inoremap <silent><Left> <C-D>
inoremap <silent><Right> <C-T>
nnoremap <tab>l >>
nnoremap <tab>h <<
vnoremap <tab>l >gv
vnoremap <tab>h <gv
nnoremap Q @q
vnoremap Q :norm @q<cr>
"----------------------------------------------------
" SETUP STUFFS
"----------------------------------------------------
"----
"Bak
"----
set backup
set backupdir=~/.vim/swap
set directory=~/.vim/swap
"-----
"Undo
"-----
if has('persistent_undo')
set undofile
set undodir=~/.vim/swap
set undolevels=10000 "maximum number of changes that can be undone
if exists('+undoreload')
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
endif
endif
"-----
"Misc
"-----
if exists('+cryptmethod')
set cryptmethod=blowfish
endif
set clipboard=unnamed
set viminfo='25,\"100,:20,%,n~/.viminfo
set history=1000
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
set list
set listchars=tab:▸\ ,trail:⋅,extends:❯,precedes:❮
set showbreak=↪
set matchpairs+=<:>
set autoread
set nosmd "Don't show the mode we're in
set nojoinspaces
set notitle
"Don't see or hear vim complaining
set visualbell
set noerrorbells
"Speed up redraws
set ttyfast
set lazyredraw
set noek " turn off the delay from pressing escape
"set cmdheight=2
set laststatus=2
set shortmess=atToOI
set diffopt+=iwhite
set fillchars=vert:\ ,stl:\ ,stlnc:\
set nostartofline
set nowrap
set hidden
set wildmenu
set wildmode=list:longest,list:full
"Searches
set showmatch
set gdefault
set ignorecase
set smartcase
set hlsearch
set incsearch
set magic
set scrolloff=10
set sidescrolloff=15
set sidescroll=1
set showcmd
set ruler
" set pastetoggle=<tab>p
nnoremap <tab>p :set invpaste paste?<CR>
set autoindent
"set cursorline
"Tabs and Spacing
set softtabstop=2
set tabstop=2
set shiftwidth=2
set backspace=indent,eol,start
set et|retab
set modelines=0
set synmaxcol=1024 "Limit how many columns syntax highlight will bother with
syntax sync minlines=256
"----
"Autocommands
"----
autocmd FileType python setlocal completeopt-=preview
if has("autocmd")
augroup autocommands
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 1 && line ("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
au InsertEnter * :set listchars-=trail:⋅
au InsertLeave * :set listchars+=trail:⋅
augroup END
endif
" Set personal paren-highlighting preference
hi MatchParen cterm=underline ctermbg=none ctermfg=magenta
" Useful mapping for syntax highlighting development
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
" Comments -> italics
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
highlight Comment cterm=italic
highlight TabLineFill ctermfg=8 ctermbg=0
highlight TabLine ctermfg=8 ctermbg=0
highlight TabLineSel ctermfg=11 ctermbg=8 cterm=italic
" statusline stuff!
if $BACKGROUND_COLOR == 'light'
highlight Statusline ctermbg=15 ctermfg=0 cterm=none
highlight StatusLineNC ctermbg=0 ctermfg=0 cterm=none
highlight TabLineFill ctermfg=11 ctermbg=7
highlight TabLine ctermfg=11 ctermbg=7
highlight TabLineSel ctermfg=8 ctermbg=15 cterm=italic
else
highlight Statusline ctermbg=8 ctermfg=0 cterm=none
highlight StatusLineNC ctermbg=0 ctermfg=0 cterm=none
endif
highlight User1 ctermfg=4 cterm=none
" separator color
highlight User2 ctermfg=10 cterm=none
" git color
highlight User3 ctermfg=13 cterm=italic
" separator color + italic
highlight User4 ctermfg=10 cterm=italic
highlight User5 ctermfg=4 cterm=italic
" statusline setup - changes color of prompt char based on mode
set statusline =%#type#
set statusline+=%{mode()=='n'?'≷':''}%*
set statusline+=%#string#
set statusline+=%{mode()=='i'?'≷':''}%*
set statusline+=%#include#
set statusline+=%{mode()=='v'?'≷':''}%*
set statusline+=%*
set statusline+=%2*\ ∘\ %*
set statusline+=%4*
set statusline+=%{expand('%:~:.:h')}
set statusline+=/
set statusline+=%*
set statusline+=%5*
set statusline+=%{expand('%:t')}
set statusline+=%*
set statusline+=\
set statusline+=%#type#
set statusline+=%{(&readonly?'!\ ':'').(&modified?'+\ ':'')}
set statusline+=%*
set statusline+=%2*
set statusline+=%{fugitive#head()==''?'':'∘\ '}
set statusline+=%*
set statusline+=%3*
set statusline+=%{fugitive#head()}
set statusline+=%*
" ---------->
" right side
" ---------->
set statusline+=%=
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
"display a warning if &paste is set
set statusline+=%#label#
set statusline+=%{&paste?'paste\ ':''}
set statusline+=%*
set statusline+=%{&ft} "filetype
set statusline+=%2*
set statusline+=\
set statusline+=%l/%L "cursor line/total lines
set statusline+=%*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment