-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
220 lines (181 loc) · 6.07 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
" Airline
let g:airline_powerline_fonts = 1 " Must be set before plugin is loaded
packloadall
helptags ~/.vim/pack
" Airline
let g:airline_theme = 'solarized'
let g:airline_symbols.linenr = ''
let g:airline_symbols.maxlinenr = ''
let g:airline_mode_map = {
\ '__' : '-',
\ 'c' : 'C',
\ 'i' : 'I',
\ 'ic' : 'I',
\ 'ix' : 'I',
\ 'n' : 'N',
\ 'ni' : 'N',
\ 'no' : 'N',
\ 'R' : 'R',
\ 'Rv' : 'V-REPLACE',
\ 's' : 'S',
\ 'S' : 'S-LINE',
\ '' : 'S-BLOCK',
\ 't' : 'T',
\ 'v' : 'V',
\ 'V' : 'V-LINE',
\ '' : 'V-BLOCK',
\ }
call airline#parts#define('neomake', {'function': 'BuildStatus'})
let g:airline_section_a = airline#section#create_left([
\'mode', 'crypt', 'paste', 'keymap', 'capslock', 'xkblayout', 'iminsert']) " Removed spell
let g:airline_section_x = '' " Normally file type
let g:airline_section_y = airline#section#create(['neomake']) " Normally encoding
let g:airline_section_z = airline#section#create(['windowswap', 'obsession', 'linenr', 'maxlinenr', ':%3v'])
syntax on
" Color scheme
set background=light
let g:solarized_termcolors=256
colorscheme solarized
"Tabs
filetype indent plugin on
set shiftwidth=4 " Reindent width (<< >>)
set tabstop=4 " Columns to a tab for display purposes
set softtabstop=4 " Columns used when hitting Tab in Insert mode
set expandtab " Tab key = spaces in Insert mode
set smarttab " Insert/delete blanks in front of a line according to
" shiftwidth instead of tabstop
set cinoptions=(4,t0,l1,:0
" Python doesn't do well with smartindent
autocmd FileType python set nosmartindent
"Search
set ignorecase " Ignore case in search patterns and in tags file
set smartcase " If search pattern has uppercase, search case-sensitively
set incsearch " Turn on incremental search
"set hlsearch " Highlight search matches
"Brackets
set showmatch " Highlights the matching bracket
"Splits
set splitright
set splitbelow
nnoremap <silent> <Leader>= :resize +5<CR>
nnoremap <silent> <Leader>- :resize -5<CR>
"Columns
set formatoptions+=t
"Breaking
let &showbreak = "↪>\ "
set breakindent
set linebreak
"Scrolling
set scrolloff=5 " Keeps at least five lines above/below current line
set sidescroll=1
"Other
set showcmd
set number " Line numbers
set ruler " Show row, column on the status line
set nocompatible
set title " Show filename in console title
set tags=tags;/ " Searches for tags files in parent directories
set laststatus=2 " Keeps statusline showing at all times
set cmdheight=2 " Command bar is two rows high
set wildmenu " Tab-completions appear as a menu
set spell spelllang=en_us
set backspace=2 " Make backspace work like you might imagine it would
"CScope
if has("cscope")
set cscopetag " Use cscope and ctags for ctrl-]
set csto=1 " Prefer ctags to cscope
" Add any cscope database in the cwd
if filereadable("cscope.out")
cs add cscope.out
endif
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif
" Trailing whitespace
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" Don't have an annoying delay after hitting escape
set timeoutlen=1000 ttimeoutlen=0
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" From https://github.com/kovidgoyal/kitty/issues/108
" vim hardcodes background color erase even if the terminfo file does
" not contain bce (not to mention that libvte based terminals
" incorrectly contain bce in their terminfo files). This causes
" incorrect background rendering when using a color theme with a
" background color.
let &t_ut=''
" Neomake
let g:neomake_serialize = 1
let g:neomake_serialize_abort_on_error = 1
let g:neomake_open_list = 2
let g:neomake_build_all_maker_buffer_output = 0
call neomake#configure#automake('w') " Call Neomake on file write
function! HandleBuildFinished()
for job in g:neomake_hook_context.finished_jobs
if job.exit_code != 0
let b:build_status = ''
return
endif
endfor
let b:build_status = ''
endfunction
function! HandleJobInit()
let b:build_status = 'Building...'
endfunction
function! BuildStatus()
return get(b:, 'build_status', '')
endfunction
augroup neomake_hooks
au!
autocmd User NeomakeJobInit :call HandleJobInit()
autocmd User NeomakeFinished :call HandleBuildFinished()
augroup END
" ___ _
" / _ \ _ _ _ __ ___ _ _| | ___
" | | | | | | | '_ ` _ \| | | | |/ _ \
" | |_| | |_| | | | | | | |_| | | (_) |
" \__\_\\__,_|_| |_| |_|\__,_|_|\___/
autocmd BufRead,BufNewFile *.h,*.c set filetype=c
set makeprg=build
let g:neomake_build_all_maker = {
\ 'exe': 'build',
\ 'args': ['--flavor=debug', '--keep-going'],
\ }
let g:neomake_build_tags_maker = {
\ 'exe': 'build',
\ 'args': ['tags'],
\ }
let g:neomake_c_gen_maker = {
\ 'exe': 'qonstruct/generate.py',
\ 'args': ['--flavor', 'debug', 'generate', '%'],
\ 'append_file': 0,
\ }
let g:neomake_c_build_maker = {
\ 'exe': 'qonstruct/cc.py',
\ 'args': ['--flavor', 'debug', 'proof', '%'],
\ 'append_file': 0,
\ }
let g:neomake_c_lint_maker = {
\ 'exe': 'lint/c/__main__.py',
\ 'errorformat': '%f:%l: %m',
\ 'args': ['%'],
\ 'append_file': 0,
\ }
let g:neomake_python_lint_maker = {
\ 'exe': 'lint/py/__main__.py',
\ 'args': ['%'],
\ 'append_file': 0,
\ }
let g:neomake_c_enabled_makers = ['gen', 'build', 'lint']
let g:neomake_python_enabled_makers = ['lint']
let g:neomake_enabled_makers = ['build_all', 'build_tags']