Skip to content

Instantly share code, notes, and snippets.

@carlweis
Created April 13, 2016 19:09
Show Gist options
  • Save carlweis/9dad00bc18f6be030b9233221ab10950 to your computer and use it in GitHub Desktop.
Save carlweis/9dad00bc18f6be030b9233221ab10950 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved, required
so ~/.vim/plugins.vim " load vundle plugins
syntax enable
"-------------General Settings--------------"
set backspace=indent,eol,start "Make backspace behave like every other editor.
let mapleader = ',' "The default leader is \, but a comma is much better.
set number "Let's activate line numbers.
set tabstop=2
set softtabstop=2
set shiftwidth=2
set noerrorbells visualbell t_vb= "No damn bells!
set autowriteall
set complete=.,w,b,u
set smartindent
set autoindent
"-----------Visuals---------------"
colorscheme hybrid
set t_Co=256
set background=dark
set linespace=15
set guifont=hack
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
"----------Airline----------------"
set laststatus=2
let g:airline_theme = "hybrid"
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" override visuals
hi LineNr ctermbg=bg
hi vertsplit ctermbg=bg ctermfg=bg
"-------------Search--------------"
set hlsearch
set incsearch
"-------------Mappings--------------"
"Make it easier to write a file
nmap <Leader>w :w<cr>
nmap <Leader>wa :wa<cr>
"Make it easy to edit the Vimrc file.
nmap <Leader>ev :tabedit $MYVIMRC<cr>
nmap <Leader>ep :tabedit ~/.vim/plugins.vim<cr>
nmap <Leader>es :e ~/.vim/snippets/<cr>
nmap <Leader>ras :call ReloadAllSnippets()<cr>
"Add simple highlight removal.
nmap <Leader><space> :nohlsearch<cr>
"Make NERDTree easier to toggle
nmap <C-n> :NERDTreeToggle<cr>
"CtrlP mappings
nmap <C-r> :CtrlPBufTag<cr>
nmap <C-e> :CtrlPMRUFiles<cr>
"Ctags mappings
nmap <Leader>f :tag<space>
nmap <C-t> :!ctags -R<cr><cr>
"-------------Split Management--------------"
set splitbelow "Make splits default to below...
set splitright "And to the right. This feels more natural.
"We'll set simpler mappings to switch between splits.
nmap <C-J> <C-W><C-J>
nmap <C-K> <C-W><C-K>
nmap <C-H> <C-W><C-H>
nmap <C-L> <C-W><C-L>
"------------Plugin Settings-------------"
"/
" PHP CS Fixer
"/
let g:php_cs_fixer_level = "psr2"
noremap <silent><leader>pf :call PhpCsFixerFixFile()<cr><cr>
"/
" CtrlP
"/
let g:ctrlp_custom_ignore = 'node_modules\DS_Store\|git'
let g:ctrlp_match_window = 'top,order:ttb,min:1, max:30,results:30'
"/
"greplace.vim
"/
set grepprg=ag
let g:grep_cmd_opts = '--line-numbers --noheading'
"/
"AG search
"/
"-------------NERDTree Settings----------"
let g:NERDTreeWinPos = "right" " Always open on the right
let NERDTreeHijackNetrw = 0 " Don't allow NERDTree to override Netrw
"------------Laravel-Specific------------"
"laravel navigation
nmap <Leader>lr :e app/Http/routes.php<cr>
nmap <Leader>lfc :e app/Http/Controllers/<cr>
nmap <Leader>lfm :e app/Models/<cr>
nmap <Leader>lfv :e resources/views/<cr>
nmap <Leader>lfsp :e app/Providers/<cr>
nmap <Leader>lfmg :e database/migrations/<cr>
"laravel generators
nmap <Leader>lm :!php artisan make:
nmap <Leader>lmc :!php artisan make:controller<space>
nmap <Leader>lmm :!php artisan make:model<space>
nmap <Leader>lmmg :!php artisan make:migration<space>
nmap <Leader>lmco :!php artisan make:console<space>
nmap <Leader>lme :!php artisan make:event<space>
nmap <Leader>lmmw :!php artisan make:middleware<space>
nmap <Leader>lmp :!php artisan make:provider<space>
nmap <Leader>lmr :!php artisan make:request<space>
nmap <Leader>lms :!php artisan make:seeder<space>
nmap <Leader>lmt :!php artisan make:test<space>
"laravel artisan
nmap <Leader>lrl :!php artisan route:list<cr>
nmap <Leader>ldbs :!php artisan db:seed<cr>
nmap <Leader>ldbm :!php artisan migrate<cr>
nmap <Leader>ldbmr :!php artisan migrate:refresh<cr>
"----------------Git-Specific----------------"
nmap <Leader>gi :!git init<cr>
nmap <Leader>ga :!git add -A<cr><cr>
nmap <Leader>gc :!git commit -am'
nmap <Leader>gco :!git checkout<space>
nmap <Leader>gcb :!git checkout -b<space>
nmap <Leader>gs :!git status<cr>
nmap <Leader>gl :!git log<cr>
nmap <Leader>gm :!git merge<space>
nmap <Leader>gp :!git push -u<space>
nmap <Leader>gpa :!git push --all<cr>
nmap <Leader>grb :!git rebase<space>
nmap <Leader>grh :!git reset HEAD<space>
"--------------Meteor-Specific--------------"
nmap <Leader>ma :!meteor add<space>
nmap <Leader>mr :!meteor remove<space>
nmap <Leader>mm :!meteor mongo<cr>
nmap <Leader>mc :!meteor console<cr>
"------------PHP-Specific----------------"
"Auto-import namespace
function! IPhpExpandClass()
call PhpExpandClass()
call feedkeys('a', 'n')
endfunction
autocmd FileType php inoremap <Leader>n <Esc>:call IPhpInsertUse()<CR>
autocmd FileType php noremap <Leader>n :call PhpInsertUse()<CR>
"Expand fully qualified namespace
function! IPhpExpandClass()
call PhpExpandClass()
call feedkeys('a', 'n')
endfunction
autocmd FileType php inoremap <Leader>nf <Esc>:call IPhpExpandClass()<CR>
autocmd FileType php noremap <Leader>nf :call PhpExpandClass()<CR>
"Sort PHP use statements
vmap <Leader>su ! awk '{ print length(), $0 \| "sort -n \| cut -d\\ -f2-"}'<cr>
"-------------Auto-Commands--------------"
"Automatically source the Vimrc file on save.
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source %
"set tabsize for languages
autocmd Filetype css setlocal tabstop=2
autocmd Filetype scss setlocal tabstop=2
autocmd Filetype less setlocal tabstop=2
autocmd Filetype styl setlocal tabstop=2
autocmd Filetype html setlocal tabstop=2
autocmd Filetype rb setlocal tabstop=2
autocmd Filetype js setlocal tabstop=2
autocmd Filetype php setlocal tabstop=4
autocmd Filetype py setlocal tabstop=4
augroup END
" vundle
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-vinegar'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'rking/ag.vim'
Plugin 'skwp/greplace.vim'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'tpope/vim-surround'
Plugin 'StanAngeloff/php.vim'
Plugin 'arnaud-lb/vim-php-namespace'
Plugin 'ervandew/supertab'
Plugin 'stephpy/vim-php-cs-fixer'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-projectionist'
Plugin 'vim-ruby/vim-ruby'
Plugin 'skalnik/vim-vroom'
Plugin 'tpope/vim-endwise'
Plugin 'mattn/emmet-vim'
Plugin 'bling/vim-bufferline'
Plugin 'airblade/vim-gitgutter'
Plugin 'edkolev/tmuxline.vim'
Plugin 'scrooloose/syntastic'
Plugin 'edkolev/promptline.vim'
Plugin 'wavded/vim-stylus'
Plugin 'vim-scripts/jade.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment