-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
231 lines (182 loc) · 5.57 KB
/
.vimrc
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
" Vundle Preamble {{{
set nocompatible " required by vundle
filetype off " required by vundle
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" }}}
" Vundle Plugins {{{
" required by vundle to manage vundle
Plugin 'VundleVim/Vundle.vim'
" colorschemes
Plugin 'morhetz/gruvbox'
" fuzzy matching for filenames and other things
Plugin 'ctrlpvim/ctrlp.vim'
" file browser
Plugin 'scrooloose/nerdtree'
" git wrapper for vim
Plugin 'tpope/vim-fugitive'
" handy bracket mappings
Plugin 'tpope/vim-unimpaired'
" surround all the things
Plugin 'tpope/vim-surround'
" syntax highlighting extras for c, bison, and flex
Plugin 'justinmk/vim-syntax-extra'
" javascript plugins
Plugin 'jelera/vim-javascript-syntax'
" python plugins
Plugin 'lepture/vim-jinja'
Plugin 'davidhalter/jedi-vim'
Plugin 'python-mode/python-mode'
Plugin 'psf/black'
" rust plugins
Plugin 'rust-lang/rust.vim'
Plugin 'cespare/vim-toml'
" go plugins
Plugin 'fatih/vim-go'
" saltstack plugins
Plugin 'saltstack/salt-vim'
" }}}
" Vundle Postamble {{{
" ALL plugins must be added before this line
call vundle#end() " required by vundle
filetype plugin indent on " required by vundle
" }}}
" Misc {{{
set encoding=utf-8
set ttyfast " faster redraw
" }}}
" Meta {{{
" http://stackoverflow.com/a/15317146
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//
" }}}
" Spaces & Tabs {{{
set tabstop=4 " number of visual spaces per tab
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces used in indenting
set expandtab " tabs are spaces
" overrides for specific filetypes
autocmd FileType javascript,json set tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType css,html set tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType c,cpp set tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileTYpe yml,yaml set tabstop=2 softtabstop=2 shiftwidth=2
" }}}
" UI & Layout {{{
set number " show line numbers
set cc=80 " color coloumn at 80 lines
set nowrap " don't wrap text
set lazyredraw " redraw only when we need to
" }}}
" Leader shortcuts {{{
let mapleader="\<Space>" " leader is space
nnoremap <leader>m :silent make\|redraw!\|cw<CR>
nnoremap <leader>ev :vsp $MYVIMRC<CR>
nnoremap <leader>ez :vsp ~/.zshrc<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
nnoremap <leader><space> :nohlsearch<CR>
nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <leader>f :NERDTreeFind<CR>
" count matches for a pattern under the cursor (https://j.mp/2QSFa8Z)
nnoremap <leader>* *<C-O>:%s///gn<CR>
" Thanks, nXqd: https://superuser.com/a/437744
nnoremap <leader>p :setlocal paste! paste?<CR>
nnoremap <leader>l :setlocal list! list?<CR>
" Run rustfmt on .rs files. https://vi.stackexchange.com/a/11196
autocmd FileType rust nnoremap <buffer><silent><leader>r :RustFmt<CR>
" }}}
" Folding {{{
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
" comma opens/closes folds
nnoremap , za
set foldmethod=indent " fold based on indent level
" }}}
" Search {{{
set incsearch " search as characters are entered
set hlsearch " highlight matches
set showmatch " highlight matching [{()}]
" search from visual selection
vnoremap // y/<C-R>"<CR>
" }}}
" Colors {{{
if has("termguicolors")
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
syntax enable
set background=dark
colorscheme gruvbox
let g:gruvbox_contrast_dark = "soft"
" }}}
" Markdown {{{
au BufRead,BufNewFile *.md set filetype=markdown
" }}}
" NERDTree {{{
" don't show help text at the top of NERDTree
let NERDTreeMinimalUI=1
" ignore these files in NERDTree
let NERDTreeIgnore = ['\.pyc$', '\.egg-info$', '__pycache__']
" start with NERDTree open if no files are specified
autocmd vimenter * if !argc() | NERDTree | endif
" exit Vim if a NERDTree is the last buffer
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" }}}
" Jinja {{{
au BufNewFile,BufRead *.jinja2 set ft=jinja
" }}}
" Python Mode {{{
" Activate rope
" Keys:
" K Show python docs
" <Ctrl-Space> Rope autocomplete
" <Ctrl-c>g Rope goto definition
" <Ctrl-c>d Rope show documentation
" <Ctrl-c>f Rope find occurrences
" <Leader>b Set, unset breakpoint (g:pymode_breakpoint enabled)
" [[ Jump on previous class or function (normal, visual, operator modes)
" ]] Jump on next class or function (normal, visual, operator modes)
" [M Jump on previous class or method (normal, visual, operator modes)
" ]M Jump on next class or method (normal, visual, operator modes)
let g:pymode_rope = 1
"
" documentation
let g:pymode_doc = 1
let g:pymode_doc_key = 'K'
"
"linting
let g:pymode_lint = 1
let g:pymode_lint_checker = "pyflakes,pep8"
let g:pymode_lint_options_pep8 = {'max_line_length': 88}
" auto check on save
let g:pymode_lint_write = 1
"
" support virtualenv
let g:pymode_virtualenv = 1
"
" enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_key = '<leader>b'
"
" syntax highlighting
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
"
" don't autofold code
let g:pymode_folding = 0
"
" prevent auto insertion of autocomplete options
set completeopt=menuone,noinsert
" }}}
" Black {{{
autocmd BufWritePre *.py execute ':Black'
" }}}
" Rustfmt {{{
autocmd BufWritePre *.rs execute ':RustFmt'
" }}}
" vim:foldmethod=marker:foldlevel=0