rc

After the devastation that was the Deoplete branch, I went back for the master. I reworked some things, but most notably, added the Vim-JavaComplete2 completer to the plugins.

Also, added a series of settings to make it play nice with YCM and my way of doing things.

Author
Vngngdn
Date
Oct. 3, 2016, 6:17 p.m.
Hash
01337258730fe6ce444eedc38642a6496f4c141b
Parent
354fff5348ce282394292f3576ab472be372d0da
Modified file
.vimrc

.vimrc

27 additions and 8 deletions.

View changes Hide changes
1
1
" Some details on the contents:
2
2
" This file is my personal Vim configuration file. It contains my plugins, is
3
3
" divided to subject, and fattened with lovely comments.
4
4
" Please be advised that some (obvious) settings are left out, because I
5
5
" actually only use NeoVim. Again, this is my PERSONAL file, not a 'general
6
6
" public Vi(m) compatible' file.
7
7
8
8
" VUNDLE {{{
9
9
" Vundle is used to manage plugins for Vim. It needs additional setup, so it
10
10
" gets priority in my .vimrc.
11
11
12
12
filetype off                  " required
13
13
14
14
" set the runtime path to include Vundle and initialize
15
15
set rtp+=~/.vim/bundle/Vundle.vim
16
16
call vundle#begin()
17
17
18
18
" let Vundle manage Vundle, required
19
19
Plugin 'VundleVim/Vundle.vim'
20
20
21
21
" YCM is a plugin that allows Vim semantic type checking and more programming mumbo jumbo. It is godlike and it must always be there for me.
22
22
" XXX: This might be removed in favor of Deoplete. It depends on whether
23
23
" Deoplete is better or not.
24
24
Plugin 'Valloric/YouCompleteMe'
25
25
26
26
" Airline provides a neat and feature rich status bar. Really nice to have.
+
27
" of bloat software on your PC to even get a bit of semantic autocompletion.
+
28
" I've found a project which (at least) works without having to install Eclipse,
+
29
" Eclim, and whatever else you need. This is that tool.
+
30
Plugin 'artur-shaik/vim-javacomplete2'
+
31
+
32
" Airline provides a neat and feature rich status bar. Really nice to have.
27
33
Plugin 'bling/vim-airline'
28
34
29
35
" Bufferline will show buffers in the status bar. There's enough room anyway, so I fancied having it.
30
36
Plugin 'bling/vim-bufferline'
31
37
32
38
" Syntastic does automatic syntax checking without the need to compile.
33
39
" XXX: Might be replaced in the future in favor of Neomake, because it's
34
40
" asynchronous, and I only use NeoVim these days, honestly.
35
41
Plugin 'scrooloose/syntastic'
36
42
37
43
" A fuzzy searcher. Just CTRL+P and BAM all your files are visible.
38
44
Plugin 'kien/ctrlp.vim'
39
45
40
46
" This plugin enables Git intergration.
41
47
Plugin 'tpope/vim-fugitive'
42
48
43
49
" This provides snippets for redundant code. Praise the hackers man.
44
50
Plugin 'SirVer/ultisnips'
45
51
46
52
" In addition to UltiSnips, this plugin contains a prefetched repository of snippets. Must have, because I'm not planning on writing all of those by myself.
47
53
Plugin 'honza/vim-snippets'
48
54
49
55
" Rust syntax files, including Syntastic integration:
50
56
" To be removed when these are added to (Neo)Vim 'upstream'.
51
57
Plugin 'rust-lang/rust.vim'
52
58
53
59
" All of your Plugins must be added before the following line
54
60
call vundle#end()            " required
55
61
filetype plugin indent on    " required
56
62
" }}}
57
63
58
64
" YOUCOMPLETEME {{{
59
65
" YouCompleteMe is a godlike completer for Vim. As such, it is worthy of its own section.
60
66
" However, I'll be trying out Deoplete in the future, which might render it
61
67
" obsolete. Until further notice, I'm keeping this beauty.
62
68
"
63
69
" This setting will force YCM to close the preview buffer after selecting the completion.
64
70
let g:ycm_autoclose_preview_window_after_completion=1
65
71
66
72
" Sets the symbol used to indicate a syntax error:
67
73
let g:ycm_error_symbol = '>>'
68
74
69
75
" Sets the symbol used to indicate a warning:
70
76
let g:ycm_warning_symbol = 'i'
71
77
72
78
" Fills the identifier completion database with the language's keywords (e.g., when starting a new Java file, "class" will already be in the completion engine.
73
79
let g:ycm_seed_identifiers_with_syntax = 1
74
80
75
81
" To make YCM aware of the Eclim daemon presence; this setting makes YCM use
76
-
" Eclim as the source for semantic completions.
77
-
let g:EclimCompletionMethod = 'omnifunc'
78
-
" NOTE: When in Vim, type 
79
-
" ":ProjectCreate <path/to/source/code/directory> -n java"
80
-
" If this doesn't work as expected. It's Java, and this is the best you can get.
81
-
82
-
" This setting tells YCM what keys to use to accept completion. I removed <Down> as default, because I'm a silly coder and still use my arrow keys to navigate my source files. Hey, years of negligence for Vim leaves its marks. To think I ever thought Notepad++ was the best editor ever, the fuck...
83
82
let g:ycm_key_list_select_completion=['<TAB>']
84
83
85
84
" Same reason; I'm a dumb fuck and arrows are still hardwired in my brain.
86
85
let g:ycm_key_list_previous_completion=['<S-TAB>']
87
86
88
87
" Configures the pointer to the ycm_extra_conf.py file.
89
88
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
90
89
let g:ycm_confirm_extra_conf = 0 " Disables security confirmation before loading the conf.py file.
91
90
92
91
" Configuration necessary for sematic Rust completion
93
92
let g:ycm_rust_src_path = '/usr/src/rust/src'
94
93
" }}}
95
94
96
-
" AIRLINE {{{
+
95
" JAVACOMPLETE {{{
+
96
" Refraining from having to use Eclim and all the junk that attaches itself to
+
97
" it, means I have to use something else. Vim-javacomplete2 is that thing, but
+
98
" it has some additional settings that need to be set, in order to use it
+
99
" properly.
+
100
"
+
101
" Required; tell Vim that there's a completer for Java files:
+
102
autocmd FileType java setlocal omnifunc=javacomplete#Complete
+
103
" Stops adding closing braces, which conflicts with my way of thinking, which
+
104
" is: If I didn't hit the key for it, why the fuck is it on my screen.
+
105
let g:JavaComplete_ClosingBrace = 0
+
106
" JavaComplete uses a cache, which I can totally understand, because Java. I've
+
107
" set it to something more reasonable:
+
108
let g:JavaComplete_BaseDir = '~/.vim/.javacomplete-cache'
+
109
"
+
110
" TODO: javacomplete2 has a list of "default keymappings" on its GitHub page.
+
111
" It's possible that I'll have to delete these later. If so, refer to 
+
112
" https://github.com/artur-shaik/vim-javacomplete2#required
+
113
" }}}
+
114
"
+
115
" AIRLINE {{{
97
116
" Airline is a great status bar plugin. Although it can behave quirky if Powerline is not on the scene. These scripts are dedicated to handle that behavior.
98
117
99
118
" These lines will load the powerline font for use in Airline.
100
119
if !exists('g:airline_symbols')
101
120
		let g:airline_symbols={}
