Major Refactored vim config.

There's a lot of cruft built up over my years of using vim & with the
introduction of Doom Emacs what I use vim for has gotten more pointed as
well. Vim now services as a quick in and out tool for dropping to the
commandline on local or remote machines.

So quick rundown on changes.

- Removed weird hallow sourcing in vimrc
- Removed unused or under used Plugs.
- Switched from ctrl+p to fzf.
- Switched to ALE for linting and formatting
- Configuration and keybinds now lives with the Plugs. Intended one
  level under it.
- The large boilerplate sane default file has been extracted into
  sensible.vim. This based on tpope's config.
- Make will no longer symlink .dotfile/vim to ~/.vim. This was causing
  lots of unversioned cruff to pile up in the project. Instead it will
  now symlink all the things needed.
- Make update will now run PlugClean as well.
This commit is contained in:
James Patrick 2021-07-20 14:47:54 -04:00
parent df0981745d
commit 8bce4295c8
12 changed files with 337 additions and 314 deletions

View File

View File

2
vim/ftplugin/json.vim Normal file
View File

@ -0,0 +1,2 @@
com! FormatJSON :%!python3 -m json.tool
map <buffer><leader>= :FormatJSON<cr>

6
vim/ftplugin/xml.vim Normal file
View File

@ -0,0 +1,6 @@
let b:ale_fixers = ['xmllint']
let b:ale_fix_on_save = 0
let g:xml_syntax_folding=1
setlocal foldmethod=syntax
autocmd Syntax xml,html,xhtml normal zR

View File

@ -10,8 +10,13 @@ install: | init update
init:
if (( $$+commands[vim] )) ; then
$(report) header "Setting up vim"
$(mk_link) $(SRC_DIR) $(TARGET_DIR)
mkdir -p $(TARGET_DIR)
$(mk_link) $(SRC_DIR)/vimrc ~/.vimrc
$(mk_link) $(SRC_DIR)/vimrc.d $(TARGET_DIR)/vimrc.d
$(mk_link) $(SRC_DIR)/spell $(TARGET_DIR)/spell
( mkdir -p $(TARGET_DIR)/backup \
&& chmod 700 $(TARGET_DIR)/backup ) \
; $(report) "setting up backup dir"
else
$(report) warn "cannot find vim?"
fi
@ -21,7 +26,7 @@ update:
$(report) header "Upgrading vim"
curl -fsLo $(PLUG_PATH) $(PLUG_URL) \
; $(report) "vim plug setup"
vim +PlugInstall +PlugUpdate +qall \
vim +PlugInstall +PlugUpdate +PlugClean +qall \
; $(report) "downloading/updating plugins"
stty sane # dropping in & out causes some weird tty behavior.
else

View File

@ -1,21 +1,21 @@
off
env
Ctrl
zsh
dotfiles
CoffeeScript
Haml
ctag
Ctags
mkdir
tmux
hostname
rebase
rebases
ctags
config
zsh
backend
Ctrl
GreenFiling
Haml
SES
Tybera
GreenFiling
backend
config
ctag
ctags
dotfiles
env
hostname
mkdir
off
rebase
rebases
tmux
zsh
zsh

148
vim/vimrc
View File

