home/.vimrc (view raw)
1" _ _ _ _
2"(_)_ __ (_) |___ _(_)_ __ ___
3"| | '_ \| | __\ \ / / | '_ ` _ \
4"| | | | | | |_ \ V /| | | | | | |
5"|_|_| |_|_|\__(_)_/ |_|_| |_| |_|
6
7
8call plug#begin()
9Plug 'jiangmiao/auto-pairs'
10Plug 'airblade/vim-gitgutter'
11Plug 'NerdyPepper/vim-colors-plain', { 'branch': 'duotone' }
12Plug 'dbeniamine/vim-mail'
13Plug 'tpope/vim-surround'
14" plugins for writing {{{
15Plug 'reedes/vim-pencil', { 'for': ['text', 'markdown'] }
16Plug 'plasticboy/vim-markdown', { 'for': ['text', 'markdown'] }
17" }}}
18Plug 'ervandew/supertab'
19Plug 'Clavelito/indent-awk.vim'
20Plug 'wellle/targets.vim'
21Plug 'tpope/vim-rsi'
22Plug 'zah/nim.vim'
23call plug#end()
24
25" indentation
26augroup indents
27 autocmd!
28 autocmd FileType less,css,html setlocal ts=2 sts=2 sw=2 expandtab
29 autocmd FileType text,markdown setlocal expandtab
30 autocmd FileType rgbds setlocal autoindent
31augroup END
32
33augroup restorecursor
34 autocmd BufReadPost *
35 \ if line("'\"") > 1 && line("'\"") <= line("$") |
36 \ execute "normal! g`\"" |
37 \ endif
38augroup END
39
40" basic settings
41set swapfile
42set dir=/tmp
43set nonumber
44set smartcase
45syntax on
46filetype plugin indent on
47set laststatus=2
48set hlsearch
49set incsearch
50set ignorecase
51set scrolloff=12
52set rtp+=~/.fzf
53set timeout timeoutlen=3000 ttimeoutlen=100
54set undodir=~/.vim/undodir
55set nowrap
56set nocursorline
57set nofoldenable
58set conceallevel=2
59set mouse=a
60set wildmenu
61set shiftwidth=4 " indent = 4 spaces
62set tabstop=4 " tab = 4 spaces
63set expandtab
64set softtabstop=4 " backspace through spaces
65set nocompatible
66set noshowmode
67set clipboard=unnamedplus
68
69" wildcard ignores
70set wildignore+=.git,.hg,.svn
71set wildignore+=*.aux,*.out,*.toc
72set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class
73set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp
74set wildignore+=*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg
75set wildignore+=*.mp3,*.oga,*.ogg,*.wav,*.flac
76set wildignore+=*.eot,*.otf,*.ttf,*.woff
77set wildignore+=*.doc,*.pdf,*.cbr,*.cbz
78set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb
79set wildignore+=*.swp,.lock,.DS_Store,._*
80
81" colorscheme
82colorscheme plain
83set background=dark
84
85" keybindings
86let mapleader=' '
87nnoremap <leader><esc> :nohlsearch<cr>
88nnoremap <leader>o :only<cr>
89nnoremap H H:exec 'norm! '. &scrolloff . 'k'<cr>
90nnoremap L L:exec 'norm! '. &scrolloff . 'j'<cr>
91nnoremap <C-t> :tabedit
92nnoremap <leader>n :bnext<cr>
93nnoremap <leader>p :bprev<cr>
94
95" Not an editor command: Wqa
96:command! WQ wq
97:command! Wq wq
98:command! Wqa wqa
99:command! W w
100:command! Q q
101
102" statusline
103let g:currentmode={
104 \ 'n' : 'normal ',
105 \ 'no' : 'n·operator pending ',
106 \ 'v' : 'visual ',
107 \ 'V' : 'v·line ',
108 \ '' : 'v·block ',
109 \ 's' : 'select ',
110 \ 'S' : 's·line ',
111 \ '' : 's·block ',
112 \ 'i' : 'insert ',
113 \ 'R' : 'replace ',
114 \ 'Rv' : 'v·replace ',
115 \ 'c' : 'command ',
116 \ 'cv' : 'vim ex ',
117 \ 'ce' : 'ex ',
118 \ 'r' : 'prompt ',
119 \ 'rm' : 'more ',
120 \ 'r?' : 'confirm ',
121 \ '!' : 'shell ',
122 \ 't' : 'terminal '}
123
124hi PrimaryBlock ctermfg=06 ctermbg=00
125hi SecondaryBlock ctermfg=08 ctermbg=00
126hi Blanks ctermfg=07 ctermbg=00
127
128set statusline=
129set statusline+=%#PrimaryBlock#
130set statusline+=\ %{g:currentmode[mode()]}
131set statusline+=%#SecondaryBlock#
132set statusline+=%{StatuslineGit()}
133set statusline+=%#Blanks#
134set statusline+=\ %f\
135set statusline+=%m
136set statusline+=%=
137set statusline+=%#SecondaryBlock#
138set statusline+=\ %l\
139set statusline+=%#PrimaryBlock#
140set statusline+=%{&filetype}
141
142" for git branch in statusline, from nerdypepper
143function! GitBranch()
144 return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
145endfunction
146
147
148" bunch of functions
149function! S_gitgutter() " formatted git hunk summary for statusline
150 if exists('b:gitgutter')
151 let l:summary = b:gitgutter.summary
152 if l:summary[0] != 0 || l:summary[1] != 0 || l:summary[2] != 0
153 return ' +'.l:summary[0].' ~'.l:summary[1].' -'.l:summary[2].' '
154 endif
155 endif
156 return ''
157endfunction
158
159function! StatuslineGit()
160 let l:branchname = GitBranch()
161 return strlen(l:branchname) > 0?' '.l:branchname.' ':''
162endfunction
163
164" git gutter settings
165let g:gitgutter_override_sign_column_highlight = 0
166let g:gitgutter_sign_added = '+'
167let g:gitgutter_sign_modified = '±'
168let g:gitgutter_sign_removed = '-'
169let g:gitgutter_sign_removed_first_line = '^'
170let g:gitgutter_sign_modified_removed = '#'
171
172" comments are italicized
173hi Comment cterm=italic
174" color overrides
175hi CursorLine ctermbg=none
176
177" vim-markdown
178let g:vim_markdown_no_default_key_mappings=1
179let g:vim_markdown_toml_frontmatter=1
180let g:vim_markdown_yaml_frontmatter=1
181let g:vim_markdown_folding_disabled=1
182let g:vim_markdown_conceal=0
183
184" vim-pencil
185let g:pencil#textwidth = 72
186let g:pencil#conceallevel = 0
187augroup pencil
188 autocmd!
189 autocmd FileType markdown,mkd,text call pencil#init({'wrap': 'hard', 'autoformat': 0})
190augroup END
191
192au BufRead,BufNewFile *.asm set filetype=rgbds
193
194augroup setMail
195 autocmd!
196 autocmd BufRead,BufNewFile /tmp/nail-* setlocal ft=mail
197augroup END
198
199" insert date
200abclear
201cabbrev dt read !~/bin/date.sh<cr>
202cabbrev tm read !date "+\%H:\%M"
203
204" change cursor
205" doesn't actually work :(
206if exists('$TMUX')
207 let &t_SI .= "\ePtmux;\e\e[6 q\e\\"
208 let &t_EI .= "\ePtmux;\e\e[2 q\e\\"
209 let &t_SR .= "\ePtmux;\e\e[4 q\e\\"
210else
211 let &t_SI .= "\e[6 q"
212 let &t_EI .= "\e[2 q"
213 let &t_SR .= "\e[4 q"
214endif