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