@ -1,7 +1,147 @@
source ~/.vim/vimrc.d/base.vim
source ~/.vim/vimrc.d/plugins.vim
source ~/.vim/vimrc.d/ui.vim
source ~/.vim/vimrc.d/keybind.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sections:
" -> Plug Setup
" -> Brief Config
" -> Plugs & Configure
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PlugSetup:
" -> Auto Install Plug
" -> Auto Add Missing Plugs
" -> Add Conditional Helper
" -> Has Async
" Install vim-plug if not found
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
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
" Convenience function for arbitrary conditional loading
" See https://github.com/junegunn/vim-plug/wiki/tips#conditional-activation for more.
function! Cond(cond, ...)
let opts = get(a:000, 0, {})
return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Brief Config:
" -> Sane Config Base
" -> Leader Key
" -> Has Async Var
" Sane Config Based on Tpope's Vim-Sensible
" https://github.com/tpope/vim-sensible
source ~/.vim/vimrc.d/sensible.vim
" Take me to your leader
let mapleader=","
" Added Async Var
let g:has_async = v:version >= 800 || has('nvim')
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugs_Configure:
" -> Molokai Theme
" -> Deoplete Completion Framework
" -> Git Gutter
" -> Rainbow Parens
" -> Auto Pair
" -> Vim Surround
" -> Vim Airline
" -> Vim Eunuch
" -> Nerdtree
" -> Incsearch
" -> EasyMotion
" -> Incsearch + EasyMotion
" -> Fzf
" -> ALE
call plug#begin('~/.vim/plugged')
" Theme
Plug 'tomasr/molokai'
autocmd VimEnter * colorscheme molokai
hi LineNr ctermfg=245 ctermbg=235
let g:molokai_original=1
let g:rehash256=1
match ErrorMsg '\%>120v.\+'
match ErrorMsg '\s\+$'
" Deoplete : Fancy vim8+/nvim autocomplete framework
if (has('python3') || has('nvim'))
Plug 'Shougo/deoplete.nvim'
" completion source
Plug 'Shougo/neco-syntax'
" running on non-nvim instances requires the following
" See https://github.com/Shougo/deoplete.nvim#install for more
Plug 'roxma/nvim-yarp', Cond(! has('nvim'))
Plug 'roxma/vim-hug-neovim-rpc', Cond(! has('nvim'))
let g:deoplete#enable_at_startup=1
endif
" GitGutter : Letting you know whats changed
Plug 'airblade/vim-gitgutter'
" Rainbow Parens : making at color term more useful
Plug 'kien/rainbow_parentheses.vim'
" Auto Pair : Vim plugin, insert or delete brackets, parens, quotes in pair
Plug 'jiangmiao/auto-pairs'
" Vim Surround : quoting/parenthesizing made simple
Plug 'tpope/vim-surround'
" Vim Airline : Modeline support
Plug 'vim-airline/vim-airline'
" Vim Eunuch : Helpers for UNIX
Plug 'tpope/vim-eunuch'
" Nerdtree : A tree explorer plugin for vim.
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Incsearch : Improved incremental searching for Vim
Plug 'haya14busa/incsearch.vim'
" EasyMotion : Vim motions on speed!
Plug 'easymotion/vim-easymotion'
let g:EasyMotion_smartcase = 1
map <Leader>f <Plug>(easymotion-bd-f2)
nmap <Leader>f <Plug>(easymotion-overwin-f2)
" Incsearch & EasyMotion : peanut butter & chocolate
Plug 'haya14busa/incsearch-easymotion.vim'
map / <Plug>(incsearch-easymotion-/)
map ? <Plug>(incsearch-easymotion-?)
map g/ <Plug>(incsearch-easymotion-stay)
" FZF : Fuzzy was he found
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
let g:fzf_layout = { 'down': '40%' }
map <leader><tab> :History<cr>
map <leader>b :Buffers<cr>
" ALE : Asynchronous Lint Engine
Plug 'dense-analysis/ale', Cond(g:has_async)
if g:has_async
map <leader>= :ALEFix<cr>
endif
let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace']}
let g:ale_fix_on_save = 1
let g:ale_completion_enabled = 1
call plug#end()
" vim: set filetype=vim:
" -*- mode: vim -*-

View File

@ -1,72 +0,0 @@
set go=
set t_Co=256
syntax on
filetype plugin indent on
set encoding=utf-8
set hidden
set showcmd
set nowrap
set backspace=indent,eol,start
set autoindent
set number
set shiftround
set ignorecase
set smartcase
set hlsearch
set incsearch
set history=1000
set undolevels=1000
set title
set noerrorbells
set list
set listchars=tab:>>,trail:.,extends:>,precedes:<,nbsp:.
set ttyfast
set mouse=a
set nocompatible
set backup
set noswapfile
set backupdir=~/.vim/backup
set laststatus=2
set fileformats=unix,dos,mac
set expandtab
set softtabstop=2 tabstop=2 shiftwidth=2
set ruler
set cursorline
set cuc cul
set wildmenu
set lazyredraw
set showmatch " highlight matching [{()}]
set wildignore=*.swp,*.bak
set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*
set wildmode=longest,list:full
set linebreak
set nolist " list disables linebreak
set omnifunc=syntaxcomplete#Complete
set dictionary=/usr/share/dict/words
" The Silver Searcher
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
endif
if v:version > 702 && has('patch541')
set formatoptions+=j
endif
let g:has_async = v:version >= 800 || has('nvim')
"" Toggle relative/absolute numbering
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
""
com! FormatJson :%!python3 -m json.tool
com! FormatXML :%!python3 -c "import xml.dom.minidom, sys; print(xml.dom.minidom.parse(sys.stdin).toprettyxml())"

View File

@ -1,93 +0,0 @@
"" Keybinds
let mapleader=","
"" Kill
nnoremap <Leader>kb :BD<cr>
"" Toggles : t for toggle
" Toggle PasteMode
nnoremap <Leader>tp :set invpaste paste?<cr>
" Toggle wordwrap
nnoremap <Leader>tw :set wrap!<CR>
" Toggle Git Gutter :: Requires GitGutter
nnoremap <Leader>tg :GitGutterToggle<cr>
" Toggle Indent :: Requires Yggdroot/indentLine
nnoremap <leader>ti :IndentLinesToggle<cr>
" Tooggle Spell Check
nnoremap <leader>ts :setlocal spell! spelllang=en<CR>
" Toggle Relative Numbers
nnoremap <leader>t# :call NumberToggle()<cr>
" Toggle Syntastic :: Requires scrooloose/syntastic
nnoremap <leader>tc :SyntasticToggleMode<cr>
" Keybind ri
nnoremap <leader>ri :call ri#OpenSearchPrompt(0)<cr> " horizontal split"
nnoremap <leader>rk :call ri#LookupNameUnderCursor()<cr> " keyword lookup"
" vim-test mappings : T for Testing
nnoremap <silent> <Leader>Tt :TestFile<CR>
nnoremap <silent> <Leader>Ts :TestNearest<CR>
nnoremap <silent> <Leader>Tl :TestLast<CR>
nnoremap <silent> <Leader>Ta :TestSuite<CR>
nnoremap <silent> <leader>Tgt :TestVisit<CR>
" Enter for Nerd :: Requires Nerdtree
map <Leader><cr> :NERDTreeToggle<cr>
" Sudo Save :: Requires tpope/vim-eunuch
nnoremap <Leader>W :SudoWrite<cr>
" Quick Format : f for Format
nnoremap <silent> <Leader>fi :normal migg=G`i`
nnoremap <silent> <Leader>fw :FixWhitespace<cr>
vnoremap <silent> <Leader>ft :Tabularize /
nnoremap <silent> <Leader>fT :Tabularize /\zs<LEFT><LEFT><LEFT>
" Set File Type Use : F for Filetype
nnoremap <silent> <Leader>Fm :set filetype=markdown<CR>
nnoremap <silent> <Leader>Fv :set filetype=vim<CR>
nnoremap <silent> <Leader>Frb :set filetype=ruby<CR>
" Tagbar
nmap <F8> :TagbarToggle<CR>
" CTRL-P
map <F3> :CtrlPMRU<cr>
nnoremap <Leader>b :CtrlPBuffer<cr>
" Better Search :: Requires haya14busa/incsearch.vim
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
nnoremap <Space> :
" Better Subsitute :: Requires osyo-manga/vim-over
nnoremap <leader>s :OverCommandLine<CR> %s/
" Format XML
map @@x :%s/<\([^>]\)*>/\r&\r/g<enter>:g/^$/d<enter>vat=
" Switch windows with shift + jikl
nnoremap <S-l> :wincmd l<CR>
nnoremap <S-j> :wincmd j<CR>
nnoremap <S-h> :wincmd h<CR>
nnoremap <S-k> :wincmd k<CR>
" Line Switch
nnoremap <C-j> :m .+1<CR>==
nnoremap <C-k> :m .-2<CR>==
vnoremap <C-j> :m '>+1<CR>gv=gv
vnoremap <C-k> :m '<-2<CR>gv=gv
" Plug Stuff
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>ps :PlugStatus<CR>
" UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
imap <expr><C-k> pumvisible() ? "\<C-y><C-R>=UltiSnips#ExpandSnippet()<CR>" : "\<C-R>=UltiSnips#ExpandSnippet()<CR>"

View File

