Skip to content

Instantly share code, notes, and snippets.

@joelbrewer
Created March 23, 2022 22:11
Show Gist options
  • Save joelbrewer/d2b791e383ec13c089cdcb75a2c0ead7 to your computer and use it in GitHub Desktop.
Save joelbrewer/d2b791e383ec13c089cdcb75a2c0ead7 to your computer and use it in GitHub Desktop.
Joel's .vimrc
call plug#begin('~/.vim/bundle')
Plug 'ctrlpvim/ctrlp.vim'
Plug 'pbrisbin/vim-mkdir'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'vim-ruby/vim-ruby'
Plug 'vim-scripts/tComment'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'altercation/vim-colors-solarized'
Plug 'scrooloose/nerdtree'
Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-obsession'
Plug 'jgdavey/tslime.vim'
Plug 'keith/swift.vim'
Plug 'leafgarland/typescript-vim'
Plug 'rizzatti/dash.vim'
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'valloric/MatchTagAlways'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'burnettk/vim-angular'
Plug 'vimwiki/vimwiki'
Plug 'epilande/vim-es2015-snippets'
Plug 'epilande/vim-react-snippets'
Plug 'tellijo/vim-react-native-snippets'
Plug 'SirVer/ultisnips'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
Plug 'ervandew/supertab'
Plug 'editorconfig/editorconfig-vim'
Plug 'w0rp/ale'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'mkitt/tabline.vim'
Plug 'jpalardy/vim-slime'
call plug#end()
let mapleader = " "
imap jj <Esc>
nmap <leader>w :wa<CR><CR>
nmap <leader>q :q<CR><CR>
" nmap <leader>cb :!cordova emulate browser<CR>
nmap <leader>p :FZF<CR>
nmap <leader>a <Plug>(ale_fix)
nmap <leader>p :Files<CR>
nmap <leader>h :History<CR>
nmap <leader>b :Buffers<CR>
noremap <Leader>c "*y
noremap <Leader>v "*p
nnoremap <leader><leader> <c-^> " Switch between the last two files
nnoremap <Leader>r :RunInInteractiveShell<space> " Run commands that require an interactive shell
" map <Leader>ct :!ctags -R .<CR> " Index ctags from any project, including those outside Rails
map <leader>n :NERDTreeToggle<CR>
map <leader>ln :lnext<CR>
map <leader>lp :lprevious<CR>
set backspace=2 " Backspace deletes like most programs in insert mode
set nobackup
set nowritebackup
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
set autowrite " Automatically :write before running commands
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
set list listchars=tab:»·,trail:·,nbsp:· " Display extra whitespace
set number
set numberwidth=5
set wildmode=list:longest,list,full
set splitbelow
set splitright
set ttyfast
set rtp+=/usr/local/opt/fzf
set hlsearch
set spellfile=$HOME/.vim-spell-en.utf-8.add
set complete+=kspell
set diffopt+=vertical
set background=dark
set pastetoggle=<F12>
let g:jsx_ext_required = 0
let g:ale_sign_column_always = 1
let g:ale_sign_error = '**'
let g:ale_fixers = {
\ 'javascript': ['eslint']
\ }
let g:ale_lint_on_save = 1
let g:airline#extensions#ale#enabled = 1
let g:slime_target = "tmux"
let g:slime_default_config = {"socket_name": get(split($TMUX, ","), 0), "target_pane": ":.2"}
colorscheme solarized
filetype plugin indent on
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
syntax on
endif
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals set filetype=ruby
autocmd BufRead,BufNewFile *.md set filetype=markdown
" Enable spellchecking for Markdown
autocmd FileType markdown setlocal spell
" Automatically wrap at 80 characters for Markdown
autocmd BufRead,BufNewFile *.md setlocal textwidth=80
" Automatically wrap at 72 characters and spell check git commit messages
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType gitcommit setlocal spell
" Allow stylesheets to autocomplete hyphenated words
autocmd FileType css,scss,sass setlocal iskeyword+=-
augroup END
" Use The Silver Searcher https://github.com/ggreer/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 --hidden -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'" " Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing
let g:html_indent_tags = 'li\|p' " Treat <li> and <p> tags like the block tags they are
let g:solarized_termtrans = 1
let g:solarized_termcolors=256
let g:airline_theme='solarized'
let g:airline_solarized_bg='dark'
set iskeyword-=.
set guitablabel=\[%N\]\ %t\ %M
imap <Tab> <C-P>
nnoremap <CR> :noh<CR><CR>
" Source vimrc on save
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
" Use backward slash to bring up Ag
nnoremap \ :Ag<SPACE><CR>
" Search for word under the cursor using K
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
endif
" 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>"
" if &compatible
" set nocompatible
" end
" Shim command and function to allow migration from Vundle to vim-plug.
function! VundleToPlug(vundle_command, arg, ...)
echom "You are using Vundle's `".a:vundle_command."` command to declare plugins. Dotfiles now uses vim-plug for plugin mangagement. Please rename uses of `".a:vundle_command."` to `Plug`. Plugin was '".a:arg."'."
let vim_plug_options = {}
if a:0 > 0
if has_key(a:1, 'name')
let name = a:1.name
let vim_plug_options.dir = "$HOME/.vim/bundle/".a:1.name
endif
if has_key(a:1, 'rtp')
let vim_plug_options.rtp = a:1.rtp
endif
endif
Plug a:arg, vim_plug_options
endfunction
com! -nargs=+ -bar Plugin call VundleToPlug("Plugin", <args>)
com! -nargs=+ -bar Bundle call VundleToPlug("Bundle", <args>)
@joelbrewer
Copy link
Author

joelbrewer commented Mar 23, 2022

To install vim plugin manager:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Then open vim: vim and run :PlugInstall inside vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment