-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.rc.vim
240 lines (203 loc) · 5.6 KB
/
view.rc.vim
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
"---------------------------------------------------------------------------
" View:
"
" Anywhere SID.
function! s:SID_PREFIX()
return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$')
endfunction
" Show line number.
set number
" Show <TAB> and <CR>
set list
if IsWindows()
set listchars=tab:>-,trail:-,extends:>,precedes:<
else
set listchars=tab:▸\ ,trail:-,extends:»,precedes:«,nbsp:%
endif
" Always display statusline.
set laststatus=2
" Height of command line.
set cmdheight=2
" Show command on statusline.
set showcmd
" Show title.
set title
" Title length.
set titlelen=95
" Title string.
let &titlestring="
\ %{expand('%:p:~:.')}%(%m%r%w%)
\ %<\(%{".s:SID_PREFIX()."strwidthpart(
\ fnamemodify(&filetype ==# 'vimfiler' ?
\ substitute(b:vimfiler.current_dir, '.\\zs/$', '', '') : getcwd(), ':~'),
\ &columns-len(expand('%:p:.:~')))}\) - VIM"
" Set tabline.
function! s:my_tabline() "{{{
let s = ''
for i in range(1, tabpagenr('$'))
let bufnrs = tabpagebuflist(i)
let bufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears
let no = i " display 0-origin tabpagenr.
let mod = getbufvar(bufnr, '&modified') ? '!' : ' '
" Use gettabvar().
let title =
\ !exists('*gettabvar') ?
\ fnamemodify(bufname(bufnr), ':t') :
\ gettabvar(i, 'title') != '' ?
\ gettabvar(i, 'title') :
\ fnamemodify((i == tabpagenr() ?
\ getcwd() : gettabvar(i, 'cwd')), ':t')
let title = '[' . title . ']'
let s .= '%'.i.'T'
let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
let s .= title
let s .= mod
let s .= '%#TabLineFill#'
endfor
let s .= '%#TabLineFill#%T%=%#TabLine#'
return s
endfunction "}}}
let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()'
set showtabline=0
" Set statusline.
let &statusline="%{winnr('$')>1?'['.winnr().'/'.winnr('$')"
\ . ".(winnr('#')==winnr()?'#':'').']':''}\ "
\ . "%{(&previewwindow?'[preview] ':'').expand('%:t')}"
\ . "\ %=%{(winnr('$')==1 || winnr('#')!=winnr()) ?
\ '['.(&filetype!=''?&filetype.',':'')"
\ . ".(&fenc!=''?&fenc:&enc).','.&ff.']' : ''}"
\ . "%m%{printf(' %4d/%d',line('.'),line('$'))}"
" Turn down a long line appointed in 'breakat'
set linebreak
let &showbreak='↪ '
set breakat=\ \ ;:,!?
" Wrap conditions.
set whichwrap+=<,>,[,],b,s,~
set wrap
" Do not display greetings message at the time of Vim start.
set shortmess=aTI
" Disable bell.
set t_vb=
set novisualbell
" Display candidate supplement.
set wildmenu
set wildmode=list:longest,full
set wildignorecase
" Display all the information of the tag by the supplement of the Insert mode.
set showfulltag
" Can supplement a tag in a command-line.
set wildoptions=tagfile
" Always show content after scroll
set scrolloff=4
" Minimum number of lines to scroll
" set scrolljump=5
" Disable menu
let g:did_install_default_menus = 1
" Enable folding.
set foldenable
" set foldmethod=expr
set foldmethod=marker
" Show folding level.
set foldcolumn=1
set fillchars=vert:\|
set commentstring=%s
if exists('*FoldCCtext')
" Use FoldCCtext().
set foldtext=FoldCCtext()
endif
if !&verbose
" Enable spell check.
set spelllang=en_us
endif
" Report changes.
set report=0
" Maintain a current line at the time of movement as much as possible.
set nostartofline
" Splitting a window will put the new window below the current one.
set splitbelow
" Splitting a window will put the new window right the current one.
set splitright
" Set minimal width for current window.
set winwidth=30
" Set minimal height for current window.
" set winheight=20
set winheight=1
" Set maximam maximam command line window.
set cmdwinheight=5
" No equal window size.
set noequalalways
" Adjust window size of preview and help.
set previewheight=8
set helpheight=12
" Don't redraw while macro executing.
set lazyredraw
set ttyfast
" When a line is long, do not omit it in @.
set display=lastline
" Display an invisible letter with hex format.
"set display+=uhex
" View setting.
set viewdir=$CACHE/vim_view viewoptions-=options viewoptions+=slash,unix
function! s:strwidthpart(str, width) "{{{
if a:width <= 0
return ''
endif
let ret = a:str
let width = s:wcswidth(a:str)
while width > a:width
let char = matchstr(ret, '.$')
let ret = ret[: -1 - len(char)]
let width -= s:wcswidth(char)
endwhile
return ret
endfunction"}}}
set cursorline
if v:version >= 703
" For conceal.
set conceallevel=2 concealcursor=iv
set colorcolumn=0
" Use builtin function.
function! s:wcswidth(str)
return strwidth(a:str)
endfunction
finish
endif
function! s:wcswidth(str)
if a:str =~# '^[\x00-\x7f]*$'
return strlen(a:str)
end
let mx_first = '^\(.\)'
let str = a:str
let width = 0
while 1
let ucs = char2nr(substitute(str, mx_first, '\1', ''))
if ucs == 0
break
endif
let width += s:_wcwidth(ucs)
let str = substitute(str, mx_first, '', '')
endwhile
return width
endfunction
" UTF-8 only.
function! s:_wcwidth(ucs)
let ucs = a:ucs
if (ucs >= 0x1100
\ && (ucs <= 0x115f
\ || ucs == 0x2329
\ || ucs == 0x232a
\ || (ucs >= 0x2e80 && ucs <= 0xa4cf
\ && ucs != 0x303f)
\ || (ucs >= 0xac00 && ucs <= 0xd7a3)
\ || (ucs >= 0xf900 && ucs <= 0xfaff)
\ || (ucs >= 0xfe30 && ucs <= 0xfe6f)
\ || (ucs >= 0xff00 && ucs <= 0xff60)
\ || (ucs >= 0xffe0 && ucs <= 0xffe6)
\ || (ucs >= 0x20000 && ucs <= 0x2fffd)
\ || (ucs >= 0x30000 && ucs <= 0x3fffd)
\ ))
return 2
endif
return 1
endfunction
"}}}