Created
June 25, 2021 14:19
-
-
Save jeffcasavant/d6f7299ba6353659393126472c909a9f 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' | |
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' | |
" Have access to some Kubernetes commands from Vim | |
Plugin 'andrewstuart/vim-kubernetes' | |
" Better handling for fancy chars | |
Plugin 'tpope/vim-characterize' | |
" Strip whitespace on end of changed lines only | |
" Plugin 'axelf4/vim-strip-trailing-whitespace' | |
" Change case style automatically | |
Plugin 'icatalina/vim-case-change' | |
" NginX hbetter handling | |
Plugin 'chr4/nginx' | |
" Autoformat command for non-covered usecases | |
Plugin 'Chiel92/vim-autoformat' | |
" Context sticks to the top of the frame on scroll | |
Plugin 'wellle/context.vim' | |
""" Syntax highlighting | |
" Good chunk of syntax highlighters loaded on demand | |
Plugin 'sheerun/vim-polyglot' | |
" Stuff that I'd prefer the official version of rather than Polyglot's | |
Plugin 'rust-lang/rust.vim' | |
Plugin 'pearofducks/ansible-vim' | |
Plugin 'towolf/vim-helm' | |
" Stuff that's not included in polyglot | |
Plugin 'Glench/Vim-Jinja2-Syntax' | |
Plugin 'markcornick/vim-vagrant' | |
Plugin 'vim-scripts/ferm.vim' | |
Plugin 'maxmellon/vim-jsx-pretty' | |
Plugin 'saltstack/salt-vim' | |
""" Visual | |
" Sublime text colorscheme | |
Plugin 'tomasr/molokai' | |
" Gruvbox colorscheme | |
Plugin 'morhetz/gruvbox' | |
" Purple synthwave colorscheme | |
Plugin 'yassinebridi/vim-purpura' | |
call vundle#end() | |
filetype plugin indent on | |
""" Soft tabs | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
""" FZF | |
" use ripgrep | |
let $FZF_DEFAULT_COMMAND = 'rg --files' | |
let g:fzf_layout = { 'window': { 'width': 1, 'height': 0.4, 'yoffset': 1, 'border': 'horizontal' } } | |
""au FileType javascript setl tabstop=2 shiftwidth=2 softtabstop=2 expandtab et | |
au FileType terraform setl tabstop=2 shiftwidth=2 softtabstop=2 expandtab et | |
au FileType typescript setl tabstop=2 shiftwidth=2 softtabstop=2 expandtab et | |
au FileType ansible set filetype=yaml.ansible | |
au FileType Jenkinsfile set autoindent | |
"au FileType terraform setl tabstop=2 shiftwidth=2 softtabstop=2 expandtab et | |
""" Autoformat | |
let g:ale_fix_on_save = 1 | |
let g:ale_fixers = {} | |
let g:ale_fixers['*'] = ['remove_trailing_lines'] | |
let g:ale_fixers['hcl'] = ['terraform'] | |
" let g:ale_fixers['html'] = ['prettier'] | |
let g:ale_fixers['javascript'] = ['eslint'] | |
let g:ale_fixers['json'] = ['jq'] | |
let g:ale_fixers['python'] = ['isort', 'black'] ", 'reorder-python-imports'] | |
let g:ale_fixers['rust'] = ['rustfmt'] | |
let g:ale_fixers['scss'] = ['prettier'] | |
let g:ale_fixers['sh'] = ['shfmt'] | |
let g:ale_fixers['terraform'] = ['terraform'] | |
let g:ale_fixers['terragrunt'] = ['terragrunt'] | |
let g:ale_fixers['typescript'] = ['prettier'] | |
let g:ale_fixers['yaml'] = ['prettier'] | |
let g:ale_javascript_prettier_options = '--tab-width 2 --print-width 120 --single-quote' | |
" let g:ale_json_jq_options = '-S' | |
let g:ale_linters = {'rust': ['rls', 'cargo']} | |
let g:ale_python_black_options = '--line-length 120' | |
let g:ale_python_reorder_python_imports_options = '--py3-plus' | |
let g:ale_python_pylint_options = '--max-line-length 120' | |
""" Visual configuration | |
" 256-color support | |
set t_Co=256 | |
set t_ut= | |
" Syntax highlighting on | |
syntax on | |
" Colorscheme settings | |
if v:version >= 800 | |
set termguicolors | |
endif | |
set background=dark | |
let g:gruvbox_bold = 1 | |
let g:gruvbox_italic = 1 | |
let g:gruvbox_underline = 1 | |
let g:gruvbox_undercurl = 1 | |
colorscheme gruvbox | |
" colorscheme purpura | |
" 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 | |
" Ansible YAML config | |
let g:ansible_unindent_after_newline = 1 | |
let g:ansible_attribute_highlight = 'ab' | |
let g:ansible_name_highlight = 'd' | |
let g:ansible_extra_keywords_highlight = 1 | |
""" 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 | |
""" Backspace in insert mode | |
set backspace=2 | |
""" 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 config | |
let g:lightline = { | |
\ 'colorscheme': 'one', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ], | |
\ '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' | |
\ }, | |
\ 'component_function': { | |
\ 'gitbranch': 'fugitive#head' | |
\ }, | |
\ } | |
autocmd User ALELint call s:conditional_update_lightline() | |
function! s:conditional_update_lightline() | |
if exists("#lightline") | |
call lightline#update() | |
endif | |
endfunction | |
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 | |
cmap t= Tabularize /^[^=]*\zs= | |
cmap t' Tabularize /^[^']*\zs' | |
" Fuzzy find | |
nmap ; :Buffers<CR> | |
nmap <c-p> :Files<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) | |
" Disable ALE autoformat | |
cmap setnoform let g:ale_fix_on_save=0 | |
cmap setform let g:ale_fix_on_save=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment