-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
351 lines (280 loc) · 10 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
" Stupid fix while they sort things together, taken from
" https://github.com/vim/vim/issues/3117#issuecomment-404052306
if has('python3')
silent! python3 1
endif
" Install vim plug
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" Colorscheme install this into ~/.vim/colors :
" curl -fLo ~/.vim/colors/Tomorrow-Night-Bright.vim --create-dirs https://raw.githubusercontent.com/chriskempson/vim-tomorrow-theme/master/colors/Tomorrow-Night-Bright.vim
call plug#begin('~/.vim/plugged')
"""" Misc
Plug 'bling/vim-airline'
Plug 'lfv89/vim-interestingwords' " leader-k to mark words (nN to move around once over it, leader-K to unmark all)
Plug 'kien/rainbow_parentheses.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-speeddating' | Plug 'vimwiki/vimwiki'
Plug 'tpope/vim-obsession'
Plug 'elixir-lang/vim-elixir', {'for': 'elixir'}
Plug 'sanford1/unite-unicode'
Plug 'ryanoasis/vim-devicons'
"""" Basics
Plug 'tpope/vim-repeat'
Plug 'justinmk/vim-sneak'
Plug 'chaoren/vim-wordmotion'
Plug 'tpope/vim-surround'
Plug 'bronson/vim-trailing-whitespace'
"""" Coding
Plug 'FooSoft/vim-argwrap' "Wrap/unwrap things
Plug 'tpope/vim-commentary'
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' - Commented due to
" missing python with vim
" Plug 'maralla/validator.vim' "More sophisticated async linter - commented
" due to missing python in vim
Plug 'xoliver/python-alternate.vim'
"""" Git
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'rhysd/committia.vim' " More pleasant editing on commit message
"""" Objects
Plug 'vim-scripts/argtextobj.vim'
Plug 'michaeljsmith/vim-indent-object'
"""" Python
Plug 'alfredodeza/pytest.vim', {'for': 'python'}
Plug 'voithos/vim-python-matchit', {'for': 'python'}
Plug 'davidhalter/jedi-vim', {'for': 'python'}
Plug 'tmhedberg/SimpylFold'
"""" Specific file types
Plug 'vim-scripts/csv.vim', {'for': 'csv'}
Plug 'elzr/vim-json', {'for': ['javascript', 'json']}
Plug 'hashivim/vim-terraform'
"""" Unite
Plug 'Shougo/vimproc.vim', {'do': 'make'} | Plug 'Shougo/unite.vim'
Plug 'Shougo/unite-outline'
Plug 'Shougo/neoyank.vim'
"""" Try out
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'osyo-manga/vim-hopping'
Plug 'osyo-manga/vim-over' "Replace overview
call plug#end()
""" Internal
filetype plugin indent on
set encoding=UTF-8
set t_Co=256
set background=dark
set clipboard=unnamed "Enable copy-paste through tmux and in OSX
set confirm "Confirm when switching away from unsaved tab
set guioptions-=T "remove toolbar
set history=1000
set wildmenu "Activate showing autocomplete menu
set wildmode=longest,list,full "Autocomplete as much as possible, do not go over options
map <Space> <Leader>
set showcmd
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :q<CR>
set backspace=indent,eol,start
"Backspace in normal mode -> jump to previous buffer
nnoremap <BS> :bprevious<CR>
" Search business
set ignorecase
set hlsearch
set incsearch
" Show matching brackets
set showmatch
set magic
syntax enable
"Tab business
set smarttab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
""" Scroll, line numbers
set number "Show line numbers
" set relativenumber "Show relative line numbers
set lazyredraw "Lazy redraw of screen, improves speed of relative numbers
set scrolloff=10 "Offset when scrolling
set cursorline "Show active line
"Show absolute line numbers in insert mode, relative otherwise
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
" Fold business
set foldmethod=indent
set foldlevel=99
" Split pane business
set splitbelow
set splitright
" ctags business
set tags=./tags;
" Status bar business
set laststatus=2
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" Max columns definition for gqq (0 won't auto-add newlines)
set tw=0 " 119
nnoremap <silent> <leader>aw :ArgWrap<CR>
""" Autocmd
if has("autocmd")
filetype on
filetype plugin indent on
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
autocmd FileType python setlocal expandtab
autocmd FileType python let &colorcolumn=join(range(80,119),",")
autocmd FileType python let g:argwrap_tail_comma = 1 "Add trailing comma when wrapping
au BufNewFile,BufFilePre,BufRead *.rpy set filetype=python
endif
nmap <silent><Leader>wb <Esc>:call HighlightBulletPoints()<CR>
function! HighlightBulletPoints()
syn match TodoBullets /^[\*\-\+] \[ \]/
highlight TodoBullets ctermfg=white ctermbg=1 " red
syn match HalfwayBullets /^[\*\-\+] \[[^X ]\]/
highlight HalfwayBullets ctermfg=white ctermbg=172 " orange
syn match DoneBullets /^[\*\-\+] \[X\]/
highlight DoneBullets ctermfg=green
endfunction
" Stay in visual mode when indenting
vnoremap < <gv
vnoremap > >gv
" Make the folder explorer look nicer
let g:netrw_liststyle=3
""" Colours
if has("gui_running")
colorscheme desert
else
colorscheme Tomorrow-Night-Bright
set mouse=a
endif
" Too long lines should be mildly highlighted
hi ColorColumn guibg=#444444
" It needs to be after filetype on for csv.vim
syntax on
" Ctrl+L to clear search patterns
nnoremap <C-L> :nohlsearch<CR><C-L>
""" Files, folders
" Save your swp files to a less annoying place than the current directory.
" " If you have .vim-swap in the current directory, it'll use that.
" " Otherwise it saves it to ~/.vim/swap, ~/tmp or .
if isdirectory($HOME . '/.vim/swap') == 0
:silent !mkdir -p ~/.vim/swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/swap//
set directory+=~/tmp//
set directory+=.
""" External plugins
" Airline
let g:airline#extensions#tabline#enabled = 0 "Do not show all open buffers on top bar (that way tabs show fine)
let g:airline_theme='dark'
" Rainbow parentheses
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
" signify
let g:signify_vcs_list = ['git']
" jedi-vim
let g:jedi#use_splits_not_buffers = "right"
let g:jedi#popup_on_dot = 0
" ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" validator
" let g:validator_auto_open_quickfix = 1
let g:validator_error_msg_format = "[%d/%d]"
let g:validator_python_flake8_args="--max-line-length=119"
" vim-tmux-navigator
let g:tmux_navigator_no_mappings = 1 "Screw default mappings: Control+hjkl
nnoremap <silent> <C-W>h :TmuxNavigateLeft<cr>
nnoremap <silent> <C-W>j :TmuxNavigateDown<cr>
nnoremap <silent> <C-W>k :TmuxNavigateUp<cr>
nnoremap <silent> <C-W>l :TmuxNavigateRight<cr>
nnoremap <silent> <C-\> :TmuxNavigatePrevious<cr>
" pytest.vim
nmap <silent><Leader>f <Esc>:Pytest file<CR>
nmap <silent><Leader>c <Esc>:Pytest class<CR>
nmap <silent><Leader>m <Esc>:Pytest method<CR>
" unite.vim
" Cool flags: -quick-match -auto-preview
call unite#filters#matcher_default#use(['matcher_fuzzy'])
" Recursive file opening, asynchronous
" nmap <leader>p :Unite -no-split -start-insert -buffer-name=files file_rec/async<CR>
nmap <leader>p :Files<CR>
" Show open buffers
nmap <leader>l :Unite -no-split -quick-match -buffer-name=buffers buffer<CR>
" Show outline
nmap <leader>o :Unite -auto-preview -no-split -buffer-name=outline -start-insert outline<CR>
" Launch file search
nmap <leader>/ :Unite -no-split -auto-preview grep:.<CR>
" Yank history search
let g:unite_source_history_yank_enable = 1
nmap <leader>y :Unite -no-split -quick-match -buffer-name=yanks history/yank<cr>
if executable('ag')
" Use ag for recursive file search - will ignore stuff in .gitignore :-)
let g:unite_source_rec_async_command = ['ag']
let g:unite_source_rec_async_default_opts =
\ '-i --line-numbers --nocolor --nogroup --hidden --ignore ' .
\ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
let g:unite_source_rec_async_recursive_opt = ''
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts =
\ '-i --line-numbers --nocolor --nogroup --hidden --ignore ' .
\ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
let g:unite_source_grep_recursive_opt = ''
endif
autocmd FileType unite call s:unite_my_settings()
function! s:unite_my_settings()
imap <silent><buffer><expr> <C-v> unite#do_action('right')
imap <buffer> <C-j> <C-n>
imap <buffer> <C-k> <C-p>
endfunction
"Use kj to leave insert mode
inoremap kj <ESC>
" Jump from python file to test file
autocmd FileType python nnoremap <silent> <leader>. <Esc>:call OpenPythonAlternate()<CR>
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
" Enable folding
set foldmethod=indent
set foldlevel=99
let g:SimpylFold_docstring_preview=1
let g:SimpylFold_fold_docstring = 0
" CSV default
let g:csv_delim=','
" Need to include ~/.vim/bundle/unite-outline/autoload/unite/sources/outline/vimwiki.vim
" Clone of defaul markdown.vim to bypass limitations sine outline-vimwiki won't work
let g:vimwiki_list = [{'syntax': 'markdown', 'ext': '.md'}]
""" Enable navigation of quickfix issues in normal mode
nmap <silent> <C-N> :lne<CR>zv
nmap <silent> <C-P> :lp<CR>zv
" Vim-hopping
" Unsure about starter
nmap <silent> <leader>h :HoppingStart()<CR>
" Keymapping
let g:hopping#keymapping = {
\ "\<C-j>" : "<Over>(hopping-next)",
\ "\<C-k>" : "<Over>(hopping-prev)",
\ "\<C-u>" : "<Over>(scroll-u)",
\ "\<C-d>" : "<Over>(scroll-d)",
\}
""" Auto-folding settings to display vimrc (reminder: zR undoes all folds)
" -vim:fdm=expr:fdl=0
" -vim:fde=getline(v\:lnum)=~'^""'?'>'.(matchend(getline(v\:lnum),'""*')-2)\:'='"