-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
380 lines (365 loc) · 11.1 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
" --- REQUIREMENTS {{{
" Compile: cd ~/.vim/bundle/YouCompleteMe; ./install.py --clang-completer
" --system-clang; to
" compile ycm
" Package: the_silver_searcher / ag has to be installed to use ag
" Package: powerline-fonts
" Package: python-isort (import sorter for python)
" Packages: formaters for auto format (yapf, astyle)
" Packages: lint tools used for needed languages (javac, gcc, flake8)
" Packages: ctags (for tagbar)
" Plugin Manager: Vundle (install with git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim)
" Color Scheme: Molokai (git clone https://github.com/tomasr/molokai.git
" ~./vim/colors)
" Set shell to bash to prevent problems with plugins
set shell=bash
set nocompatible " disable vi compatibility mode
filetype off
" }}}
" --- PLUGINS {{{
" include vundel in runtime path
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle handle itself
Plugin 'VundleVim/Vundle.vim'
Plugin 'mileszs/ack.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'sjl/gundo.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdcommenter'
Plugin 'w0rp/ale'
Plugin 'Chiel92/vim-autoformat'
Plugin 'fisadev/vim-isort'
Plugin 'Valloric/YouCompleteMe'
Plugin 'skywind3000/asyncrun.vim'
Plugin 'Valloric/ListToggle'
Plugin 'godlygeek/tabular'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'Valloric/MatchTagAlways'
Plugin 'chriskempson/base16-vim'
Plugin 'Raimondi/delimitMate'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'majutsushi/tagbar'
Plugin 'rakr/vim-one'
Plugin 'pangloss/vim-javascript'
Plugin 'reedes/vim-colors-pencil'
Plugin 'PotatoesMaster/i3-vim-syntax'
Plugin 'lervag/vimtex'
Plugin 'junegunn/goyo.vim'
Plugin 'tweekmonster/spellrotate.vim'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-notes'
" --- END PLUGINS ---
call vundle#end()
filetype plugin indent on
" }}}
" --- GENERAL {{{
" default to utf8
set encoding=utf-8
" enable backups
set backup
set writebackup
" move backups to /tmp
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" enable modelines
set modelines=1
" enable mouse scrolling
set mouse=a
" allow to hide unsaved buffers
set hidden
" set global spellcheck file
set spellfile=$HOME/.dotfiles/.vimspell.utf-8.add
set complete+=kspell
" }}}
" --- KEY BINDINGS {{{
" change <leader> to comma
let mapleader = ","
" also go down to lines which are only visually split
nnoremap j gj
nnoremap k gk
" split movements
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" buffer movements
nnoremap <leader>T :enew<CR>
nnoremap <leader>k :bp<CR>
nnoremap <leader>j :bn<CR>
" save session
nnoremap <leader>s :mksession!<CR>
" lead shortcut for ctrlp
nnoremap <leader>p :CtrlP<cr>
" shorcut for ack / ag search
nnoremap <leader>a :Ack<space>
" shortcut for gundo
nnoremap <leader>uu :GundoToggle<CR>
" NerdTree toggle
nnoremap <leader>t :NERDTreeToggle<CR>
" NERDCOmmenter Toggle
nnoremap <leader># :call NERDComment(0, "toggle")<CR>
vnoremap <leader># :call NERDComment(0, "toggle")<CR>
inoremap <leader># <C-o>:call NERDComment(0,"toggle")<C-m>
" upper/lower word
nmap <leader>u mQviwU`Q
nmap <leader>l mQviwu`Q
" upper/lower first char of word
nmap <leader>U mQgewvU`Q
nmap <leader>L mQgewvu`Q
" auto format code
nnoremap <leader>f :Autoformat<CR>
" quick run shortcut
nnoremap <F5> :call <SID>compile_and_run()<CR>
" ToggleTagbar
nmap <F8> :TagbarToggle<CR>
" tabularize shortcuts
nnoremap <leader>a= :Tabularize /=<CR>
vnoremap <leader>a= :Tabularize /=<CR>
nnoremap <leader>a: :Tabularize /:\zs<CR>
vnoremap <leader>a: :Tabularize /:\zs<CR>
autocmd FileType markdown inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
" Goyo Toggle
nnoremap <leader>g :Goyo<CR>
" spellrotate commands
nmap <silent> zz <Plug>(SpellRotateForward)
nmap <silent> ZZ <Plug>(SpellRotateBackward)
vmap <silent> zz <Plug>(SpellRotateForwardV)
vmap <silent> ZZ <Plug>(SpellRotateBackwardV)
" SearchNotes
" Make the C-] combination search for @tags:
imap <C-,>ns :SearchNotes<CR>
nmap <leader>ns :SearchNotes<CR>
nmap <leader>no :Note
" Fix indent
nnoremap << >>
nnoremap >> <<
" }}}
" --- UI CONFIG {{{
" color theme to molokai
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
"set t_Co=256
"set background=light
"let g:molokai_original = 1
"let g:rehash256 = 1
" show line numbers
set number
" show last command
set showcmd
" show tab menu for completition
set wildchar=<Tab>
set wildmode=full:list
set wildmenu
" let vim redraw less e.g. for macros
set lazyredraw
" show matching () [] {}
set showmatch
"enable folding
set foldenable
" show folds by default
set foldlevelstart=10
" allow for a max of 10 nested folds
set foldnestmax=10
" open/close folds shortcut
nnoremap <space> za
" fold using indents
set foldmethod=indent
" always show statusline
set laststatus=2
" set split default positions
set splitright
set splitbelow
set go-=m
set go-=r
set go-=T
" }}}
" --- SYNTAX {{{
" enable syntax highjighting
syntax enable
" set tabs to 4 spaces
set tabstop=4
set softtabstop=4
" expand tabs into spaces
set expandtab
" set >> and << commands to 4 spaces
set shiftwidth=4
" indent when moving to the next line while writing code
set autoindent
" filetype based indents
filetype indent on
" enable python highlighting features
let python_highlight_all = 1
" }}}
" --- SEARCH {{{
" highlight text while searching
set hlsearch
" search while typing
set incsearch
" turn off search highlights
nnoremap <leader><space> :nohlsearch<CR>
" }}}
" --- PLUGIN SETTINGS {{{
" ack.vim
let g:ackprg = 'ag --vimgrep --smart-case'
" ctrlp.vim
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_path_mode = 0
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
" NERDTree
let NERDTreeShowBookmarks=1
let NERDTreeQuitOnOpen=1
" vim-airline
let g:airline_powerline_fonts = 1
let g:airline_theme='base16_eighties'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#whitespace#enabled = 0
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
" NERDCommenter
let g:NERDSpaceDelims = 1 "Space after comment symbol
" ale
let g:ale_linters = {'python': ['flake8', 'mypy', 'pylint'], 'markdown': ['mdl'], 'java': ['javac'], 'html': ['htmlhint', 'tidy'], 'yaml': ['yamllint'],}
" vim-autoformat
let g:formatters_python = ['yapf']
" vim-isort
let g:vim_isort_python_version = 'python3'
" ycm
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
" ListToggle
let g:lt_location_list_toggle_map = '<leader>ll'
let g:lt_quickfix_list_toggle_map = '<leader>q'
" UltiSnips
let g:UltiSnipsExpandTrigger="<leader><tab>"
let g:UltiSnipsJumpForwardTrigger="<leader><tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsListSnippets= "<leader>sp"
" MatchTagAlways
let g:mta_filetypes = { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1, 'htmldjango' : 1 }
" vim-javascript
let g:javascript_plugin_jsdoc = 1
" vimtex
let g:vimtex_view_method = 'zathura'
let g:vimtex_compiler_latexmk = {
\ 'options' : [
\ '-pdf',
\ '-pdflatex="xelatex --shell-escape %O %S"',
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ]
\}
" vim-notes
let g:notes_directories = ['~/.nextCloud/Notes']
let g:notes_suffix = '.md'
" goyo.vim (fix color bug)
autocmd! User GoyoLeave nested set bg=dark | colo base16-one-light
" unimpared.vim
nmap > [
nmap < ]
omap > [
omap < ]
xmap > [
xmap < ]
" }}}
" --- FILETYPE SETTINGS {{{
augroup configgroup
autocmd!
autocmd VimEnter * highlight clear SignColumn
autocmd FileType java setlocal noexpandtab
autocmd FileType java setlocal list
autocmd FileType java setlocal listchars=tab:+\ ,eol:-
autocmd FileType java setlocal formatprg=par\ -w80\ -T4
autocmd FileType php setlocal expandtab
autocmd FileType php setlocal list
autocmd FileType php setlocal listchars=tab:+\ ,eol:-
autocmd FileType php setlocal formatprg=par\ -w80\ -T4
autocmd FileType ruby setlocal tabstop=2
autocmd FileType ruby setlocal shiftwidth=2
autocmd FileType ruby setlocal softtabstop=2
autocmd FileType ruby setlocal commentstring=#\ %s
autocmd FileType python setlocal commentstring=#\ %s
autocmd BufEnter *.cls setlocal filetype=java
autocmd BufEnter *.zsh-theme setlocal filetype=zsh
autocmd BufEnter Makefile setlocal noexpandtab
autocmd BufEnter *.sh setlocal tabstop=2
autocmd BufEnter *.sh setlocal shiftwidth=2
autocmd BufEnter *.sh setlocal softtabstop=2
augroup END
" django file recognition
au BufNewFile,BufRead admin.py setlocal filetype=python.django
au BufNewFile,BufRead urls.py setlocal filetype=python.django
au BufNewFile,BufRead models.py setlocal filetype=python.django
au BufNewFile,BufRead views.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal filetype=python.django
au BufNewFile,BufRead forms.py setlocal filetype=python.django
" spell check for markdown and latex files
au BufNewFile,BufRead,BufEnter *.md setlocal spell spelllang=en_gb
au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb
" }}}
" --- CUSTOM FUNCTIONS {{{
" compile/run function
function! s:compile_and_run()
exec 'w'
if &filetype == 'python'
exec "AsyncRun! python %"
elseif &filetype == 'sh'
exec "AsyncRun! time bash %"
elseif &filetype == 'java'
exec "AsyncRun! javac %; time java %<"
elseif &filetype == 'c'
exec "AsyncRun! gcc -o %< %; ./%<"
elseif &filetype == 'cpp'
exec "AsyncRun! gcc -o %< %; ./%<"
endif
endfunction
augroup SPACEVIM_ASYNCRUN
autocmd!
" automaticaly open quickfix window on run
autocmd User AsyncRunStart call asyncrun#quickfix_toggle(15, 1)
augroup END
" auto tabularize pipes
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" rebuild spell file if it changed
for d in glob('~/.dotfiles/.vimspell.utf-8.add', 1, 1)
if filereadable(d) && (!filereadable(d . '.spl') || getftime(d) > getftime(d . '.spl'))
exec 'mkspell! ' . fnameescape(d)
endif
endfor
"python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
" }}}
" --- vim.rc settings ---
" vim:foldmethod=marker:foldlevel=0