-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
executable file
·158 lines (131 loc) · 4.28 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
set ai et sts=4 sw=4 ts=4 nocompatible bs=2 bg=dark hlsearch incsearch
set ruler visualbell noerrorbells t_vb= nojoinspaces
set tw=79
set number
language en_US.UTF-8
set spelllang=en_us
" Disable auto-wrapping both display and hard wrapping
set nowrap
set fo-=t
" Optionally show line breaks. We don't really need to show these anymore, now
" that we are highlighting too long lines. The highlight color shows us that
" the line is too long (without making copy paste suck).
set showbreak=
" set showbreak=--->
" set isk+=_,$,@,%,#,- " none of these should be word dividers, so make them
" not be
" Default to unix, and support detection of dos and mac file formats
set ffs=unix,dos,mac
" Default to UTF-8 encoding
set encoding=utf-8
" NI Specific
" set sts=3 sw=3 ts=3
" Linux Kernel Specific
" set noet sts=8 sw=8 ts=8
" Google Style
" set sts=2 sw=2 ts=2
syntax on
colorscheme desert256
" set wildmenu
" Highlight too-long lines (and optionally trailing whitespace).
highlight default link TooLong Error
highlight default link TrailinWhites MatchParen
function! HighlightTooLongLines(highlight_trailing_whitespace)
let l:regex_rightmargin = []
let l:regex_trailinwhites = []
if a:highlight_trailing_whitespace != 0
call add(l:regex_trailinwhites, '\s\+$')
endif
if &textwidth != 0
call add(l:regex_rightmargin, '\%>' . &textwidth . 'v.\+')
endif
if len(l:regex_rightmargin) > 0
let l:regex = '/\(' . join(l:regex_rightmargin, '\|') . '\)/'
let l:match = 'match TooLong ' . l:regex
exec l:match
else
match none
endif
if len(l:regex_trailinwhites) > 0
let l:regex = '/\(' . join(l:regex_trailinwhites, '\|') . '\)/'
let l:match = '2match TrailinWhites ' . l:regex
exec l:match
else
2match none
endif
endfunction
augroup filetypedetect
autocmd WinEnter,BufNewFile,BufRead * call HighlightTooLongLines(1)
augroup end
" Highlight trailing whitespace when not in insert mode.
autocmd InsertEnter * call HighlightTooLongLines(0)
autocmd InsertLeave * call HighlightTooLongLines(1)
" Markdown type discovery
autocmd BufNewFile,BufFilePre,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md set filetype=markdown
" Mbed TLS test files are C with a .function postfix
autocmd BufNewFile,BufFilePre,BufRead *.function set filetype=c
" GLSL shaders
autocmd BufNewFile,BufRead *.vert,*.tesc,*.tese,*.geom,*.frag,*.comp set filetype=glsl
autocmd BufNewFile,BufRead *.glsl,*.glvs,*.glfs,*.vs,*.fs set ft=glsl
autocmd BufNewFile,BufRead *.rgen,*.rmiss,*.rchit,*.rahit,*.rint,*.rcall set filetype=glsl
" Tabs will be listed
set list listchars=tab:»·
augroup makefile
au!
au FileType make,automake setlocal noet sts=0 ts=8 sw=8
augroup END
augroup golang
au!
au FileType go setlocal noet sts=0 ts=8 sw=8
augroup END
augroup gitcommit
au!
au FileType gitcommit setlocal tw=72 spell fo+=t
augroup END
augroup patch
au!
au FileType gitcommit setlocal tw=72 spell fo+=t
augroup END
augroup markdown
au!
au FileType markdown setlocal spell
augroup END
augroup ft_asm
au!
au FileType asm setlocal noet sts=8 sw=8 ts=8
augroup END
if has("gui_running")
set guioptions=egrLt
set guioptions=-s
" Windows Specific
" set guifont=Monaco:h8:cANSI
" set guifont=Lucida_Console:h9:cANSI
" Mac Specific
" set guifont=Menlo:h14
else
set bg=dark
if &term == "xterm" || &term == "xterm-color" || &term == "xterm-256color" || &term == "screen-256color-bce" || &term == "screen-256color" || &term == "rxvt-unicode-256color"
set t_Co=256
colorscheme desert256
endif
endif
fun! <SID>StripTrailingWhitespaces()
" Save the cursor location
let l = line(".")
let c = col(".")
" Preserve search position by using call
call %s/\s\+$//e
" Restore the cursor location
call cursor(l, c)
endfun
" gc ("garbage collect") strips all trailing whitespace
nmap gc :%s/\s\+$//<CR>
" clang-format
" https://clang.llvm.org/docs/ClangFormat.html
if has("macunix")
map <C-K> :pyf /opt/homebrew/Cellar/clang-format/12.0.1/share/clang/clang-format.py<cr>
imap <C-K> <c-o>:pyf /opt/homebrew/Cellar/clang-format/12.0.1/share/clang/clang-format.py<cr>
else
map <C-K> :py3f /usr/local/llvm90/share/clang/clang-format.py<cr>
imap <C-K> <c-o>:py3f /usr/local/llvm90/share/clang/clang-format.py<cr>
endif