Skip to content

Instantly share code, notes, and snippets.

@bdougie
Last active February 14, 2018 21:31
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 bdougie/8b5990439904cc6a0e16 to your computer and use it in GitHub Desktop.
Save bdougie/8b5990439904cc6a0e16 to your computer and use it in GitHub Desktop.
My Vimrc as of 1/2016
""""""""""""""""""""""
"" Vundler Boiler """"
""""""""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
filetype plugin on " nercommenter
" Word wrap
set wrap
set textwidth=80
"omnicomplete
set omnifunc=syntaxcomplete#Complete
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'https://github.com/gorodinskiy/vim-coloresque.git'
Plugin 'cakebaker/scss-syntax.vim'
" Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'skalnik/vim-vroom'
Plugin 'farseer90718/flattr.vim'
Plugin 'lmeijvogel/vim-yaml-helper'
Plugin 'rizzatti/dash.vim'
Plugin 'thoughtbot/vim-rspec'
Plugin 'https://github.com/scrooloose/nerdcommenter'
Plugin 'fatih/vim-go'
Plugin 'rust-lang/rust.vim'
Plugin 'millermedeiros/vim-esformatter'
Plugin 'lambdatoast/elm.vim'
Plugin 'mxw/vim-jsx'
Plugin 'mileszs/ack.vim'
Plugin 'posva/vim-vue'
Plugin 'digitaltoad/vim-pug'
Plugin 'reasonml/vim-reason-loader'
Plugin 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql'] }
" Plugin 'wookiehangover/jshint.vim'
" Plugin 'SirVer/ultisnips'
" you complete me doesnt work
" Plugin 'Valloric/YouCompleteMe'
" Plugin 'janko-m/vim-test'
"brew install the_silver_searcher
call vundle#end()
""""""""""""""""""""""
"""" Janus setup """""
""""""""""""""""""""""
" Define paths
let g:janus_path = escape(fnamemodify(resolve(expand("<sfile>:p")), ":h"), ' ')
let g:janus_vim_path = escape(fnamemodify(resolve(expand("<sfile>:p" . "vim")), ":h"), ' ')
let g:janus_custom_path = expand("~/.janus")
" Source janus's core
exe 'source ' . g:janus_vim_path . '/core/before/plugin/janus.vim'
" You should note that groups will be processed by Pathogen in reverse
" order they were added.
call janus#add_group("tools")
call janus#add_group("langs")
call janus#add_group("colors")
""""""""""""""""""""""
"" Pathogen setup """"
""""""""""""""""""""""
" Load all groups, custom dir, and janus core
call janus#load_pathogen()
""""""""""""""""""""""
"" Customizations """"
""""""""""""""""""""""
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif
" Disable plugins prior to loading pathogen
exe 'source ' . g:janus_vim_path . '/core/plugins.vim'
" .vimrc.after is loaded after the plugins have loaded
" Source the vimrc file after saving it
if has("autocmd")
autocmd bufwritepost .vimrc source $MYVIMRC
endif
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" bind \ (backward slash) to grep shortcut
nnoremap \ :Ag<SPACE>
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
""""""""""""""""""""""
"""""" Mappings """"""
""""""""""""""""""""""
" mapleader change to <spacebar>
:let mapleader = " "
" prettier
let g:prettier#config#semi = 'true'
let g:prettier#config#single_quote = 'false'
let g:prettier#config#bracket_spacing = 'false'
let g:prettier#config#tab_width = 2
let g:prettier#config#print_width = 120
" vroom commands
let g:vroom_map_keys = 0
nmap <leader>ttt :VroomRunTestFile<CR>
nmap <leader>rr :VroomRunNearestTest<CR>
nmap <leader>ll :VroomRunLastTest<CR>
" RSpec.vim mappings
map <leader>tt :call RunCurrentSpecFile()<CR>
map <leader>s :call RunNearestSpec()<CR>
map <leader>l :call RunLastSpec()<CR>
map <leader>a :call RunAllSpecs()<CR>
" open vim with <leader>v command
nmap <leader>v :edit $MYVIMRC<CR>
" copies the current path to vim clipboard - path, fullpath, just filename
nmap <leader>ff :let @+=expand("%")<CR>
nmap <leader>F :let @+ = expand("%:p")<CR>
nmap <leader>fl :let @+ = expand("%:t")<CR>
" search :Ack actually is <leader>f in terminal vim
nmap <leader>ck :Ack
nmap <leader>gr :grep -F
" toggle spell
nmap <silent> <leader>sp :set spell!<CR>
nmap <silent> <leader>sz 1z=<CR>
" http://vimcasts.org/episodes/spell-checking/
" comment out like sublime
" nmap <D-/> gcc
" maps buffer searching
nmap <leader>bb :ls<CR>
nmap <leader>bl :b#<CR>
nmap <leader>bc :CtrlPBuffer<CR>
" maps vertical and horizontal switching
nmap <leader>H :windo wincmd K<CR>
nmap <leader>h :windo wincmd H<CR>
" open new and split windows
nmap <leader>ss :Sex<CR>
nmap <leader>vv :Vex<CR>
" maps the quit without changes to <leader>q
nmap <leader>q :q!<CR>
" maps spelling mistakes
nmap <leader>e :e.<CR>
" Syntaxt enabling
nmap <leader>1 :syntax enable<CR>
" remove hilights from matched searches
nmap <leader>2 :noh<CR>
" Format JSON Quickly
nmap <leader>3 :%!python -m json.tool<CR>
" copy Sublime indentation rules
" pairing - no indenting for now
" Vjj> instead
" nmap <D-[> <<
" nmap <D-]> >>
" vmap <D-[> <gv
" vmap <D-]> >gv
" move highlighted text
:vmap <C-Right> xpgvlolo
:vmap <C-left> xhPgvhoho
:vnoremap <Left> h
:vnoremap <Right> l
:vnoremap <Up> k
:vnoremap <Down> j
vmap <C-Down> xjPgvjojo
vmap <C-Up> xkPgvkoko
" YAML nav mappings, mainly for the en.yml
nmap <leader>yp :YamlGetFullPath<CR>
nmap <leader>yk :YamlGoToKey
nmap <leader>ym :YamlGoToParent<CR>
" GO run
nmap <leader>gr <Plug>(go-run)
nmap <leader>gob <Plug>(go-build)
nmap <leader>got <Plug>(go-test)
nmap <leader>goc <Plug>(go-coverage)
" Word swapping http://vim.wikia.com/wiki/VimTip47
" :nnoremap <silent> gv xph
" :nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>
" :nnoremap <silent> gl "_yiw?\w\+\_W\+\%#<CR>:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>
" Swap the current character (the character under the cursor) with the next:
" xp
" Swap the current character with the previous:
" Xp
" Swap the current line with the next (but see below for a better method):
" ddp
" Swap the current line with the previous:
" ddkP or ddkkp
" Swap the current word with the next (see note):
" dawwP
" dawelp
" hdeep (works at start of first word)
"xdiwdwep"xp (works with most punctuations too)
" Saving, etc
nnoremap <Leader>w :retab<bar>:w<cr> " changes tabs to spaces and save
nnoremap <Leader>wq :retab<bar>:wq<cr> " changes tabs to spaces, saves, and quits
nnoremap <Leader>q :q<cr>
" crete tabs
" no more creating tabs for now
" nmap <leader>ta :tabedit<CR>
" nvm local shortcut
nmap <leader>nvm :! source ~/.nvm/nvm.sh<CR>
" set indent in normal mode to be "="
set autoindent
set cindent
" color scheme
set background=light
" colorscheme github "light
" colorscheme base16-atelierforest "light
" colorscheme base16-atelierseaside "lightgreen
colorscheme flattr "dark
"" Christian's MakeScript
function! MakeSpec()
let file_path = substitute(expand("%:r"), '^app/', '', '')
:exec ":Espec ". file_path."!"
endfunction
:command! MakeSpec :call MakeSpec()
" grab entire line to move using CRTL + Shift + Direction
function! s:swap_lines(n1, n2)
let line1 = getline(a:n1)
let line2 = getline(a:n2)
call setline(a:n1, line2)
call setline(a:n2, line1)
endfunction
function! s:swap_up()
let n = line('.')
if n == 1
return
endif
call s:swap_lines(n, n - 1)
exec n - 1
endfunction
function! s:swap_down()
let n = line('.')
if n == line('$')
return
endif
call s:swap_lines(n, n + 1)
exec n + 1
endfunction
noremap <silent> <c-s-up> :call <SID>swap_up()<CR>
noremap <silent> <c-s-down> :call <SID>swap_down()<CR>
" test using spring
" let test#ruby#rspec#executable = "spring rspec"
" commonly misspelled words
iabbrev mispell misspell
" eslint for es6 fmt
" will run esformatter after pressing <leader> followed by the 'e' and 's' keys
nnoremap <silent> <leader>esl :Esformatter<CR>
vnoremap <silent> <leader>esl :EsformatterVisual<CR>
let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_css_checkers = ['stylelint']
" golint
" set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
" lint on save
" autocmd BufWritePost,FileWritePost *.go execute 'GoLint' | cwindow
" jsx
let g:jsx_ext_required = 0
" ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
let s:opam_share_dir = system("opam config var share")
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
let s:opam_configuration = {}
function! OpamConfOcpIndent()
execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
endfunction
let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')
function! OpamConfOcpIndex()
execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim"
endfunction
let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')
function! OpamConfMerlin()
let l:dir = s:opam_share_dir . "/merlin/vim"
execute "set rtp+=" . l:dir
endfunction
let s:opam_configuration['merlin'] = function('OpamConfMerlin')
let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
let s:opam_available_tools = split(system(join(s:opam_check_cmdline)))
for tool in s:opam_packages
" Respect package order (merlin should be after ocp-index)
if count(s:opam_available_tools, tool) > 0
call s:opam_configuration[tool]()
endif
endfor
" ## end of OPAM user-setup addition for vim / base ## keep this line
" #ocamlmerlin
let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
execute "set rtp+=" . g:opamshare . "/merlin/vim"
let g:syntastic_ocaml_checkers = ['merlin']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment