-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
306 lines (244 loc) · 7.53 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
set nocompatible " not compatible with legacy vi
filetype off
" Vundle setup
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" plugins from http://vim-scripts.org/vim/scripts.html
Plugin 'syntastic'
Plugin 'rainbow_parentheses.vim'
Plugin 'jshint.vim'
Plugin 'ctrlp.vim'
" plugins from github
Plugin 'flazz/vim-colorschemes'
Plugin 'chase/vim-ansible-yaml'
Plugin 'lambdatoast/elm.vim'
Plugin 'fatih/vim-go'
Plugin 'psf/black'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
set shortmess=atI " Disable splash screen
" Use utf 8 encoding
set encoding=utf-8
" turns tabs into spaces and sets 4 spaces to a tab
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4
" don't wrap lines
set nowrap
" But have a wrapping shortcut
nnoremap <leader>w :set wrap!<CR>
" turns off swap files and backups
set nobackup
set nowb
set noswapfile
" Set the terminal title based on the file being edited
set title
" disable some shortcuts I don't use
" never want to open the man page for a given word
nnoremap K <nop>
" Never want to enter ex mode
nnoremap Q <nop>
set ruler
set t_Co=256
if has("gui_running")
set guioptions-=T "remove toolbar
set guioptions+=e "remove toolbar
set guifont=Ubuntu\ Mono\ 13
colorscheme calmar256-dark
else
colorscheme molokai
endif
inoremap <Nul> <C-p>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" ctags ahoy
"/usr/bin/ctags -R -o ~/.mytags .
set tags=~/mytags
" Strips trailing whitespace when saving Python & RST files
autocmd BufWritePre *.py :%s/\s\+$//e
autocmd BufWritePre *.rst :%s/\s\+$//e
" Formats python files using the black formatter
autocmd BufWritePost *.py execute ':Black'
syntax on
filetype plugin indent on
au FileType py set autoindent
au FileType py set smartindent
au FileType py set textwidth=80 " PEP-8 Friendly
set ffs=unix,dos
"make sure highlighting works all the way down long files
autocmd BufEnter * :syntax sync fromstart
" allow cursor to be positioned one char past end of line
" and apply operations to all of selection including last char
set selection=exclusive
" allow backgrounding buffers without writing them
" and remember marks/undo for backgrounded buffers
set hidden
" ============================== Scrolling ===================================
" Keep more context when scrolling off the end of a buffer
set scrolloff=8
set sidescrolloff=15
set sidescroll=1
" allow cursor keys to go right off end of one line, onto start of next
set whichwrap+=<,>,[,]
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Make searches case-sensitive only if they contain upper-case characters
set ignorecase
set smartcase
" show search matches as the search pattern is typed
set incsearch
" search-next wraps back to start of file
set wrapscan
" highlight last search matches
set hlsearch
" map key to dismiss search highlightedness
map <bs> :noh<CR>
set showcmd " Shows commands as you build them
set showmode " Shows current mode in status bar
" allows clicking links
set mouse=a
" Stops vim beeping at you, flashes the screen instead
set visualbell
" Put a line on the 89 character marker
if exists('+colorcolumn')
set colorcolumn=89
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>120v.\+', -1)
endif
set cursorline
set history=1000
set relativenumber
set number
" Makes tab complete work more like the shell
set wildmenu
set wildmode=list:longest
set wildignore=*.o,*.obj,*.bak,*.exe,*.pyc
filetype indent on
filetype on
filetype plugin on
" Map our <leader> to ',' and shorten the timeout
let mapleader = ","
set timeoutlen=500
" toggle paste mode
set pastetoggle=<Leader>p
" CtrlP stuff
set runtimepath^=~/.vim/bundle/ctrlp.vim
nnoremap <Leader>f :CtrlP <CR>
nnoremap <Leader>b :CtrlPBuffer<CR>
nnoremap <Leader>m :CtrlPMRU<CR>
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|node_modules|\.sass-cache|bower_components|build)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
" DONTify and unDONTify test names
map <F7> :%s/def test/def DONTtest/g<CR>
map <F8> :%s/def DONTtest/def test/g<CR>
nnoremap <Leader>d :%s/def test/def DONTtest/<CR>
nnoremap <Leader>D :%s/def DONTtest/def test/<CR>
" Open vimgrep and put the cursor in the right position
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
map <F1> :bprevious<CR>
map <F2> :bnext<CR>
" Insert time and date at the top of the file, useful for journals
nmap <F6> ggO<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><CR>-----------------------<CR>
imap <F6> <Esc>ggO<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><CR>-----------------------<CR>
" Syntastic settings
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:statline_syntastic = 0
" =====STATUS LINE OF DEATH!!=====
set statusline=
" filename, relative to cwd
set statusline+=%f
" separator
set statusline+=\
" modified flag
set statusline+=%#wildmenu#
set statusline+=%m
set statusline+=%*
"Display a warning if file encoding isnt utf-8
set statusline+=%#question#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
"display a warning if fileformat isnt unix
set statusline+=%#directory#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if files contains tab chars
set statusline+=%#warningmsg#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
" Syntastic status parts
set statusline+=%#warningmsg#
set statusline+=%*
" read-only
set statusline+=%r
set statusline+=%*
" right-align
set statusline+=%=
" filetype
set statusline+=%{strlen(&ft)?&ft:'none'}
" separator
set statusline+=\
" current char
set statusline+=%3b,0x%02B
" separator
set statusline+=\
" column,
set statusline+=%2c,
" current line / lines in file
set statusline+=%l/%L
" always show status line
set laststatus=2
" return '[tabs]' if tab chars in file, or empty string
function! StatuslineTabWarning()
if !exists("b:statusline_tab_warning")
let tabs = search('^\t', 'nw') != 0
if tabs
let b:statusline_tab_warning = '[tabs]'
else
let b:statusline_tab_warning = ''
endif
endif
return b:statusline_tab_warning
endfunction
"recalculate the tab warning flag when idle and after writing
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" " Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
" Rainbow parentheses
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" Some common typing errors
abbr hte the
abbr htem them
abbr Hasnel Hansel
abbr shrug; ¯\_(ツ)_/¯
" Stop pyflakes overwriting my quickfix list every time!!!!
let g:pyflakes_use_quickfix = 0
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to reload them.
if exists("g:did_load_filetypes")
filetype off
filetype plugin indent off
endif
filetype on
filetype plugin indent on
set clipboard=unnamedplus