Skip to content

Instantly share code, notes, and snippets.

@bleggett
Last active March 26, 2016 14:15
Show Gist options
  • Save bleggett/aa20f5e77ac8c745496c to your computer and use it in GitHub Desktop.
Save bleggett/aa20f5e77ac8c745496c to your computer and use it in GitHub Desktop.
"Use gist-vim to save vimrc.
"GistID: aa20f5e77ac8c745496c
"Fix runtimepath on windows so it's the same as on *nix, so I don't have to
"fiddle with path conditionals.
if has('win32') || has('win64')
set runtimepath=$USERPROFILE/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
if empty(glob('~/.vim/autoload/plug.vim'))
"DOESN'T WORK, DANGED WINDOWS
silent !curl -fLo %USERPROFILE%/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
else
"Try to pull down vim-plug on startup if it's not there.
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
endif
"Because it's 2015
set nocompatible
"--------------------------------------------------------------------------------
"vim-plug build functions
"--------------------------------------------------------------------------------
function! BuildVimProc(info)
" info is a dictionary with 3 fields
" - name: name of the plugin
" - status: 'installed', 'updated', or 'unchanged'
" - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
if has('win64')
!mingw32-make.exe -f make_mingw64.mak
else
!make
endif
endif
endfunction
"--------------------------------------------------------------------------------
"Plugins
"--------------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
Plug 'Raimondi/delimitMate'
Plug 'scrooloose/syntastic'
Plug 'tomtom/tcomment_vim'
Plug 'tomasr/molokai'
Plug 'mbbill/fencview'
Plug 'itchyny/lightline.vim'
Plug 'bling/vim-bufferline'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'exvim/ex-showmarks'
Plug 'littleq0903/vim-tsql'
Plug 'scrooloose/nerdtree', {'on': ['NERDTree', 'NERDTreeToggle']}
Plug 'Chiel92/vim-autoformat', {'do': 'npm install js-beautify -g'}
Plug 'mattn/webapi-vim' | Plug 'mattn/gist-vim'
Plug 'KabbAmine/gulp-vim'
Plug 'dzeban/vim-log-syntax', {'for': 'log'}
Plug 'PProvost/vim-ps1', {'for': 'ps1' }
Plug 'othree/yajs.vim', {'for': 'javascript'}
Plug 'OrangeT/vim-csharp', {'for': 'cs'}
Plug 'groenewege/vim-less', {'for': 'less' }
Plug 'hail2u/vim-css3-syntax', {'for': 'css' }
Plug 'othree/html5.vim', {'for': 'html'}
Plug 'Valloric/YouCompleteMe', { 'for': ['typescript', 'javascript', 'cs'], 'do': 'python install.py --tern-completer' }
autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif
Plug 'leafgarland/typescript-vim', {'for': 'typescript' }
Plug 'elzr/vim-json', {'for': 'json'}
call plug#end()
"--------------------------------------------------------------------------------
"Plugin options
"--------------------------------------------------------------------------------
"tsql options
let g:sql_type_default = "sqlserver"
"syntastic options
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_check_on_w = 1
let g:syntastic_javascript_checkers = ['eslint']
"Jump to Next Error shortcut
nmap <silent> <leader>ne :ll<CR>
"ex-showmarks options
let g:showmarks_enable = 1
let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
" Ignore help, quickfix, non-modifiable buffers
let showmarks_ignore_type = "hqm"
" Hilight lower & upper marks
let showmarks_hlline_lower = 1
let showmarks_hlline_upper = 0
"Lightline/bufferline options
set laststatus=2
set noshowmode
set autoread
let g:bufferline_echo = 0
let g:bufferline_active_buffer_left = '|'
let g:bufferline_active_buffer_right = '|'
let g:bufferline_modified = '*'
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'filename' ], ['bufferline'] ],
\ },
\ 'component': {
\ 'bufferline': '%{bufferline#refresh_status()}%{g:bufferline_status_info.before}'.
\ '%#TabLineSel#%{g:bufferline_status_info.current}'.
\ '%#LightLineLeft_active_3#%{g:bufferline_status_info.after}'
\ },
\ 'component_function': {
\ 'bufferline': 'MyBufferline'
\ }
\ }
function! MyBufferline()
call bufferline#refresh_status()
let b = g:bufferline_status_info.before
let c = g:bufferline_status_info.current
let a = g:bufferline_status_info.after
let alen = strlen(a)
let blen = strlen(b)
let clen = strlen(c)
let w = winwidth(0) * 4 / 9
if w < alen+blen+clen
let whalf = (w - strlen(c)) / 2
let aa = alen > whalf && blen > whalf ? a[:whalf] : alen + blen < w - clen || alen < whalf ? a : a[:(w - clen - blen)]
let bb = alen > whalf && blen > whalf ? b[-(whalf):] : alen + blen < w - clen || blen < whalf ? b : b[-(w - clen - alen):]
return (strlen(bb) < strlen(b) ? '...' : '') . bb . c . aa . (strlen(aa) < strlen(a) ? '...' : '')
else
return b . c . a
endif
endfunction
"vim-gist options
let g:gist_post_private = 1
let g:gist_update_on_write = 1
"CtrlP options
let g:ctrlp_switch_buffer = 'Et'
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_show_hidden = 1
map <silent> <c-m> :CtrlPMRU<CR>
map <silent> <c-b> :CtrlPBuffer<CR>
"NERDtree options
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeHijackNetrw=1
"YouCompleteMe options
nmap <silent> <leader>nf :cn<CR>
nmap <silent> <leader>pf :cp<CR>
nmap <silent> <leader>gd :YcmCompleter GoToDefinition<CR>
nmap <silent> <leader>gi :YcmCompleter GoToImplementation<CR>
nmap <silent> <leader>gr :YcmCompleter GoToReferences<CR>
nmap <silent> <leader>gt :YcmCompleter GetType<CR>
" nmap <silent> <leader>rn :RefactorRename exec '.input("Rename to: ")'<CR>
"--------------------------------------------------------------------------------
"General VIM opts
"--------------------------------------------------------------------------------
filetype plugin indent on
set nobackup
set autochdir
syntax enable
set ignorecase
set smartcase
"Enable the evil MSWin mode...
source $VIMRUNTIME/mswin.vim
behave mswin
"..before disabling most of the annoying bits we don't want.
set keymodel-=stopsel
set selectmode=""
unmap <C-V>
"This is apparently needed to get non-fussy shared clipboard
set clipboard=unnamed
"--------------------------------------------------------------------------------
"GUI Look&Feel
"--------------------------------------------------------------------------------
colorscheme molokai
if !has('gui_running')
" set t_Co=256
" set lines=50 columns=175
else
set gfn=Droid\ Sans\ Mono:h11
if has('win32') || has('win64')
"Fullscreen on start for Windows
au GUIEnter * simalt ~x
"Fancy font rendering on Windows
set rop=type:directx,gamma:1.0,contrast:0.5,level:1,geom:1,renmode:4,taamode:1
else
"Fake fullscreen for other platforms
set lines=999 columns=9999
endif
set guioptions-=T
set encoding=utf8
"These are all annoying, nop them.
map <MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>
map <2-MiddleMouse> <Nop>
imap <2-MiddleMouse> <Nop>
map <3-MiddleMouse> <Nop>
imap <3-MiddleMouse> <Nop>
map <4-MiddleMouse> <Nop>
imap <4-MiddleMouse> <Nop>
endif
"--------------------------------------------------------------------------------
"General VIM keybinds
"--------------------------------------------------------------------------------
"Format doc command mappings
map <silent> <C-f> gg=G<C-o><C-o>
imap <silent> <C-f> <ESC> gg=G<C-o><C-o>
"Quick vimrc edit macros
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
"--------------------------------------------------------------------------------
"Indentation
"--------------------------------------------------------------------------------
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
"--------------------------------------------------------------------------------
"Custom filetype defs
"--------------------------------------------------------------------------------
au BufRead,BufNewFile *.targets set filetype=xml
au BufRead,BufNewFile *.proj set filetype=xml
au BufRead,BufNewFile *.ps1 set filetype=ps1
au BufRead,BufNewFile *.wsdl set filetype=xml
au BufRead,BufNewFile *.script set filetype=sql
au BufRead,BufNewFile *.log set filetype=log
au BufRead,BufNewFile Log* set filetype=log
au BufRead,BufNewFile *Log.* set filetype=log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment