thoughts, things, etc. from andrew snow

"sleeper vim", a small but mighty vimrc



If you weren't aware, SpaceVim isn't actually meant to be a permanent mod! okay, maybe it is.

While SpaceVim is great, philisophically it is as odds with the entire spirit of vim. I should state here I am by no means an expert nor even well-versed with vim, but I spend alot of time on the internet, and that means running across alot of rants about vim. For better, for worse, for no reason at all, people have some opinions about what, at first, seems to be something so innocuous it boggles the mind to see the body of work that is related to all things vim.

What I'm trying to say: vim isn't perhaps even a word editor (text editor, sorry) - it's more like a trusty toolbox, the one that isn't bristling with tons of gizmos, or the latest hardware. The toolbox with a big phillips-head, a small one, a hammer that has survived at least one metal barrier, a roll of duct tape, crowbar, and some wd-40. (I'd mention the ratchet but that always depends on if you can find the proper size attachment rolling around in the bottom.)

The beauty of vim is that it can be adjusted to exactly what your needs are. For me, I use it mainly to write these pages. A static site generator converts markdown to HTML, so my vim leans towards being as pleasant as possible when it comes to editing markdown files.

the guts

Without further ado, my vimrc:

" ==============
" Basic Settings
" ==============

set nocompatible                
set backspace=indent,eol,start     
set number                        
set hidden                        
filetype plugin indent on        
set history=100                    
nnoremap ; :
set tabstop=4                
set wrap                    
set linebreak                    
set nolist                        
set textwidth=0                    
set wrapmargin=0
set formatoptions-=t        
set formatoptions+=l

" =============
" vim-plug
" =============

call plug#begin('~/.vim/plugged')
" list plugins below here

Plug 'jeromescuggs/hybrid-operator'
Plug 'jeromescuggs/vim-deus'

Plug 'lilydjwg/colorizer'

" Plug 'tpope/vim-markdown'
Plug 'gabrielelana/vim-markdown'
Plug 'vim-scripts/txt.vim'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-abolish'
Plug 'junegunn/limelight.vim' 
Plug 'junegunn/goyo.vim' 
Plug 'reedes/vim-lexical' 
Plug 'reedes/vim-litecorrect' 

Plug 'scrooloose/nerdtree'
Plug 'ryanoasis/vim-devicons'

Plug 'justinmk/vim-syntax-extra'

Plug 'xolox/vim-misc'
Plug 'xolox/vim-notes'

Plug 'kristijanhusak/vim-carbon-now-sh'

Plug 'reedes/vim-wordy'
Plug 'reedes/vim-pencil'

Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

" end of plugin list
call plug#end()

" ===========================
" Plugins & Filetype settings
" ===========================

  augroup pencil
   autocmd filetype markdown,mkd call pencil#init()
       \ | call lexical#init()
       \ | call litecorrect#init()
       \ | setl spell spl=en_us fdl=4 noru nonu nornu
       \ | setl fdo+=search
  augroup END
 " Pencil / Writing Controls {{{
   let g:pencil#wrapModeDefault = 'soft'
   let g:pencil#textwidth = 74
   let g:pencil#joinspaces = 0
   let g:pencil#cursorwrap = 1
   let g:pencil#conceallevel = 3
   let g:pencil#concealcursor = 'c'
   let g:pencil#softDetectSample = 20
   let g:pencil#softDetectThreshold = 130
 " }}}

" clear autocmds
" :autocmd!

map <C-n> :NERDTreeToggle<CR>

" ===========
" colorscheme
" ===========

" colo hybrid_operator
colo deus

set background=dark
syntax on
syntax enable 
set t_Co=256

" =========
" misc
" =========
set laststatus=2        " Make airline status bar appear all the time

au BufEnter,BufRead,BufNewFile *.page :setlocal filetype=markdown
" au BufEnter,BufRead,BufNewFile *.page :setlocal filetype=md
:autocmd VimEnter * :AirlineRefresh

Certainly not the most elegant vimrc, but it gets the job done.


There's not a lot of emphasis on strict organization here, but I did aim to divide it up into relatively homogenous chunks based on purpose. The sections are:

  • the basics: These are more or less the 'desert island' sixteen lines of config that are commonly held as must-have tweaks to a vanilla vim setup. Effectively, they set up vim in a way that is most familiar to anyone who has used a text editor before - line numbers are enabled in the left gutter, tab stops are set to 4 spaces in width, whitespaces and paragraph/line breaks are hidden from view, and the text is set to wrap around when a sentence goes past the rightmost margin. Obviously this is tuned for writing more than coding, but for things like webpage coding, I don't have to change any of this, and even when I am working on other programs the only thing i might toggle is the line wrap.
  • plugins: Since I came around to vim by way of spacevim, naturally when it came time to setup my plugin ecosystem I cribbed from what I knew. SpaceVim uses vim-plug, so that is what I went with, and when you look at the vimrc I think it's not hard to see why: configuration is as simple as calling the function, and then listing plugins in a simple format: github-username/repository-name. In fact, this is far from the only method you could use. vim-plug handles a variety of methods to remotely access a plugin's code, from designating entire URL's to specifying down to a particular branch or commit of a repository. After you populate a list of plugins, you then end the function with a call. That's that - you simply open vim (and possibly hit the enter key a few times to clear some errors that pop up due to your plugins not actually existing on your local filesystem yet) and execute :PlugInstall, and a pane opens and runs down your plugin list, downloads the necessary code, and you're set.
  • plugin config: below the main vim-plug call, I throw in any commands and code that my plugins might require or benefit from. Here, the bulk of this section is geared towards setting up the pencil plugin, which sets up a workspace that is geared for writing - but goes beyond the basic initial configs and also adds live spellchecking and autocorrect, defines the word wrapping as whole-word (as opposed to simply starting a new line mid-word) and most importantly, lists the filetypes which these settings should be enabled for. This is nice, because it means I can easily hop over and open a .html page for editing without having to first go and disable a bunch of settings that would get in the way of that.
  • misc/aesthetic: the final section is devoted to the visual presentation and defines things like the colorscheme I use, the statusbar mod and what it displays, support for 256colors, etc. This is also where I add custom filetypes. In the rc file, you can see that I defined any file with .page extension to be treated as if it were a markdown file, because using this filetype is a handy way to instruct my static site generator engine on what to render as HTML. any actual .md filetype is ignored, which means i can store drafts in the folder where i intend for them to be published, without having to make sure they aren't rendered out.

TODO: diving into the individual plugins and highlighting their purpose


in progress

  • split vim setup from main dotfiles setup
  • write a script that automatically creates the necessary folder structures, and then copies over the vimrc
  • documentation