Created
February 5, 2018 15:15
-
-
Save jeffcasavant/2a2b65c9642c9dc8e1015d2e689ef827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Plugins list | |
" Vundle required settings | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
""" Functionality | |
" Unicode menu | |
Plugin 'chrisbra/unicode.vim' | |
" Editorconfig file support | |
Plugin 'editorconfig/editorconfig-vim' | |
" Plugin manager | |
Plugin 'gmarik/Vundle.vim' | |
" Vertical alignment | |
Plugin 'godlygeek/tabular' | |
" Lightline | |
Plugin 'itchyny/lightline.vim' | |
" Fuzzy finding with buffers | |
Plugin 'junegunn/fzf.vim' | |
" Distraction-free writing | |
Plugin 'junegunn/goyo.vim' | |
" Comment/uncomment with g-c | |
Plugin 'tpope/vim-commentary' | |
" Asynchronously run linters | |
Plugin 'w0rp/ale' | |
" Display git status on the side | |
" Plugin 'airblade/vim-gitgutter' | |
" Use git within vim | |
" Plugin 'tpope/vim-fugitive' | |
" GitHub extensions for fugitive | |
" Plugin 'tpope/vim-rhubarb' | |
""" Syntax highlighting | |
" Good chunk of syntax highlighters loaded on demand | |
Plugin 'sheerun/vim-polyglot' | |
" Stuff that's not included in polyglot | |
Plugin 'Glench/Vim-Jinja2-Syntax' | |
Plugin 'markcornick/vim-vagrant' | |
Plugin 'vim-scripts/ferm.vim' | |
""" Visual | |
" Sublime text colorscheme | |
Plugin 'tomasr/molokai' | |
call vundle#end() | |
filetype plugin indent on | |
""" Soft tabs | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
" change tabwidth for JS | |
au FileType javascript setl tabstop=2 shiftwidth=2 softtabstop=2 expandtab et | |
""" Visual configuration | |
" 256-color support | |
set t_Co=256 | |
" Syntax highligting on | |
syntax on | |
colorscheme molokai | |
" Line number on current line only; relative on others | |
set number | |
set relativenumber | |
" Highlight search results | |
set showmatch | |
" lightline on | |
set laststatus=2 | |
" Highlight JSX within all JS files | |
let g:jsx_ext_required = 0 | |
""" UTF-8 | |
if has("multi_byte") | |
if &termencoding == "" | |
let &termencoding = &encoding | |
endif | |
set encoding=utf-8 | |
setglobal fileencoding=utf-8 | |
"setglobal bomb | |
set fileencodings=ucs-bom,utf-8,latin1 | |
endif | |
""" Optimization | |
set lazyredraw | |
""" Persistent undo | |
set undofile | |
" Be sure to create this directory | |
set undodir=$HOME/.vim/undo | |
""" Read all kinds of shit with Pandoc | |
autocmd BufReadPre *.doc,*.docx,*.rtf,*.odp,*.odt silent set ro | |
autocmd BufReadPost *.doc,*.docx,*.rtf,*.odp,*.odt silent %!pandoc "%" -tplain -o /dev/stdout | |
""" Read PDFs with pdfminer/pdf2txt | |
autocmd BufReadPre *.pdf silent set ro | |
autocmd BufReadPost *.pdf silent %!pdf2txt "%" | |
""" Distraction free writing | |
function! ProseMode() | |
call goyo#execute(0, []) | |
set spell noci nosi noai nolist noshowmode noshowcmd | |
set complete+=s | |
set bg=light | |
endfunction | |
command! ProseMode call ProseMode() | |
""" Lightline support for ALE | |
let g:lightline = { | |
\ 'active': { | |
\ 'right': [ [ 'lineinfo' ], | |
\ [ 'percent' ], | |
\ [ 'linter_warnings', 'linter_errors', 'linter_ok' ], | |
\ [ 'fileformat', 'fileencoding', 'filetype' ] ] | |
\ }, | |
\ 'component_expand': { | |
\ 'linter_warnings': 'LightlineLinterWarnings', | |
\ 'linter_errors': 'LightlineLinterErrors', | |
\ 'linter_ok': 'LightlineLinterOK' | |
\ }, | |
\ 'component_type': { | |
\ 'linter_warnings': 'warning', | |
\ 'linter_errors': 'error', | |
\ 'linter_ok': 'ok' | |
\ }, | |
\ } | |
autocmd User ALELint call lightline#update() | |
function! LightlineLinterWarnings() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? '' : printf('%d --', all_non_errors) | |
endfunction | |
function! LightlineLinterErrors() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? '' : printf('%d >>', all_errors) | |
endfunction | |
function! LightlineLinterOK() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? '✓' : '' | |
endfunction | |
""" Shortcuts | |
" Force write | |
cmap w!! w !sudo tee % >/dev/null | |
" Vert align on equals | |
cmap t= Tabularize /^[^=]*\zs= | |
" Fuzzy find in open buffers | |
nmap ; :Buffers<CR> | |
" Turn on distraction-free writing mode | |
nmap \p :ProseMode<CR> | |
" ctrl-j and k to move between ALE errors | |
nmap <silent> <C-k> <Plug>(ale_previous_wrap) | |
nmap <silent> <C-j> <Plug>(ale_next_wrap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment