Skip to content

Instantly share code, notes, and snippets.

@coryf
Last active October 11, 2015 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coryf/3836591 to your computer and use it in GitHub Desktop.
Save coryf/3836591 to your computer and use it in GitHub Desktop.
Vim setup with plugin update script
set nocompatible " We don't want vi compatibility.
set guifont=Menlo\ For\ Powerline:h10
set guioptions-=m " No menu
set guioptions-=T " No toolbar
set guioptions+=c " Use console dialogs where possible
set modelines=0
set encoding=utf-8 " Necessary to show Unicode glyphs
let g:Powerline_symbols = 'fancy'
let g:Powerline_theme = 'default'
let g:Powerline_colorscheme = 'solarized256'
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
" Add recently accessed projects menu (project plugin)
set viminfo^=!
" Auto reload vimrc
autocmd! BufWritePost .vimrc source $MYVIMRC | :PowerlineReloadColorscheme
" Go to last position
autocmd! BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Highlight the currently active file in NERDTree
" autocmd BufEnter * if &modifiable | NERDTreeFind | wincmd p | endif
" Fugative mappings
nmap <leader>gb :Gblame<CR>
nmap <leader>gs :Gstatus<CR>
nmap <leader>gd :Gdiff<CR>
nmap <leader>gl :Glog<CR>
nmap <leader>gc :Gcommit<CR>
nmap <leader>gp :Git push<CR>
nmap <leader>gg :Ggrep <cword><CR>
autocmd QuickFixCmdPost *grep* nested cwindow
nmap <leader>c :TagbarToggle<CR>
nmap <leader>n :NERDTreeToggle<CR>
nmap <leader>a :Ack<CR>
nmap <leader>s :AckFromSearch<CR>
nmap <Leader>v :e $MYVIMRC<cr>
let g:ctrlp_working_path_mode = 'a'
let g:ragtag_global_maps=1
let g:syntastic_ruby_exec=substitute(system('rbenv which ruby | sed "s/versions\/[^\/]*/versions\/$(rbenv global)/"'), '\n$', '', '')
syntax on " Enable syntax highlighting
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
" Damn you python!
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd Filetype cf setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
" json is javascript
autocmd BufNewFile,BufRead *.json set filetype=javascript
autocmd BufNewFile,BufRead Bombfile set filetype=ruby
set cf " Enable error files & error jumping.
" set clipboard+=unnamed " Yanks go on clipboard instead.
set hid
set history=512 " Number of things to remember in history.
set undolevels=512 " Number of things to remember for undo.
set autowrite " Writes on make/shell commands
set ruler " Ruler on
set number " Line numbers on
" set nowrap " Line wrapping off
set timeoutlen=2000
set ttimeout
set ttimeoutlen=250 " Time to wait after ESC (default causes an annoying delay)
let g:inkpot_black_background=0
colorscheme inkpot
"colorscheme Tomorrow-Night-Eighties
set colorcolumn=81
highlight ColorColumn ctermbg=darkgrey guibg=#2e2e3f
" Formatting (some of these are for coding in C and C++)
set ts=2 " Tabs are 2 spaces
set sts=2 " softtabwidth, backspace over tabs
set sw=2 " Tabs under smart indent
set expandtab
set bs=2 " Backspace over everything in insert mode
set incsearch
set hls
set ignorecase
set smartcase
"set cinoptions=:0,p0,t0
"set cinwords=if,else,while,do,for,switch,case
"set cinkeys-=0#
"set indentkeys-=0#
"set formatoptions=tcqr
"set cindent
"set smartindent
set autoindent
" Visual
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
" set list
" Show $ at end of line and trailing space as ~
" set lcs=tab:\ \ ,eol:$,trail:~,extends:>,precedes:<
set novisualbell " No blinking .
set noerrorbells " No noise.
set laststatus=2 " Always show status line.
" gvim specific
set mousehide " Hide mouse after chars typed
set mouse=a " Mouse in all modes
" Backups & Files
set backup " Enable creation of backup file.
set backupdir=~/.vim/backups// " Where backups will go.
set directory=~/.vim/tmp// " Where temporary files will go.
"set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
set sessionoptions=blank,buffers,curdir,folds,globals,help,localoptions,options,resize,tabpages,winsize,winpos
"if has("gui_running")
" au VimLeave * mksession ~/.vim/macvimsession
" au VimEnter * source ~/.vim/macvimsession
"end
" Autoreload dos format for mixed line-ending
autocmd BufReadPost * nested
\ if !exists('b:reload_dos') && !&binary && &ff=='unix' && (0 < search('\r$', 'nc')) |
\ let b:reload_dos = 1 |
\ e ++ff=dos |
\ endif
function! HandleURI()
let s:uri = matchstr(getline("."), "[a-z]*:\/\/[^ \"'>,;]*")
if s:uri != ""
silent! exec "!open '" . s:uri . "'"
else
echo "No URI found in line."
endif
endfunction
map <silent> <Leader>w :call HandleURI()<CR>
function! HtmlEscape()
silent! s/&/\&amp;/ge
silent! s/</\&lt;/ge
silent! s/>/\&gt;/ge
endfunction
function! HtmlUnEscape()
silent! s/&lt;/</ge
silent! s/&gt;/>/ge
silent! s/&amp;/\&/ge
silent! s/&quot;/"/ge
" URL unescape (let do it all for now)
silent! s/%\(\x\{2\}\)/\=nr2char(('0x'.submatch(1))+0)/ge
endfunction
map <silent> <Leader>]h :call HtmlEscape()<CR>
map <silent> <Leader>]u :call HtmlUnEscape()<CR>
map <silent> <Leader>]j !python -mjson.tool<CR>
#!/usr/bin/env ruby
# Place in ~/.vim and chmod +x
require 'fileutils'
plugins = %w(
Lokaltog/vim-powerline
MarcWeber/vim-addon-mw-utils
ap/vim-css-color
ciaranm/securemodelines
coryf/vim-pathogen-tomorrow-theme
garbas/vim-snipmate
honza/snipmate-snippets
jeetsukumaran/vim-buffergator
kchmck/vim-coffee-script
kien/ctrlp.vim
majutsushi/tagbar
mattn/gist-vim
mileszs/ack.vim
nono/vim-handlebars
scrooloose/nerdtree
scrooloose/syntastic
sjl/splice.vim~
skalnik/vim-vroom
tomtom/tlib_vim
tpope/vim-bundler
tpope/vim-commentary
tpope/vim-endwise
tpope/vim-eunuch
tpope/vim-fugitive
tpope/vim-git
tpope/vim-haml
tpope/vim-liquid
tpope/vim-markdown
tpope/vim-pathogen
tpope/vim-ragtag
tpope/vim-rails
tpope/vim-repeat
tpope/vim-rvm~
tpope/vim-speeddating
tpope/vim-surround
tpope/vim-unimpaired
vim-scripts/vcscommand.vim
vim-scripts/VimClojure
)
extra_cmds = {
}
bundle_dir = File.join(File.dirname(__FILE__), "bundle")
tmp_dir = File.join(File.dirname(__FILE__), "tmp")
backups_dir = File.join(File.dirname(__FILE__), "backups")
FileUtils.mkdir_p(tmp_dir)
FileUtils.mkdir_p(backups_dir)
FileUtils.mkdir_p(bundle_dir)
Dir.chdir(bundle_dir)
def runcmd(cmd)
puts cmd
system cmd
end
if ARGV.length > 0
filter = ARGV
end
plugins.each do |plugin|
if plugin =~ /^(.*)~$/ # support plugin disabled
plugin_disabled = true
plugin = $1
end
plugin_author, plugin_name = *plugin.split('/')
next if filter && (!filter.include?(plugin) && !filter.include?(plugin_name))
puts "#{'[disabled] ' if plugin_disabled}#{plugin}"
plugin_dir = plugin_name
plugin_dir += '~' if plugin_disabled
url = "https://github.com/#{plugin}.git"
if plugin_disabled
enabled_dir = plugin_name
FileUtils.mv enabled_dir, plugin_dir if File.exists?(enabled_dir)
else
disabled_dir = "#{plugin_dir}~"
FileUtils.mv disabled_dir, plugin_dir if File.exists?(disabled_dir)
end
if File.exists?(plugin_dir)
Dir.chdir(plugin_dir) { runcmd "git pull" }
else
runcmd "git clone #{url} #{plugin_dir}"
end
if cmds = extra_cmds[plugin_name]
Dir.chdir(plugin_dir) do
cmds.each { |cmd| runcmd cmd }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment