-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
270 lines (238 loc) · 12.3 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
" Sane, Lightweight and a e s t h e t i c .vimrc by Erik S. V. Jansson.
" Initialization: {
set nocompatible " Enable features which aren't compatible with Vi.
filetype off " Required by Vundle before setting the runtime paths.
set rtp+=~/.vim_bundle/Vundle.vim " Specify the Vim runtime path...
call vundle#begin('~/.vim_bundle') " The package install directory.
Plugin 'VundleVim/Vundle.vim' " Useful if Vundle itself has update.
" }
" Plugins: {
" Functional: {
Plugin 'tpope/vim-repeat' " Extend the Vim '.' operator.
Plugin 'tpope/vim-commentary.git' " Comment stuff out...
Plugin 'tpope/vim-surround' " Change (){}<>'' in a snap.
Plugin 'godlygeek/tabular' " Easy automatic tabulations.
Plugin 'scrooloose/nerdtree' " Better than NetRw, maybe.
Plugin 'majutsushi/tagbar' " Nice to get a code topview.
Plugin 'tpope/vim-fugitive' " Probably best Git wrapper.
Plugin 'tmhedberg/matchit' " The '%' now matches more k?
Plugin 'mileszs/ack.vim' " Forget IDE searches gtg fast!
Plugin 'sjl/gundo.vim' " Why only have linear undo tree?
Plugin 'ervandew/supertab' " Use <Tab> for autocomplete.
Plugin 'tpope/vim-dispatch' " When launching async jobs.
Plugin 'ngemily/vim-vp4' " Minimal Perforce integration.
" }
" Cosmetic: {
Plugin 'itchyny/lightline.vim' " A lightweight tab line.
Plugin 'morhetz/gruvbox' " The most amazing colorscheme!
Plugin 'sainnhe/gruvbox-material' " A nicer alternative.
Plugin 'luochen1990/rainbow' " Rainbow brackets for Vim!
"}
" Language: {
Plugin 'beyondmarc/hlsl.vim' " Integrate HLSL highlight.
Plugin 'CaffeineViking/vim-glsl' " Add support for GLSL.
Plugin 'kbenzie/vim-spirv.git' " SPIRV syntax highlight.
Plugin 'CaffeineViking/vim-pica200' " PICA200 assembler.
"}
" }
" Preliminaries: {
call vundle#end() " Let Vundle finish initializing itself now.
filetype plugin indent on " Enable file specific features...
" }
" General: {
set viminfo+=n~/.viminfo " Windows wants to save _viminfo...
set autowrite " Save automatically when using :make / :next.
set autoread " Reload file when it has been changed externally.
set nobackup " No need for .bkp files when version control exist.
set nowritebackup " If Vim crashes often then turn backups on again, look at docs for more information.
set noswapfile " Don't create swap files, nowadays we should have enough memory to store a text file.
set sessionoptions-=options " Don't store options (global variables etc...) when making a session.
set undodir=~/.vim_undoes " Files with dots are supported in Windows too, no need for distinction.
set undofile " Enable persistent undo, this allows you to undo changes accross different sessions!
let mapleader="\<Space>" " This vimrc frowns on overwritten vim bindings, I use the ',' quite a lot.
let g:mapleader="\<Space>" " It is very rare to see Vim user use <Space> in normal mode, hence this.
set history=1024 " Defines the number of stored commands Vim can remember, doesn't really matter :).
set belloff=all " Disable audio bell that constantly goes off in Windows version of gvim at least...
" }
" Completion: {
set complete-=i " Don't search included files (it's slow).
set completeopt+=longest " Only autocomplete widest match.
" SuperTab:
let g:SuperTabLongestEnhanced=1 " Improve 'longest' match.
let g:SuperTabCrMapping=1 " <CR> accepts the autocomplete.
" }
" Formatting: {
set expandtab " Expand tab characters to space characters.
set shiftwidth=4 " One tab is now 4 spaces.
set shiftround " Always round up to the nearest tab.
set tabstop=4 " This one is also needed to achieve the desired effect.
set softtabstop=4 " Enables easy removal of an indentation level.
set autoindent " Auto-magically copies the previous indentations.
set backspace=2 " Used for making backspace work like in most other editors (e.g. removing a single indent).
set wrap " Wrap text. This is also quite optional, replace with textwidth=80 is you don't want this behaviour.
set lazyredraw " Good performance boost when executing macros, redraw the screen only on certain commands.
" }
" Searching: {
set ignorecase " Search is not case sensitive, which is usually what we want.
set smartcase " Will override some ignorecase properties, when using caps it will do a special search.
set incsearch " Enables the user to step through each search 'hit', usually what is desired here.
set hlsearch " Will stop highlighting current search 'hits' when another search is performed.
set magic " Enables regular expressions. They are a bit like magic (not really though, DFA).
" Tries to use a better program than 'Ack' for searching through code, such as 'ag' or 'rg'.
if executable('rg')
let g:ackprg = 'rg --vimgrep' " ripgrep
elseif executable('ag')
let g:ackprg = 'ag --vimgrep' " the_silver_searcher
endif
" NOTE: ackpreview works in a bit of a weird way, there
" is no way to keep the current file open if you do not
" have a match. Maybe should fix this issue in ack.vim?
let g:ackhighlight = 1 " Keep all matches highlighted.
let g:ack_autoclose = 1 " Closes the window by default.
let g:ackpreview = 1 " Automagically previews files.
" }
" Interface: {
set ffs=unix,dos,mac " Prioritize unix as the standard file type.
set encoding=utf-8 " Vim can now work with a whole bunch more characters (powerline too).
set scrolloff=8 " The screen will only scroll when the cursor is 8 characters from the top/bottom.
set foldmethod=indent " Pressing zc will close a fold at the current indent while zo will open one.
set foldopen+=jump " Additionally, open folds when there is a direct jump to the location.
set nofoldenable " Disable folding by default, but allow it to be toggled back on with zi.
set wildmenu " Enable the 'autocomplete' menu when in command mode (':').
set cursorline " For easier cursor spotting. Completely optional though (but so is bathing).
set shortmess=at " Shorten some command mode messages, will keep you from having to hit ENTER all the time.
" set cmdheight=2 " Might decrease the number of times for hitting enter even more, double default height.
set stal=2 " Always show the tab lines, which makes the user interface a bit more consistent.
set showmatch " Will highlight matching brackets.
set mat=2 " How long the highlight will last.
set number " Show line numbers on left side.
set relativenumber " Enables the user to easily see the relative distance between cursor and target line.
set ttyfast " Will send characters over a terminal connection faster. We do have fast connections after all.
set ruler " Always show current cursor position, which might be needed for the character column location.
set hidden " Abandon buffer when closed, which is usually what we want to do in this case.
syntax on " The most important feature when coding. Vim please bless us with this option right now!.
set laststatus=2 " Always have a status line, this is required in order for Lightline to work correctly.
set noshowmode " Disables standard -INSERT-, -NORMAL-, etc... Lightline will provide a better looking one for us.
set t_Co=256 " This will 'force' terminals to use 256 colors, enabling Lightline and the colorscheme to look correct.
if has('termguicolors')
set termguicolors
endif
set background=dark " Cool programmers only use dark themes. It's good for your eyes man, really nice!
silent! colorscheme gruvbox-material " I love this theme. Big kudos to the developer(s) of this theme.
" LightLine Components: {
function! LightLineModified()
if &modified
return "+"
else
return ""
endif
endfunction
function! LightLineReadonly()
if &readonly
return ""
else
return ""
endif
endfunction
function! LightLineFugitive()
if exists("*FugitiveHead")
let branch = FugitiveHead()
return branch !=# '' ? ' '.branch : ' [No Head]' " Detached...?
else
return ' [No Head]'
endif
return ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != expand('%:f') ? expand('%:f') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
" }
" Windows: {
let g:gundo_width = 48
let g:tagbar_width = 48
let g:NERDTreeWinSize = 48
let g:NERDTreeMinimalUI = 1
let g:NERDTreeShowLineNumbers = 1
autocmd FileType nerdtree setlocal relativenumber
let g:tagbar_show_linenumbers = -1 " Global conf.
let g:gundo_preview_height = 13
let g:gundo_preview_bottom = 1
let g:NERDTreeWinPos = "right"
let g:gundo_right = 1 " right
let g:tagbar_map_showproto=""
let g:tagbar_autofocus = 1
let g:tagbar_compact = 1
let g:gundo_help = 0
" }
" Graphical: {
if has("gui_running")
set guioptions=i " Kill them toolbars!
if has("win32")
set renderoptions=type:directx " Use DirectX to e.g. render font with ligature.
set shellslash " Fix for Fugitive.
set guifont=Iosevka:h12,Fira\ Code:h10,Hack:h10 " All of these fonts are great!
" Below we load a DLL which removes the ugly GTK padding when going fullscreen.
map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
else
set guifont=Iosevka\ 12,Fira\ Code\ 10,Hack\ 10 " All of these fonts are great!
endif
set guiligatures=!*+-/:<=>\|~ " These are the only ligatures that Iosevka supports.
else
set mouse=a " Mouse support if needed.
endif
" A LightLine Theme
let g:lightline = {
\ 'colorscheme': 'gruvbox_material',
\ 'active': {
\ 'left': [[ 'mode' ], [ 'fugitive' ], [ 'filename' ]],
\ 'right': [[ 'linenums' ], [ 'fileencoding', 'fileformat' ], [ 'filetype']]
\ },
\ 'inactive': {
\ 'left': [[ 'mode' ], [ 'fugitive' ], [ 'filename' ]],
\ 'right': [[ 'linenums' ], [ 'fileencoding', 'fileformat' ], [ 'filetype']]
\ },
\ 'component': {
\ 'linenums': ' %3l %-2c',
\ 'filetype': '%{&ft!=#""?&ft:"[No Type]"}'
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified',
\ 'filename': 'LightLineFilename',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
let g:rainbow_active = 1 " Enable rainbow brackets...
" Rainbow brackets conflict w/ HLSL!
let g:rainbow_conf['separately'] = {
\ 'hlsl': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/^\@!\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ }
\ }
" }
set list " Enables the characters to be displayed.
" Useful for showing trailing whitespace and others.
set listchars=tab:›\ ,trail:•,extends:>,precedes:<,nbsp:_
" }
" Mappings: {
" Will remove latest search/replace highlight.
nnoremap <silent> <C-L> :silent! nohl<cr><C-L>
" Useful to toggle the NERDTree window back and forth.
noremap <silent> <leader>d :silent! NERDTreeToggle<cr>
" Same thing as above, but for the TagBar plugin...
noremap <silent> <leader>s :silent! TagbarToggle<cr>
" For another window, this time for the GUndo tree.
noremap <silent> <leader>g :silent! GundoToggle<cr>
" Here we have one of the things I and regular Vim
" disagree on. Both 'C' and 'D' behave as c$ or d$
" while Y behaves as yy. I don't like this at all.
nmap Y y$
" Shortcut Ag searching.
noremap <leader>f :Ack!
" Shortcut for Tabulate.
noremap <leader>a :Tab /
" }