summaryrefslogtreecommitdiff
path: root/vimrc
blob: 504d205707fd317d3ce01fb7ba6e18e77cabaaac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
" General {{{1
set nocompatible
let g:use_dvorak = 1
let g:leave_my_cursor_position_alone = ''
let PHP_vintage_case_default_indent = 1
let c_no_comment_fold = 1
set fileformats=unix,dos,mac
set spelllang=en_us
set switchbuf=useopen

" Outsourced functions file
runtime functions.vim

" Colors and Syntax {{{1
set t_Co=16
set background=dark
colorscheme solarized
if has('syntax') && !exists('g:syntax_on')
	syntax enable
endif

" Plugin-Specific {{{1
" Use vim-plug
call plug#begin('~/.vim/bundle')
Plug 'tpope/vim-commentary', { 'as': 'commentary' }
Plug 'tpope/vim-fugitive', { 'as': 'fugitive' }
Plug 'jamessan/vim-gnupg', { 'as': 'gnupg' }
Plug 'junegunn/goyo.vim', { 'as': 'goyo' }
Plug 'ledger/vim-ledger', { 'as': 'ledger' }
Plug 'rstacruz/sparkup'
Plug 'godlygeek/tabular'
Plug 'PotatoesMaster/i3-vim-syntax', { 'as': 'i3-syntax' }
Plug 'justinj/vim-pico8-syntax', { 'as': 'pico8-syntax' }
Plug 'evanrelf/vim-pico8-color', { 'as': 'pico8-color' }
Plug 'altercation/vim-colors-solarized', { 'as': 'solarized-color' }
call plug#end()

" Formatting {{{1
set formatprg=par-format\ w80
set printoptions=paper:letter,top:0.5in,left:0.5in,right:0.5in,bottom:0.5in,syntax:n,header:0
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set formatoptions=tcqn

" Usability {{{1
set whichwrap=<,>,[,],h,l
set scrolloff=2
set backspace=indent,eol,start
set ttimeout
set ttimeoutlen=50
set timeoutlen=3000
set incsearch
set number
set numberwidth=5
set hidden
set mouse=n

" Interface {{{1
set display+=lastline
" I changed my mind... a toggle is best
set nolist
"set listchars=tab:⇥\ ,trail:␣,extends:⇉,precedes:⇇,nbsp:⚭
if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8'
	let &listchars = "tab:\u21e5 ,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad"
else
	set listchars=tab:>\ ,extends:>,precedes:<,nbsp:+
endif
set splitright
set splitbelow
set laststatus=2
" Example: (1) .vimrc [vim][+] 48,22 123L 0x20
set statusline=(%n)\ %f\ %y%r%m\ %l,%v\ %LL\ 0x%B
set fillchars=fold:\ ,vert:\|
set wrap
set linebreak

" Anti-Annoyance {{{1
set nostartofline
set novisualbell
set noautoindent

" Folding {{{1
set foldmethod=expr
set foldtext=MyFoldText()

" Autocommands {{{1
if has("autocmd")
	filetype plugin indent on
	autocmd BufNewFile,BufRead /media/sd/Games/*.[0123456789].txt setfiletype sctxt
	autocmd BufNewFile,BufRead *.txt setfiletype text
	" All Markdown and TXT files need to be hard wrapped to 80 characters.
	autocmd FileType text,markdown setlocal nonumber tabstop=4 softtabstop=4 shiftwidth=4 expandtab formatoptions=tcqwn textwidth=80 nolist colorcolumn=81
	autocmd FileType python setlocal expandtab
	autocmd BufNewFile,BufRead *.ledger setlocal nonumber iskeyword+=: filetype=ledger
	autocmd FileType help setlocal colorcolumn=0
	autocmd FileType vim setlocal keywordprg=:help
	autocmd FileType c setlocal foldmethod=syntax
	" Needed for game guides on the SuperCard DSTWO; this is also true of
	" homebrew apps that use monospace fonts at normal scale. The DSTWO throws
	" up on linebreaks if it's not DOS, iso8859-1 text. The limit is set to
	" allow for a character or two that might be wider than an M or W.
	autocmd FileType sctxt setlocal enc=latin1 ff=dos tw=30 cc=31 fo=tcqwn nolist et ts=4 sts=4 sw=4
	" vim -b : edit binary using xxd-format!
	augroup Binary
	  au!
	  au BufReadPre  *.pal let &bin=1
	  au BufReadPost *.pal if &bin | %!xxd
	  au BufReadPost *.pal set ft=xxd | endif
	  au BufWritePre *.pal if &bin | %!xxd -r
	  au BufWritePre *.pal endif
	  au BufWritePost *.pal if &bin | %!xxd
	  au BufWritePost *.pal set nomod | endif
	augroup END
endif

" Key Bindings {{{1
nnoremap <leader>i :call <SID>SynStack()<CR>
nnoremap <leader>l :set list!<CR>
nnoremap <leader>n :set number!<CR>
nnoremap <leader>t :setfiletype text<CR>
nnoremap <leader>s :set spell!<CR>
nnoremap <leader>c :call <SID>CountCodeLines()<CR>
nnoremap <leader>d :call <SID>InsertDOW()<CR>
nnoremap <leader>D "=strftime("%Y-%m-%d %H:%M", localtime())<CR>p
nnoremap <Space> za
nnoremap <silent> <F5> :call <SID>StripTrailingWhitespaces()<CR>

" Thanks to /u/spupy for these short and sweet mappings that replace the
" simpler functions of tpope's surround.vim plugin. Each of these will
" surround the current (or last) visual selection with the specified 
" character.
noremap <Leader>w" <ESC>`>a"<ESC>`<i"<ESC>
noremap <Leader>w' <ESC>`>a'<ESC>`<i'<ESC>
noremap <Leader>w( <ESC>`>a)<ESC>`<i(<ESC>
noremap <Leader>w[ <ESC>`>a]<ESC>`<i[<ESC>
noremap <Leader>w{ <ESC>`>a}<ESC>`<i{<ESC>
noremap <Leader>w< <ESC>`>a><ESC>`<i<<ESC>
noremap <Leader>w` <ESC>`>a`<ESC>`<i`<ESC>

" super handy over SSH
noremap <Leader>q :call SwapKeys()<CR>


" Dvorak Hackery {{{1
if exists("g:use_dvorak") && g:use_dvorak == 1
	silent call SetKeyMap()
endif

" vim: foldmethod=marker