-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
353 lines (304 loc) · 11.8 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
set nocompatible " be iMproved
filetype off " required!
" https://github.com/vim/vim/issues/993
" set Vim-specific sequences for RGB colors
" ----------------- PLUG SETTINGS -----------------------"
" automatically install vim plug if not found
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
" plugin section
call plug#begin()
" pope section
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-unimpaired'
" Plug 'tpope/vim-dispatch'
" aesthetics
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Plug 'flazz/vim-colorschemes'
Plug 'morhetz/gruvbox'
Plug 'airblade/vim-gitgutter'
Plug 'ryanoasis/vim-devicons'
" utils
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'sjl/gundo.vim', { 'on': 'GundoToggle' }
Plug 'tomtom/tcomment_vim'
" Plug 'majutsushi/tagbar'
" Plug 'kien/ctrlp.vim'
" Plug 'mileszs/ack.vim'
" Plug 'jmcantrell/vim-virtualenv'
Plug 'christoomey/vim-tmux-navigator'
" autocomplete + snippets
" Plug 'Valloric/YouCompleteMe'
Plug 'sirver/ultisnips'
Plug 'honza/vim-snippets'
" syntax + tags + highlighting
Plug 'scrooloose/syntastic'
Plug 'godlygeek/tabular', { 'for': 'mkd' }
Plug 'chase/vim-ansible-yaml', { 'for': 'yaml' }
" Plug 'plasticboy/vim-markdown', { 'for': 'mkd' }
"Plug 'mitsuhiko/vim-jinja', { 'for': 'html' }
" Plug 'othree/html5.vim', { 'for': 'html' }
" Plug 'hail2u/vim-css3-syntax', { 'for': ['css', 'html'] }
" Plug 'pangloss/vim-javascript', { 'for': ['html', 'javascript'] }
" Plug 'mxw/vim-jsx', { 'for': ['javascript', 'javascript.jsx'] }
" Plug 'ternjs/tern_for_vim', { 'for': ['javascript'] }
" Plug 'maksimr/vim-jsbeautify', { 'for': ['html*','css','javascript'] }
" Plug 'tshirtman/vim-cython', { 'for': ['pyrex', 'cython']}
Plug 'keith/tmux.vim', { 'for': 'tmux' }
" Plug 'cakebaker/scss-syntax.vim', { 'for': ['scss','sass'] }
" text and tex stuff
Plug 'lervag/vimtex', { 'for': ['tex'] }
Plug 'reedes/vim-pencil', { 'for': ['tex','text','mkd','markdown'] }
" ipython intergration
" Plug 'ivanov/vim-ipython'
call plug#end()
filetype plugin indent on " required!
" ------------------- General settings ----------------------------"
syntax on
" persistent undo - support undo's even if you have closed the file
if has('persistent_undo') "check if your vim version supports it
set undofile "turn on the feature
set undodir=$HOME/.vim/undo "directory where the undo files will be stored
endif
" ignore other tex types - plaintex etc
let g:tex_flavor='latex'
" show active line
set cursorline
" line numbering
" set number " line numbering stuff
" set numberwidth=3 " how much width the column is at the beginning
" show 4 lines above and below
set scrolloff=4
" automatically read changes made outside vim if not changed in vim
set autoread
" view outer changes if any when selecting the window
au FocusGained,BufEnter * :silent! !
" add title to vim window!
set title
set backspace=indent,eol,start
" don't want annoying sounds - 2015-08-05 00:05
set visualbell "No sounds - Thank you sooooo much! : https://github.com/skwp/dotfiles
" Make searches match incrementally! - 2015-08-05 00:16
set incsearch
" use menu with autocompletions
set wildmenu
set wildignore+=*.dll,*.o,*.pyc,*.bak,*.exe,*.jpg,*.jpeg,*.png,*.gif,*.class,*.so,*.swp
set splitright
set shortmess=a
set cmdheight=2
" make vim search for tags in .tags as well
set tags+=.tags
" quicker window switching
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" -------------------- Bad habit removal ------------------------------"
nnoremap <Right> :tnext<CR>
nnoremap <Left> :tprev<CR>
nmap <Up> [l
nmap <Down> ]l
vmap <Up> [l
vmap <Down> ]l
set mouse=a
map <ScrollWheelUp> 4<C-Y>
map <ScrollWheelDown> 4<C-E>
" I have never used ex mode for the time being..
nnoremap Q <Nop>
" -------------------- Text folding ------------------------------"
setlocal foldmethod=manual
setlocal foldnestmax=3
setlocal foldminlines=1
inoremap <F1> <C-O>za
nnoremap <F1> za
onoremap <F1> <C-C>za
vnoremap <F1> zf
" ------------------- Indentation settings ------------------------"
set shiftwidth=4
set tabstop=4
" set expandtab " don't replace tabs by default
set softtabstop=4
" ------------------- Colorscheme settings ------------------------"
" set termguicolors
colorscheme gruvbox
set background=dark
let g:gruvbox_italic=1
let g:gruvbox_improved_warnings=1
" ------------------- General keybindings -------------------------------"
" run make
nnoremap <F3> :Make<CR>
nnoremap <F4> :NERDTree<CR>
nnoremap <F5> :GundoToggle<CR>
nnoremap <F6> :TagbarToggle<CR>
" create ctags file
nnoremap <F8> :!/usr/bin/ctags -R<CR>
" ------------------- Airline settings ----------------------------------"
set laststatus=2 "used for airline
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_theme='gruvbox'
" --------------------- Ctrlp settings ------------------------------"
let g:ctrlp_working_path_mode = 'a'
" --------------------- Syntastic settings ------------------------------"
" add checking for javascript + more options grv added @ 2015-11-01 21:04
let g:syntastic_enable_signs = 1
" let g:syntastic_auto_jump = 1
" C support "
let g:syntastic_c_check_header = 1
let g:syntastic_c_auto_refresh_includes = 1
let g:syntastic_cpp_include_dirs = ['include', '../include']
let g:syntastic_c_include_dirs = ['include', '../include']
" Be able to jump to errors with :lnext and :lprev
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_python_checkers = ['pyflakes', 'pep8']
let g:syntastic_javascript_checkers = ['eslint']
" ------------------- YouCompleteMe settings ----------------------------"
" use tab for autocompletion and ctrl plus up or down
" to select completion - 2015-08-05 00:25
let g:ycm_key_list_select_completion=['<Tab>', '<C-k>']
let g:ycm_key_list_previous_completion=['<C-j>']
" close window that shows prototypes after completion
" let g:ycm_autoclose_preview_window_after_completion = 1
" close window that shows prototypes after exiting insertion mode
let g:ycm_autoclose_preview_window_after_completion = 1
" close window that shows prototypes after exiting insertion mode
" let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_auto_trigger = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_key_invoke_completion = '<C-Space>'
" added by grv - Wed 19 Aug 2015 08:08:29 AM EEST
" use eclim for java
let g:EclimCompletionMethod = 'omnifunc'
" use shift plus tab for snippet completion
" then ctrl plus direction to skip completes - 2015-08-05 00:24
let g:UltiSnipsExpandTrigger="<S-Tab>"
let g:UltiSnipsJumpForwardTrigger="<C-l>"
let g:UltiSnipsJumpBackwardTrigger="<C-h>"
if !exists('g:ycm_semantic_triggers')
let g:ycm_semantic_triggers = {}
endif
" ------------------- Pencil settings ----------------------------"
" configured pencil - added by grv - Sat, 08 Aug 2015 16:20:35
let g:pencil#wrapModeDefault = 'soft' " default is 'hard'
let g:pencil#textwidth = 79
augroup pencil
autocmd!
autocmd FileType markdown,mkd,text,tex call pencil#init()
augroup END
"------------------- Filetype Specifics --------------------------"
"-------------------------- Python --------------------------"
augroup Python
autocmd!
" change tabs to spaces for python
autocmd FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab
" easy print using surround with char p
autocmd FileType python let g:surround_112 = "print(\r)"
" Python fold on indent
autocmd FileType python setlocal foldmethod=indent
autocmd FileType python setlocal foldnestmax=2
autocmd FileType python setlocal foldminlines=5
autocmd FileType python setlocal foldlevel=2
augroup END
"-------------------------- C++ --------------------------"
augroup Cpp
autocmd!
" change tabs to spaces for C++
autocmd FileType cpp setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab
" easy print using surround with char p
autocmd FileType cpp let g:surround_112 = "std::cout<<\r<<std::endl;"
" Make options
autocmd QuickFixCmdPost * nested cwindow | redraw!
" Cpp fold on indent
autocmd FileType cpp setlocal foldmethod=indent
autocmd FileType cpp setlocal foldnestmax=2
autocmd FileType cpp setlocal foldminlines=5
autocmd FileType cpp setlocal foldlevel=2
augroup END
"-------------------------- TeX --------------------------"
augroup TeX
autocmd!
" smaller indentation for tex. we also want greek support
autocmd FileType tex setlocal shiftwidth=2 tabstop=2 softtabstop=2 " keymap=greek_utf-8
" support surrounding with tex environments
autocmd FileType tex let g:surround_108 = "\\begin{\1environment: \1}\n\r\n\\end{\1\1}"
" support surrounding with tex command - eg \textbf{}
autocmd FileType tex let g:surround_112 = "\\\1environment: \1{\r}"
autocmd FileType tex let g:vimtex_view_general_viewer = 'okular'
autocmd FileType tex let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
autocmd FileType tex let g:vimtex_view_general_options_latexmk = '--unique'
autocmd FileType tex let g:ycm_semantic_triggers.tex = g:vimtex#re#youcompleteme
autocmd FileType tex let g:tex_conceal = ""
augroup END
"-------------------------- Java --------------------------"
augroup Java
autocmd!
" change tabs to spaces for Java
autocmd FileType java setlocal shiftwidth=4 tabstop=8 softtabstop=4 expandtab
" easy print using surround with char p
autocmd FileType java let g:surround_112 = "System.out.println(\r);"
augroup END
"-------------------------- Yaml --------------------------"
" support yaml syntax using ansible
augroup Yaml
autocmd!
autocmd FileType yaml setlocal expandtab shiftwidth=2 tabstop=8 softtabstop=2
autocmd FileType yaml set ft=ansible
augroup END
"-------------------------- JSON --------------------------"
augroup JSON
autocmd!
autocmd FileType json setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
augroup END
"-------------------------- HTML --------------------------"
augroup HTML
autocmd!
" smaller indentation for html
autocmd FileType xml,html,htmldjango,htmljinja setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
autocmd FileType xml,html,htmldjango,htmljinja noremap <buffer> <leader>r :call HtmlBeautify()<cr>
augroup END
"-------------------------- CSS ---------------------------"
augroup CSS
autocmd!
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType css noremap <buffer> <leader>r :call CSSBeautify()<cr>
augroup END
"----------------------- Javascript -----------------------"
augroup Javascript
autocmd!
autocmd FileType javascript setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType javascript noremap <buffer> <leader>r :call JsBeautify()<cr>
augroup END
"----------------------- JSX -----------------------"
augroup JSX
autocmd!
autocmd FileType javascript.jsx setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType javascript.jsx noremap <buffer> <leader>r :call JsBeautify()<cr>
augroup END
" Vertical split colors and settings - 2015-08-05 00:04
set fillchars+=vert:*
" https://sookocheff.com/post/vim/italics/
highlight Comment cterm=italic
" Make changing modes snappy
" See (https://www.reddit.com/r/vim/comments/2391u5/delay_while_using_esc_to_exit_insert_mode/)
" and https://www.johnhawthorn.com/2012/09/vi-escape-delays/
" Also note that running vim in tmux can have the same effect
" use 'set -s escape-time 0' in tmux.conf
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
" Easy copy pasting.. I should have used this a long time ago..
nnoremap <C-c> "+y
vnoremap <C-x> "+c<ESC>
vnoremap <C-c> "+y
nnoremap <C-p> "+p
vnoremap <C-p> "+p
inoremap <C-p> <C-r>+