forked from rafi/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
82 lines (68 loc) · 2.14 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
" https://github.com/rafi/vim-config
" Maintainer: Rafael Bodill
" Runtime and Plugins
" ===
if &compatible
" vint: -ProhibitSetNoCompatible
set nocompatible
" vint: +ProhibitSetNoCompatible
endif
" Set main configuration directory as parent directory
let $VIM_PATH = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
function! s:source_file(path, ...)
" Source user configuration files with set/global sensitivity
let use_global = get(a:000, 0, ! has('vim_starting'))
let abspath = resolve($VIM_PATH . '/' . a:path)
if ! use_global
execute 'source' fnameescape(abspath)
return
endif
let tempfile = tempname()
let content = map(readfile(abspath),
\ "substitute(v:val, '^\\W*\\zsset\\ze\\W', 'setglobal', '')")
try
call writefile(content, tempfile)
execute printf('source %s', fnameescape(tempfile))
finally
if filereadable(tempfile)
call delete(tempfile)
endif
endtry
endfunction
" Initialize startup settings
if has('vim_starting')
" Use spacebar as leader and ; as secondary-leader
" Required before loading plugins!
let g:mapleader="\<Space>"
let g:maplocalleader=';'
" Release keymappings prefixes, evict entirely for use of plug-ins.
nnoremap <Space> <Nop>
xnoremap <Space> <Nop>
nnoremap , <Nop>
xnoremap , <Nop>
nnoremap ; <Nop>
xnoremap ; <Nop>
" Vim only, Linux terminal settings
if ! has('nvim') && ! has('gui_running') && ! has('win32') && ! has('win64')
call s:source_file('config/terminal.vim')
endif
endif
" Load user scripts with confidential information
" or pre-settings like g:elite_mode
if filereadable($VIM_PATH . '/.vault.vim')
call s:source_file('.vault.vim')
endif
" Initialize plugin-manager and load main config files
call s:source_file('config/init.vim')
call s:source_file('config/plugins/all.vim')
" Initialize all my configurations
call s:source_file('config/general.vim')
call s:source_file('config/filetype.vim')
call s:source_file('config/mappings.vim')
call s:source_file('config/theme.vim')
" Load user custom local settings
if filereadable($VIM_PATH . '/config/local.vim')
call s:source_file('config/local.vim')
endif
set secure
" vim: set ts=2 sw=2 tw=80 noet :