-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
84 lines (74 loc) · 2.16 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
set hlsearch " highlight all search results
set ignorecase " do case insensitive search
set incsearch " show incremental search results as you type
set noswapfile " disable swap file
" set number " display line number
" :highlight LineNr ctermfg=DarkGrey
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab " disable swap file
set noshiftround
" command W w !sudo tee % > /dev/null " :W sudo saves the file
" https://jovicailic.org/2015/05/saving-read-only-files-in-vim-sudo-trick/
cmap w!! w !sudo tee % >/dev/null
" https://www.tdaly.co.uk/projects/vim-statusline-generator/
set laststatus=2
set statusline=
set statusline+=\
set statusline+=%{StatuslineMode()}
set statusline+=\
set statusline+=%F
set statusline+=\
set statusline+=%{b:gitbranch}
set statusline+=%=
set statusline+=%y\ \[%{&ff}\]\ \[%{strlen(&fenc)?&fenc:'none'}\]
set statusline+=\
set statusline+=column:\[%c\]
set statusline+=\
set statusline+=line:\[%l/%L\]
set statusline+=\
set statusline+=%m
function! StatuslineMode()
let l:mode=mode()
if l:mode==#"n"
return "NORMAL"
elseif l:mode==?"v"
return "VISUAL"
elseif l:mode==#"i"
return "INSERT"
elseif l:mode==#"R"
return "REPLACE"
elseif l:mode==?"s"
return "SELECT"
elseif l:mode==#"t"
return "TERMINAL"
elseif l:mode==#"c"
return "COMMAND"
elseif l:mode==#"!"
return "SHELL"
endif
endfunction
function! StatuslineGitBranch()
let b:gitbranch=""
if &modifiable
try
let l:dir=expand('%:p:h')
let l:gitrevparse = system("git -C ".l:dir." rev-parse --abbrev-ref HEAD")
if !v:shell_error
let b:gitbranch="(".substitute(l:gitrevparse, '\n', '', 'g').") "
endif
catch
endtry
endif
endfunction
augroup GetGitBranch
autocmd!
" autocmd VimEnter,WinEnter,BufEnter * call StatuslineGitBranch()
autocmd BufEnter * let b:git_branch = StatuslineGitBranch()
augroup END
" vimdiff https://www.codyhiar.com/blog/vimdiff-better-highlighting/
highlight DiffAdd cterm=BOLD ctermfg=0 ctermbg=2
highlight DiffDelete cterm=BOLD ctermfg=0 ctermbg=1
highlight DiffChange cterm=BOLD ctermfg=0 ctermbg=6
highlight DiffText cterm=BOLD ctermfg=0 ctermbg=6