102
121
	endif
103
122
let g:airline_symbols.space="\ua0"
104
123
let g:airline_powerline_fonts=1
105
124
106
125
" If there is only one tab opened, the tab bar will display the different buffers.
107
126
let g:airline#extensions#tabline#enabled=1
108
127
let g:bufferline_echo = 0 " Disables automatic echoing to the bufferline.
109
128
110
129
" }}}
111
130
112
131
" ULTISNIPS {{{
113
132
" As mentioned earlier, this provides snippets to stop redundant code.
114
133
115
134
" To begin, changing default TAB, because YCM already uses TAB.
116
135
	let g:UltiSnipsExpandTrigger="<c-l>"
117
136
	let g:UltiSnipsJumpForwardTrigger="<c-j>"
118
137
	let g:UltiSnipsJumpBackwardTrigger="<c-k>"
119
138
120
139
" }}} 
121
140
"
122
141
" COLOURS & COLORS {{{
123
142
124
143
colorscheme molokai " I like molokai. I've used badwolf, but I like popping colors.
125
144
126
145
" }}}
127
146
128
147
" SPACES & TABS {{{
129
148
130
149
" The number of visual spaces per TAB hit.
131
150
set tabstop=4
132
151
133
152
" Setting the amount of tabs to 4. The default is 8.
134
153
set shiftwidth=4
135
154
136
155
" This breaks lines after column 80.
137
156
set textwidth=80
138
157
" }}}
139
158
140
159
" UI CONFIGURATION {{{
141
160
142
161
" The next 2 settings enable relative line numbering, but retain the absolute
143
162
" line numbering for the line currently selected by the cursor.
144
163
set number
145
164
set relativenumber
146
165
set cursorline " Highlights the line currently selected by the cursor.
147
166
filetype indent on " Detects filetype on load, and loads the appropriate syntax file.
148
167
set showmatch " Highlights matching parenthesis on hover ("[, {, ...").
149
168
" scrolloff tells Vim how much lines above/below the cursor should always be
150
169
" visible. For example, if set to 5, there will always be 5 lines below and
151
170
" above the cursor, except when reaching the EOF.
152
171
set scrolloff=5
153
172
" Next setting disables outputting the current mode to the last line. I did so,
154
173
" because I use Airline, which already prints the current mode.
155
174
set noshowmode
156
175
" }}}
157
176
158
177
" SEARCHING {{{
159
178
160
179
" Problem with hlsearch is that it does not turn off the highlighting. So searching for vowels may quickly result in everything being highlighted. This is a mapping. It will remove highlighting when entering \<SPACE>
161
180
nnoremap <leader><space> :nohlsearch<CR>
162
181
" }}}
163
182
164
183
" FOLDING {{{
165
184
" In case I forget (I'm Belgian), folding is hiding code parts that belong together, like functions. Très important. Fuck azerty.
166
185
167
186
" This enables folding as is.
168
187
set foldenable
169
188
170
189
" This setting determines how many folds have to be opened. The number indicates the folding level. So 0 = every possible folding is folded. 99 = practically everything is open. I'm using 10, since I already have a problem with more than 3 nested loops.
171
190
set foldlevelstart=10
172
191
173
192
" This setting blocks overuse of nested foldings. I don't know how this will turn out in LISP/Scheme, but I'll be damned if this setting does more harm than good.
174
193
set foldnestmax=10
175
194
176
195
" This setting is commented by default, but included in case I start to grow hate for the current way Vim handles folding (za). It basically maps that command to spacebar. I may map it to z because then I only have to type one letter and RETURN, that's 33% of my time saved! =3
177
196
"nnoremap <space> za
178
197
179
198
" }}}
180
199
181
200
" MOVEMENT {{{
182
201
183
202
" Up and down moving in Vim using j/k defaults to "physical line movement", i.e.
184
203
" if a line is too long, it's wrapped to the next line ("virtual lines"), but
185
204
" the line counter still regards it as 1 line.
186
205
" The next setting makes it so that, if j/k is pressed once, it moves over
187
206
" virtual lines, but when repeated (say "5dd"), it moves over physical lines.
188
207
" Basically, the perfect tradeoff solution when using relative line numbering.
189
208
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
190
209
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
191
210
" Next 4 lines disable arrow keys.
192
211
noremap <Up> <nop>
193
212
noremap <Down> <nop>
194
213
noremap <Left> <nop>
195
214
noremap <Right> <nop>
196
215
" }}}
197
216
198
217
" BACKING UP {{{
199
218
200
219
" What these lines do, is move the backup files to the /tmp folder. This will keep my directories clean and neat.
201
220
set backup
202
221
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
203
222
set backupskip=/tmp/*,/private/tmp/*
204
223
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
205
224
set writebackup
206
225
" }}}
207
226
"
208
227
" NEOVIM {{{
209
228
" While it certainly is an improvement over 'vanilla' Vim, it does some things
210
229
" that keep me from using Vim as it's supposed to be; limited to no mouse usage.
211
230
" So I disable it. I'll enable it again when I've twisted my mind far enough to
212
231
" not touch my mouse again. (Not to mention some terminals don't support mouse
213
232
" control, so it's a bad habit nonetheless if you spend all your time on
214
233
" GNU/Linux distros)
215
234
set mouse=""
216
235
" }}}
217
236
"
218
237
" MACROS {{{
219
238
" Function that allows to quickly switch between relative and absolute numbering using
220
239
" CTRL+N(umber).
221
240
function! NumberToggle()
222
241
	if(&relativenumber == 1)
223
242
		set norelativenumber  " Necessary to disable the previous behavior.
224
243
		set number
225
244
	else
226
245
		set number " Retains absolute number on the current line.
227
246
		set relativenumber
228
247
	endif
229
248
endfunc
230
249
nnoremap <C-n> :call NumberToggle()<cr>
231
250
" }}}
232
251
" OTHER IMPORTANT STUFF {{{
233
252
234
253
235
254
" I found this gem on Reddit. If I'm editing a file that's read only, and I started Vim without sudo, then this little line will do just that for me. All I have to do is use "w!!" when saving.
236
255
" Extensive explanation can also be found at https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work#7078429
237
256
cmap w!! w !sudo tee > /dev/null %
238
257
239
258
240
259
" This setting will allow me to switch to another buffer without need to save the current buffer.
241
260
set hidden
242
261
" }}}
243
262
244
263
" Because Vim can fold vimrc files with the right syntax, These lines will tell Vim how to handle that.
245
264
set modelines=2 "This tells Vim that the last 2 lines of this file should only apply to this file.
246
265
" So as you can see, the last 2 lines get a special vim:-prefix, so Vim knows for sure this is what's important.
247
266
" To wrap a new section, look at the other sections, and copy that syntax.
248
267
" vim:foldmethod=marker
249
268
" vim:foldlevel=0
250
269