-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
362 lines (277 loc) · 9.09 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
"
" VIMRC CONFIG
"
" Sections:
"-> General
"-> VIM User Interface
"-> Colors and Fonts
"-> Files and Backups
"-> Text, Tab, and Indentation
"-> Plug-ins
"-> Plug-in Configuration
"-> Helper Functions
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable full compatibility with Vi
set nocompatible
" Sets how many lines of history VIM has to remember
set history=500
" Enable filetype detection
filetype on
" Enable and load plugins for the detected filetype
filetype plugin on
filetype indent on
" Enable ALE plugin autocompletion
let g:ale_linters = {
\ 'vhdl': ['hdl_checker'],
\}
let g:ale_completion_enabled=1
" Set file format to Unix to help with line endings in Linux
set fileformat=unix
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM User Interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Enable auto completion menu after pressing TAB
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif
" Height of the command bar
set cmdheight=1
" Show matching words, highlight, ignore case during search
set showmatch
set hlsearch
set ignorecase
" Try to be smart about cases while searching
set smartcase
" Makes search act like search in modern browsers
set incsearch
" Remap to remove highlighting
nnoremap <CR> :noh<CR><CR>:<backspace>
" Don't redraw while executing macros
set lazyredraw
" Turn magic on for regular expressions
set magic
" Show matching brackets when cursor is over them
set showmatch
" Correct backspacing
set backspace=indent,eol,start
" Autoclose brackets and move cursor between them
inoremap ( ()<Left>
inoremap [ []<Left>
inoremap { {}<Left>
inoremap <expr> <CR> search('{\%#}', 'n') ? "\<CR>\<CR>\<Up>\<C-f>" : "\<CR>"
" Get rid of annoying bell
set belloff=all
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax on
" Set regular expression engine automatically
set regexpengine=0
set t_Co=256
" Set colourscheme
colorscheme molokai
" Enable true color support
if (empty($TMUX) && getenv('TERM_PROGRAM') != 'Apple_Terminal')
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
endif
" Set Visual mode highlighting to different colour
autocmd ColorScheme * hi Visual guibg=darkblue
" Add line numbers
set number
" Display cursorline and cursorcolumn ONLY in active window.
set cursorline cursorcolumn
augroup cursor_off
autocmd!
autocmd WinLeave * set nocursorline nocursorcolumn
autocmd WinEnter * set cursorline cursorcolumn
augroup END
" Show partial command in the last line of the screen
set showcmd
" Don't show current mode on the last line, airline plugin takes care of that
set noshowmode
" Set the GUI font used
set guifont=SauceCodePro\ NFM\ SemiBold:h16
" Set utf8 as standard encoding
set encoding=utf8
" Set conceal level for NERDTree-devicon
set conceallevel=3
" Add sign column and reduce updatetime for GitGutter signs
set signcolumn=auto
set updatetime=100
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, Backups and Undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Temp file directories
set undodir=$HOME/.vim/tmp/undo/ " undo files
set backupdir=$HOME/.vim/tmp/backup/ " backups
set directory=$HOME/.vim/tmp/swap/ " swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, Tab, and Indentation
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" 1 tab = 4 spaces
set shiftwidth=4
set tabstop=4
" Disable text wrapping
set nowrap
" Auto indenting, smart indenting
set autoindent
set smartindent
""""""""""""""""""""""""""""""
" => Plug-ins
""""""""""""""""""""""""""""""
" List of plug-ins
call plug#begin()
Plug 'itchyny/lightline.vim'
Plug 'dense-analysis/ale'
Plug 'maximbaz/lightline-ale'
Plug 'preservim/nerdtree'
Plug 'Yggdroot/indentLine'
Plug 'justinmk/vim-sneak'
Plug 'tpope/vim-commentary'
Plug 'mhinz/vim-startify'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" Load icon plugin last
Plug 'ryanoasis/vim-devicons'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plug-in Configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Start NERDTree and vim-startify as splashscreen
autocmd VimEnter *
\ if !argc()
\ | Startify
\ | NERDTree
\ | wincmd w
\ | endif
" lightline configuration
" Set the colorscheme for lightline
let g:lightline = { 'colorscheme' : 'default' }
" lightline-ale integration and devicon addition
let g:lightline.component_expand = {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_infos': 'lightline#ale#infos',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ }
let g:lightline.component_type = {
\ 'linter_checking': 'right',
\ 'linter_infos': 'right',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'right',
\ }
let g:lightline.active = {
\ 'left' : [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'absolutepath', 'modified' ] ],
\ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ],
\ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype'] ] }
let g:lightline#ale#indicator_checking = "\uf110"
let g:lightline#ale#indicator_infos = "\uf129"
let g:lightline#ale#indicator_warnings = "\uf071"
let g:lightline#ale#indicator_errors = "\uf05e"
let g:lightline#ale#indicator_ok = "\uf00c"
let g:lightline.component_function = {
\ 'gitbranch': 'MyFugitiveHead',
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ }
" indentline configuration
let g:indentLine_char_list = ['¦']
let g:indentLine_setColors = 1
" Set label mode for vim-sneak
let g:sneak#label = 1
" Make NERDTree change CWD automatically
let g:NERDTreeChDirMode = 2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper Functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function MyFugitiveHead()
let head = FugitiveHead()
if head != ""
let head = "\uf126 " .. head
endif
return head
endfunction
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
endfunction
" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
set diffexpr=MyDiff()
endif
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" EOF - VIMRC CONFIG
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""