@ -1,107 +0,0 @@
" ==============================================================================
" PLUGINS
" This
filetype off
"" automatically install new plugs
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 --sync | source $MYVIMRC
endif
"" Start Vim-Plug
call plug#begin('~/.vim/plugged')
"" Cond loading
function! Cond(cond, ...)
let opts = get(a:000, 0, {})
return a:cond ? opts : extend(opts, { 'on': [],'for': [] })
endfunction
" Themes
Plug 'kamwitsta/flatwhite-vim'
Plug 'tomasr/molokai'
" Extensions
Plug 'Shougo/deoplete.nvim' , Cond(g:has_async, { 'on': [] })
Plug 'Shougo/neco-vim' , {'for' : 'vim'}
Plug 'Shougo/neocomplete.vim' , Cond(!g:has_async, { 'on': [] })
Plug 'Shougo/vimproc.vim' , {'do' : 'make'}
Plug 'Yggdroot/indentLine'
Plug 'airblade/vim-gitgutter'
Plug 'bronson/vim-trailing-whitespace'
Plug 'godlygeek/tabular'
Plug 'haya14busa/incsearch.vim'
Plug 'honza/vim-snippets'
Plug 'janko-m/vim-test'
Plug 'jiangmiao/auto-pairs'
Plug 'jpalardy/vim-slime'
Plug 'kien/ctrlp.vim'
Plug 'kien/rainbow_parentheses.vim'
Plug 'majutsushi/tagbar'
Plug 'osyo-manga/vim-over'
Plug 'qpkorr/vim-bufkill' , {'on': 'BD'}
Plug 'rizzatti/dash.vim'
Plug 'roxma/nvim-yarp' , Cond(g:has_async)
Plug 'roxma/vim-hug-neovim-rpc' , Cond(g:has_async)
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree' , { 'on': 'NERDTreeToggle' }
Plug 'scrooloose/syntastic' , Cond(!g:has_async)
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-markdown' , {'for' : 'markdown'}
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'w0rp/ale' , Cond(g:has_async)
for fpath in split(globpath('~/.vim/plug.d/', '*.vim'), '\n')
exe 'source' fpath
endfor
" CTRL-P
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_working_path_mode = 'ra'
if executable('ag')
let g:ctrlp_user_command = 'ag -Q -l --nocolor --hidden -g "" %s'
endif
" VIM-AIRPLAINE
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_theme = 'powerlineish'
set laststatus=2
set ttimeoutlen=50
" RAINBOW_PARENTHESE
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
call plug#end()

161
vim/vimrc.d/sensible.vim Normal file
View File

@ -0,0 +1,161 @@
if exists('g:loaded_sensible') || &compatible
finish
else
let g:loaded_sensible = 'yes'
endif
" lazy for faster redraw
set lazyredraw
" disable vi compatibility
set nocompatible
" set encoding
set encoding=utf-8
" show the full incomplete command at the bottom of screen.
set showcmd
" mouse support
set mouse=a
" enable line numbers
set number
" highlight the cursorline
set cursorline
" and also the column
set cuc cul
" make laggy connections work faster
set ttyfast
" case-insensitive filename completion
set wildignorecase
" allow unsaved hidden buffers
" https://vimtricks.com/p/what-is-set-hidden/
set hidden
" disable wrapping
set nowrap
" round tabs to the nearest tab
set shiftround
" set the tab to match
set autoindent
" when searching ignore case
set ignorecase
" when using case respect it
set smartcase
" highlight results
set hlsearch
"search as you type
set incsearch
" you know what's helpful a ridiculous back button
set history=1000
set undolevels=1000
" user backfile files foften
set backup
set backupdir=~/.vim/backup
" swap files kind of clutter up
set noswapfile
" I get these enough. I don't need more.
set noerrorbells
" always have a status.
set laststatus=2
" tab logic
set expandtab
set softtabstop=2 tabstop=2 shiftwidth=2
" add tab completion for commands
" https://vim.fandom.com/wiki/Great_wildmode/wildmenu_and_console_mouse
set wildmode=list:longest,full
" highlight matching [{()}]
set showmatch
" spellnig mattears.
set dictionary=/usr/share/dict/words
" ag isn't grep but it is faster.
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
endif
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
" backspace cross the following
set backspace=indent,eol,start
set complete-=i
set smarttab
set nrformats-=octal
if !has('nvim') && &ttimeoutlen == -1
set ttimeout
set ttimeoutlen=100
endif
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
if !&scrolloff
set scrolloff=1
endif
if !&sidescrolloff
set sidescrolloff=5
endif
set display+=lastline
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
" Delete commment characters when joining comment lines
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
" max tab count
if &tabpagemax < 50
set tabpagemax=50
endif
if !empty(&viminfo)
set viminfo^=!
endif
set sessionoptions-=options
set viewoptions-=options
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^Eterm'
set t_Co=16
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
" vim:set ft=vim et sw=2:

View File

@ -1,19 +0,0 @@
"" GUI
if has('gui_macvim')
let macvim_skip_colorscheme = 1
colorscheme flatwhite
set lines=60 columns=108 linespace=0
set guifont=Source\ Code\ Pro\ for\ Powerline:h10
else
set background=dark
let g:molokai_original=1
let g:rehash256=1
set t_Co=256
colorscheme molokai
hi LineNr ctermfg=245 ctermbg=235
endif
"" Error Message
match ErrorMsg '\%>120v.\+'
match ErrorMsg '\s\+$'