-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim-airline.patch
54 lines (54 loc) · 1.98 KB
/
vim-airline.patch
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
diff -ruN '--exclude=.git' a/autoload/airline/init.vim b/autoload/airline/init.vim
--- a/autoload/airline/init.vim 2017-02-09 03:45:47.904397628 -0200
+++ b/autoload/airline/init.vim 2017-02-09 03:45:56.300306814 -0200
@@ -140,11 +140,7 @@
let g:airline_section_y = airline#section#create_right(['ffenc'])
endif
if !exists('g:airline_section_z')
- if winwidth(0) > 80
- let g:airline_section_z = airline#section#create(['windowswap', 'obsession', '%3p%%'.spc, 'linenr', 'maxlinenr', spc.':%3v'])
- else
- let g:airline_section_z = airline#section#create(['%3p%%'.spc, 'linenr', ':%3v'])
- endif
+ let g:airline_section_z = airline#section#create(['windowswap', '%10{airline#util#getcharcode()}'.spc, '%3p%%'.spc, 'linenr', ':%3c '])
endif
if !exists('g:airline_section_error')
let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic', 'eclim', 'neomake_error_count', 'ale_error_count'])
diff -ruN '--exclude=.git' a/autoload/airline/util.vim b/autoload/airline/util.vim
--- a/autoload/airline/util.vim 2017-02-09 03:45:47.904397628 -0200
+++ b/autoload/airline/util.vim 2017-02-09 03:45:56.300306814 -0200
@@ -105,3 +105,34 @@
return system(a:cmd)
endfunction
endif
+
+function! airline#util#getcharcode()
+ " Get the output of :ascii
+ redir => ascii
+ silent! ascii
+ redir END
+
+ if match(ascii, 'NUL') != -1
+ return '∅ EMPTY ⏚ '
+ endif
+
+ " Zero pad hex values
+ let nrformat = '0x%02x'
+
+ let encoding = (&fenc == '' ? &enc : &fenc)
+
+ if encoding == 'utf-8'
+ " Zero pad with 4 zeroes in unicode files
+ let nrformat = '0x%04x'
+ endif
+
+ " Get the character and the numeric value from the return value of :ascii
+ " This matches the two first pieces of the return value, e.g.
+ " "<F> 70" => char: 'F', nr: '70'
+ let [str, char, nr; rest] = matchlist(ascii, '\v\<(.{-1,})\>\s*([0-9]+)')
+
+ " Format the numeric value
+ let nr = printf(nrformat, nr)
+
+ return "➤ '". char ."' ". nr
+endfunction