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