home/.vimrc (view raw)
1" _ _ _ _
2"(_)_ __ (_) |___ _(_)_ __ ___
3"| | '_ \| | __\ \ / / | '_ ` _ \
4"| | | | | | |_ \ V /| | | | | | |
5"|_|_| |_|_|\__(_)_/ |_|_| |_| |_|
6"
7
8
9call plug#begin()
10Plug 'jiangmiao/auto-pairs'
11Plug 'airblade/vim-gitgutter'
12Plug 'NerdyPepper/vim-colors-plain', { 'branch': 'duotone' }
13Plug 'dbeniamine/vim-mail'
14Plug 'tpope/vim-surround'
15" plugins for writing {{{
16Plug 'reedes/vim-pencil', { 'for': ['text', 'markdown'] }
17Plug 'plasticboy/vim-markdown', { 'for': ['text', 'markdown'] }
18" }}}
19Plug 'ervandew/supertab'
20Plug 'wellle/targets.vim'
21Plug 'tpope/vim-rsi'
22Plug 'zah/nim.vim'
23" Plug 'icyphox/vim-workman', { 'branch': 'iceman' }
24call plug#end()
25
26" indentation
27augroup indents
28 autocmd!
29 autocmd FileType less,css,html setlocal ts=2 sts=2 sw=2 expandtab
30 autocmd FileType text,markdown setlocal expandtab
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
192augroup setMail
193 autocmd!
194 autocmd BufRead,BufNewFile /tmp/nail-* setlocal ft=mail
195augroup END
196
197" insert date
198abclear
199cabbrev dt read !~/bin/date.sh<cr>
200cabbrev tm read !date "+\%H:\%M"
201
202" change cursor
203" doesn't actually work :(
204if exists('$TMUX')
205 let &t_SI .= "\ePtmux;\e\e[6 q\e\\"
206 let &t_EI .= "\ePtmux;\e\e[2 q\e\\"
207 let &t_SR .= "\ePtmux;\e\e[4 q\e\\"
208else
209 let &t_SI .= "\e[6 q"
210 let &t_EI .= "\e[2 q"
211 let &t_SR .= "\e[4 q"
212endif
213
214" for workman in normal mode
215" let g:workman_normal_qwerty = 0