Skip to content

Instantly share code, notes, and snippets.

@lucidstack
Last active July 1, 2017 15:52
Show Gist options
  • Save lucidstack/2e9a461303b98115c55b to your computer and use it in GitHub Desktop.
Save lucidstack/2e9a461303b98115c55b to your computer and use it in GitHub Desktop.
lucidstack vimrc
" Defaults
""""""""""
set nocompatible " be iMproved, required
filetype off " required
""""""""""
" Defaults
" Plugins
""""""""
call plug#begin('~/.local/share/nvim/plugged')
" Navigation
Plug 'scrooloose/nerdtree'
Plug 'mortonfox/nerdtree-iterm'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'lucidstack/ctrlp-tmux.vim'
Plug 'lucidstack/ctrlp-mpc.vim'
let g:ctrlp_mpc_cmd = 'mpc --port 6600'
let g:ctrlp_custom_ignore = 'log\|tags\|node_modules\|plugins\|platforms\|\.git'
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlPLastMode'
let g:ctrlp_extensions = ['buffertag', 'tag', 'line', 'dir', 'tmux', 'mpc']
Plug 'justinmk/vim-gtfo'
Plug 'mileszs/ack.vim'
let g:ackprg = 'ag --vimgrep --ignore node_modules --ignore log --smart-case'
" Editing
Plug 'scrooloose/nerdcommenter'
Plug 'chrisbra/csv.vim'
Plug 'troydm/zoomwintab.vim'
Plug 'ervandew/supertab'
Plug 'wellle/targets.vim'
let g:SuperTabDefaultCompletionType = "<c-n>"
Plug 'scrooloose/syntastic'
let g:syntastic_c_include_dirs=['/usr/local/Cellar/erlang/18.2.1/lib/erlang/erts-7.2.1/include']
let g:syntastic_coffee_checkers = ['coffeelint']
let g:syntastic_html_tidy_ignore_errors=["trimming empty <"]
Plug 'ludovicchabant/vim-gutentags'
let g:gutentags_cache_dir = '~/.tags_cache'
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-surround'
Plug 'godlygeek/tabular'
Plug 'tpope/vim-repeat'
" Utility, probably don't touch
Plug 'xolox/vim-misc'
" Ruby
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-rails'
Plug 'mattn/webapi-vim'
Plug 'alexbel/vim-rubygems'
Plug 'kana/vim-textobj-user'
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'ngmy/vim-rubocop'
let g:vimrubocop_rubocop_cmd='vbin/bundle exec rubocop'
" Elixir
Plug 'lucidstack/hex.vim'
Plug 'elixir-lang/vim-elixir'
Plug 'mattreduce/vim-mix'
" Markup
Plug 'othree/html5.vim'
Plug 'nono/vim-handlebars'
Plug 'yaymukund/vim-rabl'
Plug 'mattn/emmet-vim'
let g:user_emmet_leader_key=','
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled=1
" Frontend
Plug 'kchmck/vim-coffee-script'
Plug 'cakebaker/scss-syntax.vim'
Plug 'hail2u/vim-css3-syntax'
Plug 'mtscout6/vim-cjsx'
Plug 'ap/vim-css-color'
Plug 'elzr/vim-json'
Plug 'othree/yajs.vim'
let g:vim_json_syntax_conceal = 2
" Git
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
" Testing
Plug 'tell-k/vim-browsereload-mac'
Plug 'benmills/vimux'
Plug 'skalnik/vim-vroom'
" Aspect
Plug 'junegunn/limelight.vim'
Plug 'w0ng/vim-hybrid'
Plug 'whatyouhide/vim-gotham'
Plug 'mhinz/vim-startify'
let g:hybrid_custom_term_colors = 1
let g:hybrid_reduced_contrast = 1
Plug 'morhetz/gruvbox'
let g:gruvbox_italic=1
let g:gruvbox_contrast_dark='soft'
let g:gruvbox_italicize_strings=1
Plug 'junegunn/goyo.vim'
let g:goyo_margin_top=2
let g:goyo_margin_bottom=2
let g:goyo_width=120
call plug#end() " required
filetype plugin indent on " required
" Load matchit (% to bounce from do to end, etc.)
runtime! macros/matchit.vim
""""""""
" Plugins
" Functions
""""""""""
" Returns true if paste mode is enabled (for statusline)
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" vp doesn't replace paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
""""""""""
" Functions
" UI
""""""""""
set t_Co=256
syntax enable
set background=dark
colorscheme hybrid
highlight Comment cterm=italic
highlight String cterm=italic
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
" Autopen NERDTree if vim is opened with no args
autocmd VimEnter *
\ if argc() == 0
\ | Startify
\ | NERDTree
\ | endif
""""""""""
" UI
" Functionalities
"""""""""""""""""
set hidden " allow hiding buffers with changes
set undofile " Persistent undo (across files)
set autoindent " Autoindentation
set smarttab " Knows how to use TAB
set expandtab " Use spaces instead of tabs
set pastetoggle=<F2> " Toggle paste mode with F2
set ai sw=2 sts=2 et " Autoindentation, all set to 2 spaces
set linespace=0 " No extra spaces between rows
set backspace=indent,eol,start " backspace made easy
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to
set nu " Line numbers on
set cmdheight=2
" Search and replace
""""""""""""""""""""
set showmatch " show matching brackets/parenthesis
set matchtime=2 " set matching time
set incsearch " find as you type search
set hlsearch " highlight search terms
set ignorecase " case insensitive search
set smartcase " case sensitive when uc present
set gdefault " the /g flag on :s substitutions by default
""""""""""""""""""""
" Search and replace
set winminheight=0 " windows can be 0 line high
set wildmenu " show list instead of just completing
set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all.
set scrolljump=5 " lines to scroll when cursor leaves screen
set scrolloff=3 " minimum lines to keep above and below cursor
set foldenable " auto fold code
set listchars=tab:>-,extends:>,precedes:< " chars to be displayed (useful for trailing whitespaces)
set list " show the invisible chars above
set mouse=a " makes scrolling work with mouse
set autoread " reloads files on change
set t_ut= " resets the t_ut variable (fixes background color in tmux)
set nobackup " vim, stahp. I don't want your goddamned backup files
set splitbelow " open pane below current one on split
set splitright " open pane right current one on split
set noswapfile " They are a pain to delete/recover every time
set timeoutlen=200 ttimeoutlen=0 " removes annoying delay in exiting/entering insert mode
set exrc " enable per-project .vimrc files
set secure " Only execute safe per-project vimrc commands
set lazyredraw " Only redraw the screen when something is typed (speeds up macros)
set ttyfast " Particular performance boosts for terminals
set ai " Automatically set the indent of a new line (from bitboxer/dotfiles)
if !has('nvim')
set ttymouse=xterm2 " makes dragging panes with mouse work
endif
" makes vim work with crontab
if $VIM_CRONTAB == "true"
set nobackup
set nowritebackup
endif
" strip trailing whitespaces on save
autocmd BufWritePre * :%s/\s\+$//e
" to read epubs
au BufReadCmd *.epub call zip#Browse(expand("<amatch>"))
"""""""""""""""""
" Functionalities
" Mappings
""""""""""
let mapleader = "\<Space>"
let g:mapleader = "\<Space>"
" I was an adventurer too...
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnore> >>
nnore< <<
" navigate through methods
map <Leader>nm ]m:TagbarShowTag<CR>
map <Leader>mn [m:TagbarShowTag<CR>
" leader shortcuts for beginning/end of line
nnoremap <Leader>f ^
nnoremap <Leader>j $
vmap <Leader>f ^
vmap <Leader>j $
" Open CTRLP with Space+o
nnoremap <Leader>o :CtrlP .<CR>
nnoremap <Leader>t :CtrlPTag<CR>
" Change Tmux sessions with CtrlP
nnoremap <Leader>s :CtrlPTmux<CR>
" Change tracks with CtrlP
nnoremap <Leader>m :CtrlPMpc<CR>
" Toggle Tagbar
nnoremap <leader>tt :TagbarToggle<CR>
" Move between lines taking wrapping in consideration
nnoremap j gj
nnoremap k gk
" open tag definition in a vsplit
map <C-\> :vsp<CR><C-]>
" copy and paste to from system clipboard
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
map <leader>rs :%s/\<<C-r><C-w>\>/
" kill a buffer with ctrl+c
map <C-c> :BD<cr>
" don't replace paste buffer when pasting
vmap <silent> <expr> p <sid>Repl()
" add a space and paste
nnoremap <Leader>np i <ESC>p
" Fast saving
nmap <leader>w :w!<CR>
" Yanking the right way
nnoremap Y y$
" <tab> / <s-tab> | Circular windows navigation
nnoremap <leader><tab> <c-w>w
nnoremap <leader><S-tab> <c-w>W
" from http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
map q: :q
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Buffer switching
map <leader>b :b#<CR>
" Center cursor line on screen
nnoremap <Leader>zz :let &scrolloff=999-&scrolloff<CR>
" bind ks to grep word under cursor, and ke to leave the search
nnoremap <leader>ks :Ack "<C-R><C-W>"<CR>
nnoremap <silent> <leader>ke :ccl<CR>
" Replace all occurences under cursor
nnoremap <Leader>kr :%s/\<<C-r><C-w>\>//<Left><Left>
" bind \ (backward slash) to grep shortcut
nnoremap \ :Ack<SPACE>
" Move through the quickfix window rows
nmap <silent> <up> :cprev<CR>
nmap <silent> <down> :cnext<CR>
" Switch search highlighting
noremap <silent> <leader>, :set hls!<CR>
" For when you are faster than shift
command! W w
command! Wqa wqa
command! Qa qa
" Go to line with Enter
noremap <CR> gg
" Fast reload of vimrc
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" CORDOVA! (veeeery specific)
nmap <silent> <leader>cbb :!cordova build && osascript ~/.scripts/run-xcode.osa<CR>
nmap <silent> <leader>cbs :!osascript ~/.scripts/cordova-safari.osa<CR>
" for when rails doesn't refresh your assets
nmap <silent> <leader>sr :w<CR>:!rake tmp:cache:clear<CR>:ChromeReload<CR>
" this is AMAZING. Use python to prettify a json file
nmap <leader>pj :%!python -m json.tool<CR>
" Plugins mappings
""""""""""""""""""
" vroom-vim mappings
map <Leader>vl :VroomRunLastTest<CR>
map <Leader>vn :VroomRunNearestTest<CR>
map <Leader>vf :VroomRunTestFile<CR>
map <Leader>va :VimuxRunCommand "be rake"<CR>
" Distraction-free mode
nnoremap <silent> <leader>z :Goyo<cr>
" Map Ctrl+b Ctrl+b to open/close NerdTree
map <C-b><C-b> :NERDTreeToggle<CR>
" Map r to find file in NerdTree
map <leader>r :NERDTreeFind<CR>
" Searches for the term under the cursor in Dash
nmap <leader>d <Plug>DashSearch
" select and unselect regions
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" Save and chrome reload
nmap <leader>rw :w<CR>:ChromeReload<CR>
" Alternate in rails files
nmap <leader>ra :A<CR>
nmap <leader>rr :R<CR>
" convert wiki2html
nmap <silent><buffer> <Leader>w2h <Plug>Vimwiki2HTMLBrowse
""""""""""""""""""
" Plugins mappings
" Silly mappings
"""""""""""""""""
"""""""""""""""""
" Silly mappings
if exists(':tnoremap')
" Not really using the nvim terminal at the moment :/
" Terminal mappings
"""""""""""""""""""
" Start term in panes
" nnoremap <leader>to :term<CR>
" nnoremap <leader>tt :tabnew<CR>:term<CR>
" nnoremap <leader>tv :vsp<CR>:term<CR>
" nnoremap <leader>ts :sp<CR>:term<CR>
" " Exit terminal insert mode
" tnoremap <Leader>te <C-\><C-n>
" " Navigation between panes with Alt+hjkl
" tnoremap <A-h> <C-\><C-n><C-w>h
" tnoremap <leader>hh <C-\><C-n><C-w>h
" tnoremap <A-j> <C-\><C-n><C-w>j
" tnoremap <A-k> <C-\><C-n><C-w>k
" tnoremap <A-l> <C-\><C-n><C-w>l
" nnoremap <A-h> <C-w>h
" nnoremap <A-j> <C-w>j
" nnoremap <A-k> <C-w>k
" nnoremap <A-l> <C-w>l
" nnoremap <leader>ri <c-w><c-w>i<UP><c-\><c-n>:sleep 100m<CR>i<CR><c-\><c-n><c-w><c-w>
" """""""""""""""""""
" Terminal mappings
endif
""""""""""
" Mappings
" The Silver Searcher
let g:ctrlp_use_caching = 0
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s --ignore node_modules --ignore log -l --nocolor -g ""'
else
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<space>', '<cr>', '<2-LeftMouse>'],
\ }
endif
""" Airline
"" populate airline symbols
"let g:airline_powerline_fonts = 1
"" show status line all the time
"set laststatus=2
"" enables tabline
"" let g:airline#extensions#tabline#enabled = 1
"" set airline theme
"let g:airline_theme='hybrid'
""" Airline
""" Vroom
let g:vroom_use_vimux=1
let g:vroom_use_zeus=0
let g:vroom_use_bundle_exec=0
let g:vroom_use_binstubs=0
let g:vroom_use_bundle_exec=0
let g:vroom_use_colors=1
" this gives rspec's pane a title "tests", that we'll late use to find its id
let g:vroom_spec_command="vbin/rspec"
""" Vroom
""" Goyo Callbacks
function! s:goyo_enter()
silent !tmux set status off
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_leave()
silent !tmux set status on
set showmode
set showcmd
set scrolloff=5
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
""" Goyo Callbacks
""" Limelight customisation
let g:limelight_conceal_ctermfg = 'gray'
""" Limelight customisation
""" Chrome reload plugin
let g:returnAppFlag = 0
let g:returnApp = 'iTerm'
""" Chrome reload plugin
""" Syntastic plugin
" the sass checker is slow as hell
let g:syntastic_mode_map = { 'passive_filetypes': ['sass', 'scss'] }
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
"""
""" SCSS Syntax plugin
" highlight function names a keyword correctly
autocmd FileType scss set iskeyword+=-
""" Custom syntax highlighting
hi def link exActorFunction elixirDefine
syn keyword exActorFunction defcast defcall defstart defhandleinfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment