From be85ae95c38edb120b6fa31456647d5e602fd46a Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 3 Feb 2014 13:48:53 +0000 Subject: [PATCH] Unicode completion plugin. --- .vim/autoload/unicode.vim | 668 ++++++++++++++++++++++++++++++++++++++++++++++ .vim/doc/unicode.txt | 250 +++++++++++++++++ .vim/plugin/unicode.vim | 43 +++ 3 files changed, 961 insertions(+) create mode 100644 .vim/autoload/unicode.vim create mode 100644 .vim/doc/unicode.txt create mode 100644 .vim/plugin/unicode.vim diff --git a/.vim/autoload/unicode.vim b/.vim/autoload/unicode.vim new file mode 100644 index 0000000..a84a492 --- /dev/null +++ b/.vim/autoload/unicode.vim @@ -0,0 +1,668 @@ +" unicodePlugin : A completion plugin for Unicode glyphs +" Author: C.Brabandt +" Version: 0.17 +" Copyright: (c) 2009 by Christian Brabandt +" The VIM LICENSE applies to unicode.vim, and unicode.txt +" (see |copyright|) except use "unicode" instead of "Vim". +" No warranty, express or implied. +" *** *** Use At-Your-Own-Risk! *** *** +" +" GetLatestVimScripts: 2822 17 :AutoInstall: unicode.vim + +" --------------------------------------------------------------------- + + +if exists("g:unicode_URL") + let s:unicode_URL=g:unicode_URL +else + "let s:unicode_URL='http://www.unicode.org/Public/UNIDATA/Index.txt' + let s:unicode_URL='http://www.unicode.org/Public/UNIDATA/UnicodeData.txt' +endif +if !exists("g:UnicodeShowPreviewWindow") + let g:UnicodeShowPreviewWindow = 0 +endif + +" HTML entitities +let s:html = {} +let s:html[0x0022] = """ +let s:html[0x0026] = "&" +let s:html[0x0027] = "'" +let s:html[0x003C] = "<" +let s:html[0x003E] = ">" +let s:html[0x0022] = """ +let s:html[0x0026] = "&" +let s:html[0x0027] = "'" +let s:html[0x003C] = "<" +let s:html[0x003E] = ">" +let s:html[0x00A0] = " " +let s:html[0x00A1] = "¡" +let s:html[0x00A2] = "¢" +let s:html[0x00A3] = "£" +let s:html[0x00A4] = "¤" +let s:html[0x00A5] = "¥" +let s:html[0x00A6] = "¦" +let s:html[0x00A7] = "§" +let s:html[0x00A8] = "¨" +let s:html[0x00A9] = "©" +let s:html[0x00AA] = "ª" +let s:html[0x00AB] = "«" +let s:html[0x00AC] = "¬" +let s:html[0x00AD] = "­" +let s:html[0x00AE] = "®" +let s:html[0x00AF] = "¯" +let s:html[0x00B0] = "°" +let s:html[0x00B1] = "±" +let s:html[0x00B2] = "²" +let s:html[0x00B3] = "³" +let s:html[0x00B4] = "´" +let s:html[0x00B5] = "µ" +let s:html[0x00B6] = "¶" +let s:html[0x00B7] = "·" +let s:html[0x00B8] = "¸" +let s:html[0x00B9] = "¹" +let s:html[0x00BA] = "º" +let s:html[0x00BB] = "»" +let s:html[0x00BC] = "¼" +let s:html[0x00BD] = "½" +let s:html[0x00BE] = "¾" +let s:html[0x00BF] = "¿" +let s:html[0x00C0] = "À" +let s:html[0x00C1] = "Á" +let s:html[0x00C2] = "Â" +let s:html[0x00C3] = "Ã" +let s:html[0x00C4] = "Ä" +let s:html[0x00C5] = "Å" +let s:html[0x00C6] = "Æ" +let s:html[0x00C7] = "Ç" +let s:html[0x00C8] = "È" +let s:html[0x00C9] = "É" +let s:html[0x00CA] = "Ê" +let s:html[0x00CB] = "Ë" +let s:html[0x00CC] = "Ì" +let s:html[0x00CD] = "Í" +let s:html[0x00CE] = "Î" +let s:html[0x00CF] = "Ï" +let s:html[0x00D0] = "Ð" +let s:html[0x00D1] = "Ñ" +let s:html[0x00D2] = "Ò" +let s:html[0x00D3] = "Ó" +let s:html[0x00D4] = "Ô" +let s:html[0x00D5] = "Õ" +let s:html[0x00D6] = "Ö" +let s:html[0x00D7] = "×" +let s:html[0x00D8] = "Ø" +let s:html[0x00D9] = "Ù" +let s:html[0x00DA] = "Ú" +let s:html[0x00DB] = "Û" +let s:html[0x00DC] = "Ü" +let s:html[0x00DD] = "Ý" +let s:html[0x00DE] = "Þ" +let s:html[0x00DF] = "ß" +let s:html[0x00E0] = "à" +let s:html[0x00E1] = "á" +let s:html[0x00E2] = "â" +let s:html[0x00E3] = "ã" +let s:html[0x00E4] = "ä" +let s:html[0x00E5] = "å" +let s:html[0x00E6] = "æ" +let s:html[0x00E7] = "ç" +let s:html[0x00E8] = "è" +let s:html[0x00E9] = "é" +let s:html[0x00EA] = "ê" +let s:html[0x00EB] = "ë" +let s:html[0x00EC] = "ì" +let s:html[0x00ED] = "í" +let s:html[0x00EE] = "î" +let s:html[0x00EF] = "ï" +let s:html[0x00F0] = "ð" +let s:html[0x00F1] = "ñ" +let s:html[0x00F2] = "ò" +let s:html[0x00F3] = "ó" +let s:html[0x00F4] = "ô" +let s:html[0x00F5] = "õ" +let s:html[0x00F6] = "ö" +let s:html[0x00F7] = "÷" +let s:html[0x00F8] = "ø" +let s:html[0x00F9] = "ù" +let s:html[0x00FA] = "ú" +let s:html[0x00FB] = "û" +let s:html[0x00FC] = "ü" +let s:html[0x00FD] = "ý" +let s:html[0x00FE] = "þ" +let s:html[0x00FF] = "ÿ" +let s:html[0x0152] = "Œ" +let s:html[0x0153] = "œ" +let s:html[0x0160] = "Š" +let s:html[0x0161] = "š" +let s:html[0x0178] = "Ÿ" +let s:html[0x0192] = "ƒ" +let s:html[0x02C6] = "ˆ" +let s:html[0x02DC] = "˜" +let s:html[0x0391] = "Α" +let s:html[0x0392] = "Β" +let s:html[0x0393] = "Γ" +let s:html[0x0394] = "Δ" +let s:html[0x0395] = "Ε" +let s:html[0x0396] = "Ζ" +let s:html[0x0397] = "Η" +let s:html[0x0398] = "Θ" +let s:html[0x0399] = "Ι" +let s:html[0x039A] = "Κ" +let s:html[0x039B] = "Λ" +let s:html[0x039C] = "Μ" +let s:html[0x039D] = "Ν" +let s:html[0x039E] = "Ξ" +let s:html[0x039F] = "Ο" +let s:html[0x03A0] = "Π" +let s:html[0x03A1] = "Ρ" +let s:html[0x03A3] = "Σ" +let s:html[0x03A4] = "Τ" +let s:html[0x03A5] = "Υ" +let s:html[0x03A6] = "Φ" +let s:html[0x03A7] = "Χ" +let s:html[0x03A8] = "Ψ" +let s:html[0x03A9] = "Ω" +let s:html[0x03B1] = "α" +let s:html[0x03B2] = "β" +let s:html[0x03B3] = "γ" +let s:html[0x03B4] = "δ" +let s:html[0x03B5] = "ε" +let s:html[0x03B6] = "ζ" +let s:html[0x03B7] = "η" +let s:html[0x03B8] = "θ" +let s:html[0x03B9] = "ι" +let s:html[0x03BA] = "κ" +let s:html[0x03BB] = "λ" +let s:html[0x03BC] = "μ" +let s:html[0x03BD] = "ν" +let s:html[0x03BE] = "ξ" +let s:html[0x03BF] = "ο" +let s:html[0x03C0] = "π" +let s:html[0x03C1] = "ρ" +let s:html[0x03C2] = "ς" +let s:html[0x03C3] = "σ" +let s:html[0x03C4] = "τ" +let s:html[0x03C5] = "υ" +let s:html[0x03C6] = "φ" +let s:html[0x03C7] = "χ" +let s:html[0x03C8] = "ψ" +let s:html[0x03C9] = "ω" +let s:html[0x03D1] = "ϑ" +let s:html[0x03D2] = "ϒ" +let s:html[0x03D6] = "ϖ" +let s:html[0x2002] = " " +let s:html[0x2003] = " " +let s:html[0x2009] = " " +let s:html[0x200C] = "‌" +let s:html[0x200D] = "‍" +let s:html[0x200E] = "‎" +let s:html[0x200F] = "‏" +let s:html[0x2013] = "–" +let s:html[0x2014] = "—" +let s:html[0x2018] = "‘" +let s:html[0x2019] = "’" +let s:html[0x201A] = "‚" +let s:html[0x201C] = "“" +let s:html[0x201D] = "”" +let s:html[0x201E] = "„" +let s:html[0x2020] = "†" +let s:html[0x2021] = "‡" +let s:html[0x2022] = "•" +let s:html[0x2026] = "…" +let s:html[0x2030] = "‰" +let s:html[0x2032] = "′" +let s:html[0x2033] = "″" +let s:html[0x2039] = "‹" +let s:html[0x203A] = "›" +let s:html[0x203E] = "‾" +let s:html[0x2044] = "⁄" +let s:html[0x20AC] = "€" +let s:html[0x2111] = "ℑ" +let s:html[0x2118] = "℘" +let s:html[0x211C] = "ℜ" +let s:html[0x2122] = "™" +let s:html[0x2135] = "ℵ" +let s:html[0x2190] = "←" +let s:html[0x2191] = "↑" +let s:html[0x2192] = "→" +let s:html[0x2193] = "↓" +let s:html[0x2194] = "↔" +let s:html[0x21B5] = "↵" +let s:html[0x21D0] = "⇐" +let s:html[0x21D1] = "⇑" +let s:html[0x21D2] = "⇒" +let s:html[0x21D3] = "⇓" +let s:html[0x21D4] = "⇔" +let s:html[0x2200] = "∀" +let s:html[0x2202] = "∂" +let s:html[0x2203] = "∃" +let s:html[0x2205] = "∅" +let s:html[0x2207] = "∇" +let s:html[0x2208] = "∈" +let s:html[0x2209] = "∉" +let s:html[0x220B] = "∋" +let s:html[0x220F] = "∏" +let s:html[0x2211] = "∑" +let s:html[0x2212] = "−" +let s:html[0x2217] = "∗" +let s:html[0x221A] = "√" +let s:html[0x221D] = "∝" +let s:html[0x221E] = "∞" +let s:html[0x2220] = "∠" +let s:html[0x2227] = "∧" +let s:html[0x2228] = "∨" +let s:html[0x2229] = "∩" +let s:html[0x222A] = "∪" +let s:html[0x222B] = "∫" +let s:html[0x2234] = "∴" +let s:html[0x223C] = "∼" +let s:html[0x2245] = "≅" +let s:html[0x2248] = "≈" +let s:html[0x2260] = "≠" +let s:html[0x2261] = "≡" +let s:html[0x2264] = "≤" +let s:html[0x2265] = "≥" +let s:html[0x2282] = "⊂" +let s:html[0x2283] = "⊃" +let s:html[0x2284] = "⊄" +let s:html[0x2286] = "⊆" +let s:html[0x2287] = "⊇" +let s:html[0x2295] = "⊕" +let s:html[0x2297] = "⊗" +let s:html[0x22A5] = "⊥" +let s:html[0x22C5] = "⋅" +let s:html[0x2308] = "⌈" +let s:html[0x2309] = "⌉" +let s:html[0x230A] = "⌊" +let s:html[0x230B] = "⌋" +let s:html[0x2329] = "⟨" +let s:html[0x232A] = "⟩" +let s:html[0x25CA] = "◊" +let s:html[0x2660] = "♠" +let s:html[0x2663] = "♣" +let s:html[0x2665] = "♥" +let s:html[0x2666] = "♦" + + +let s:file=matchstr(s:unicode_URL, '[^/]*$') + +let s:directory = expand(":p:h")."/unicode" +let s:UniFile = s:directory . '/UnicodeData.txt' + +fu! unicode#CompleteUnicode(findstart,base) "{{{1 + if !exists("s:numeric") + let s:numeric=0 + endif + if a:findstart + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\w\|+' + let start -= 1 + endwhile + if line[start] =~# 'U' && line[start+1] == '+' && col('.')-1 >=start+2 + let s:numeric=1 + else + let s:numeric=0 + endif + return start + else + if exists("g:showDigraphCode") + let s:showDigraphCode=g:showDigraphCode + else + let s:showDigraphCode = 0 + endif + if s:numeric + let complete_list = filter(copy(s:UniDict), + \ 'printf("%04X", v:val) =~? "^0*".a:base[2:]') + else + let complete_list = filter(copy(s:UniDict), 'v:key =~? a:base') + endif + for [key, value] in sort(items(complete_list), "CompareList") + "let key=matchstr(key, "^[^0-9 ]*") + let dg_char=GetDigraphChars(value) + if s:showDigraphCode + if !empty(dg_char) + let fstring = printf("U+%04X %s (%s):'%s'", value, key, dg_char, + \ nr2char(value)) + else + let fstring=printf("U+%04X %s:%s", value, key, nr2char(value)) + endif + else + let fstring=printf("U+%04X %s:'%s'", value, key, nr2char(value)) + endif + let istring = printf("U+%04X %s%s:'%s'", value, key, + \ empty(dg_char) ? '' : '('.dg_char.')', nr2char(value)) + + if s:unicode_complete_name + let dict = {'word':key, 'abbr':fstring} + if g:UnicodeShowPreviewWindow + call extend(dict, {'info': istring}) + endif + call complete_add(dict) + else + let dict = {'word':nr2char(value), 'abbr':fstring} + if g:UnicodeShowPreviewWindow + call extend(dict, {'info': istring}) + endif + call complete_add(dict) + endif + if complete_check() + break + endif + endfor + + return {} + endif +endfu + +fu! unicode#CompleteDigraph() "{{{1 + let prevchar=getline('.')[col('.')-2] + let prevchar1=getline('.')[col('.')-3] + let dlist=GetDigraph() + if prevchar !~ '\s' && !empty(prevchar) + let filter1 = '( v:val[0] == prevchar1 && v:val[1] == prevchar)' + let filter2 = 'v:val[0] == prevchar || v:val[1] == prevchar' + + let dlist1 = filter(copy(dlist), filter1) + if empty(dlist1) + let dlist = filter(dlist, filter2) + let col=col('.')-1 + else + let dlist = dlist1 + let col=col('.')-2 + endif + unlet dlist1 + else + let col=col('.') + endif + let tlist=[] + for args in dlist + let t=matchlist(args, '^\(..\)\s<\?\(..\?\)>\?\s\+\(\d\+\)$') + if !empty(t) + let format=printf("'%s' %s U+%04X",t[1], t[2], t[3]) + call add(tlist, {'word':nr2char(t[3]), 'abbr':format, + \ 'info': printf("Abbrev\tGlyph\tCodepoint\n%s\t%s\tU+%04X", + \ t[1],t[2],t[3])}) + endif + endfor + call complete(col, tlist) + return '' +endfu + +fu! unicode#SwapCompletion() "{{{1 + if !exists('s:unicode_complete_name') + let s:unicode_complete_name = 1 + endif + if exists('g:unicode_complete_name') + let s:unicode_complete_name = g:unicode_complete_name + else + let s:unicode_complete_name = !s:unicode_complete_name + endif + echo "Unicode Completion Names " . + \ (s:unicode_complete_name ? 'ON':'OFF') +endfu + +fu! unicode#Init(enable) "{{{1 + if !exists("s:unicode_complete_name") + let s:unicode_complete_name = 0 + endif + if a:enable + let b:oldfunc=&l:cfu + if (CheckDir()) + let s:UniDict = UnicodeDict() + setl completefunc=unicode#CompleteUnicode + set completeopt+=menuone + inoremap =unicode#CompleteDigraph() + nnoremap un :call unicode#SwapCompletion() + endif + else + if exists("b:oldfunc") && !empty(b:oldfunc) + let &l:cfu=b:oldfunc + else + setl completefunc= + endif + unlet! s:UniDict + if maparg("un", 'n') + nunmap un + endif + if maparg("") + iunmap + endif + endif + echo "Unicode Completion " . (a:enable? 'ON' : 'OFF') +endfu + +fu! unicode#GetUniChar(...) "{{{1 + try + if (CheckDir()) + if !exists("s:UniDict") + let s:UniDict=UnicodeDict() + endif + let msg = [] + + " Get glyph at Cursor + " need to use redir, cause we also want to capture combining chars + redir => a | exe "silent norm! ga" | redir end + let a = substitute(a, '\n', '', 'g') + " Special case: no character under cursor + if a == 'NUL' + call add(msg, "'NUL' U+0000 NULL") + "call add(msg, "No character under cursor!") + return + endif + let dlist = GetDigraph() + " Split string, in case cursor was on a combining char + for item in split(a, 'Octal \d\+\zs \?') + + let glyph = substitute(item, '^<\(<\?[^>]*>\?\)>.*', '\1', '') + let dec = substitute(item, '.*>\?> \+\(\d\+\),.*', '\1', '') + " Check for control char (has no name) + if dec <= 0x1F || ( dec >= 0x7F && dec <= 0x9F) + if dec == 0 + let dec = 10 + endif + let dig = filter(copy(dlist), 'v:val =~ ''\D''.dec.''$''') + call add(msg, printf("'%s' U+%04X %s", glyph, dec, + \ empty(dig) ? '' : '('.dig[0][0:1].')')) + " CJK Unigraphs start at U+4E00 and go until U+9FFF + elseif dec >= 0x4E00 && dec <= 0x9FFF + call add(msg, printf("'%s' U+%04X CJK Ideograph", glyph, dec)) + elseif dec >= 0xF0000 && dec <= 0xFFFFD + call add(msg, printf("'%s' U+%04X character from Plane 15 for private use", + \ glyph, dec)) + elseif dec >= 0x100000 && dec <= 0x10FFFD + call add(msg, printf("'%s' U+%04X character from Plane 16 for private use", + \ glyph, dec)) + else + let dict = filter(copy(s:UniDict), 'v:val == dec') + if empty(dict) + " not found + call add(msg, printf("Character '%s' U+%04X not found", glyph, dec)) + return + endif + let dig = filter(copy(dlist), 'v:val =~ ''\D''.dec.''$''') + if !empty(dig) + let dchar = printf("(%s)", dig[0][0:1]) + else + let dchar = '' + endif + let html = GetHtmlEntity(dec) + call add(msg, printf("'%s' U+%04X %s %s %s", glyph, values(dict)[0], + \ keys(dict)[0], dchar, html)) + endif + endfor + if exists("a:1") && !empty(a:1) + exe "let @".a:1. "=join(msg)" + endif + + "call OutputMessage(msg) + else + call add(msg, printf("Can't determine char under cursor, %s not found", s:UniFile)) + endif + finally + call OutputMessage(msg) + endtry +endfun + +fu! unicode#OutputDigraphs(match, bang) "{{{1 + let screenwidth = 0 + let digit = a:match + 0 + for dig in sort(GetDigraph(), 'CompareDigraphs') + " display digraphs that match value + if dig !~# a:match && digit == 0 + continue + endif + let item = matchlist(dig, '\(..\)\s\(\%(\s\s\)\|.\{,4\}\)\s\+\(\d\+\)$') + + " if digit matches, we only want to display digraphs matching the + " decimal values + if digit > 0 && digit !~ item[3] + continue + endif + + let screenwidth += strdisplaywidth(dig) + 2 + + " if the output is too wide, echo an output + if screenwidth > &columns || !empty(a:bang) + let screenwidth = 0 + echon "\n" + endif + + echohl Title + echon item[2] + echohl Normal + echon item[1]. " ". item[3] . " " + endfor +endfu + +fu! GetDigraphChars(code) "{{{1 + let dlist = GetDigraph() + let ddict = {} + for digraph in dlist + let key=matchstr(digraph, '\d\+$')+0 + let val=split(digraph) + let ddict[key] = val[0] + endfor + return get(ddict, a:code, '') +endfu + +fu! UnicodeDict() "{{{1 + let dict={} + let list=readfile(s:UniFile) + for glyph in list + let val = split(glyph, ";") + let Name = val[1] + let dict[Name] = str2nr(val[0],16) + endfor + return dict +endfu + +fu! CheckUniFile(force) "{{{1 + if (!filereadable(s:UniFile) || (getfsize(s:UniFile) == 0)) || a:force + call s:WarningMsg("File " . s:UniFile . " does not exist or is zero.") + call s:WarningMsg("Let's see, if we can download it.") + call s:WarningMsg("If this doesn't work, you should download ") + call s:WarningMsg(s:unicode_URL . " and save it as " . s:UniFile) + sleep 10 + if exists(":Nread") + sp +enew + " Use the default download method. You can specify a different one, + " using :let g:netrw_http_cmd="wget" + exe ":lcd " . s:directory + exe "0Nread " . s:unicode_URL + $d _ + exe ":w!" . s:UniFile + if getfsize(s:UniFile)==0 + call s:WarningMsg("Error fetching Unicode File from " . s:unicode_URL) + return 0 + endif + bw + else + call s:WarningMsg("Please download " . s:unicode_URL) + call s:WarningMsg("and save it as " . s:UniFile) + call s:WarningMsg("Quitting") + return 0 + endif + endif + return 1 +endfu + +fu! CheckDir() "{{{1 + try + if (!isdirectory(s:directory)) + call mkdir(s:directory) + endif + catch + call s:WarningMsg("Error creating Directory: " . s:directory) + return 0 + endtry + return CheckUniFile(0) +endfu + +fu! GetDigraph() "{{{1 + if exists("s:dlist") && !empty(s:dlist) + return s:dlist + else + redir => digraphs + silent digraphs + redir END + let s:dlist=[] + let s:dlist=map(split(substitute(digraphs, "\n", ' ', 'g'), + \ '..\s<\?.\{1,2\}>\?\s\+\d\{1,5\}\zs'), + \ 'substitute(v:val, "^\\s\\+", "", "")') + " special case: digraph 57344: starts with 2 spaces + "return filter(dlist, 'v:val =~ "57344$"') + let idx=match(s:dlist, '57344$') + let s:dlist[idx]=' '.s:dlist[idx] + + return s:dlist + endif +endfu + +fu! CompareList(l1, l2) "{{{1 + return a:l1[1] == a:l2[1] ? 0 : a:l1[1] > a:l2[1] ? 1 : -1 +endfu + +fu! CompareDigraphs(d1, d2) "{{{1 + let d1=matchstr(a:d1, '\d\+$')+0 + let d2=matchstr(a:d2, '\d\+$')+0 + if d1 == d2 + return 0 + elseif d1 > d2 + return 1 + else + return -1 + endif +endfu + +fu! OutputMessage(msg) " {{{1 + redraw + echohl Title + if type(a:msg) == type([]) + " List + for item in a:msg + echom item + endfor + elseif type(a:msg) == type("") + " string + echom a:msg + endif + echohl Normal +endfu + +fu! WarningMsg(msg) "{{{1 + echohl WarningMsg + let msg = "UnicodePlugin: " . a:msg + if exists(":unsilent") == 2 + unsilent echomsg msg + else + echomsg msg + endif + echohl Normal +endfun + +fu! GetHtmlEntity(hex) "{{{1 + return get(s:html, a:hex, '') +endfu +" Modeline "{{{1 +" vim: ts=4 sts=4 fdm=marker com+=l\:\" fdl=0 diff --git a/.vim/doc/unicode.txt b/.vim/doc/unicode.txt new file mode 100644 index 0000000..2a23ddb --- /dev/null +++ b/.vim/doc/unicode.txt @@ -0,0 +1,250 @@ +*unicode.txt* A completion plugin for Unicode glyphs + +Author: Christian Brabandt +Version: 0.17 Thu, 15 Aug 2013 08:53:06 +0200 + *unicode-copyright* +Copyright: (c) 2009 - 2013 by Christian Brabandt + The VIM LICENSE applies to unicode.vim and unicode.txt + (see |copyright|) except use unicode instead of "Vim". + NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK. + +============================================================================== + *unicode-plugin* +1. Functionality + +This plugin was written to enable an easier use of any Unicode glyph +available. The unicode.vim Plugin uses the data available from the Unicode +Consortium's website (http://www.unicode.org) to let you enter Unicode +characters using a completion function. + +By default, the plugin creates a directory unicode below the path autoload +where this plugin is located. Within this directory it will store the file +UnicodeData.txt from http://www.unicode.org/Public/UNIDATA/UnicodeData.txt +which it will try to download using |netrw| . If this is unsuccessfull, or +you do not have |netrw| enabled, dowload the file manually and save it in the +unicode directory below the autoload directory in which unicode.vim is +located. + + + *:EnableUnicodeCompletion* +By default the plugin is not enabled. To enable it enter: > + + :EnableUnicodeCompletion + +When you run this command, unicode.vim checks for the availability of +UnicodeData.txt from the Unicode Consortium, and if it is not available, +it will try to download it. + +This will also set up the completion function |completefunc| to use for your +buffer. You can use |i_CTRL-X_CTRL-U| then to start the completion. + + *:DisableUnicodeCompletion* +If you want to disable the plugin, enter > + + :DisableUnicodeCompletion +< + *:UnicodeName* +Suppose, you want to know, what the Unicode Name for the Character under the +cursor is. You simply enter the ex command: > + + :UnicodeName [reg] + +The plugin will then output the character, the character's hexadecimal value +and the official Unicode name. + +Additionally, if there exists a digraph for that character, it will also be +shown in paranthesis. + +If you specify a register name, the message will also be saved into that +register. + + *:Digraphs* +> + :Digraphs + +Outputs the digraph list in an easier way to read with coloring of the digraphs. + +If you want to display a list with a line break after each digraph, use the +bang attribute > + + :Digraphs! + +And if you want to display all digraphs matching a certain value, you can add +an argument to the command: > + + :Digraphs! A + +displays all digraphs, that match 'A' (e.g. all that can be created with the +letter A or whose digraph matches the letter 'A'. + +============================================================================== + *unicode-plugin-usage* +2. Completing Unicode chars + +If you have enabled the plugin using |:EnableUnicodeCompletion| then there are +2 possibilities to use the plugin. You can either enter the Unicode Character +name, or enter the Unicode-Codeposition. + +For example, you would like to enter Æ, so you enter AE and press || +while in insert mode. Alternatively you can enter the Unicode-Codepoint: U+C6 +and press || and the popup menu will show you all characters, that +have a codepoint like C6 with leading zeros, eg. U+00C6 and U+0C66 + +A popup menu will appear, showing you the Unicode-Codeposition value, the +Unicode Character Name and the Unicode Character (and if you have enabled it, +it can also show you the digraph characters needed to create this character in +paranthesis, see |unicode-plugin-config| ). You can scroll down in the menu by +pressing and up by pressing . + +A |preview-window| can be opened, if your Vim was compiled with the +quickfix-feature that displays the hexadecimal Unicode Codepoint, the name, +the digraph characters in parenthesis (if they exist) followed by the glyph +itself by setting the variable g:UnicodeShowPreviewWindow (see below). By +default, this feature is off. + + *unicode-plugin-config* +The plugin can be customized to include the 2 digraph characters you have to +type, to get that character. This works only, if there is a digraph defined +for that Unicode char. If you would like this you need to set +g:showDigraphCode, e.g. > + + :let g:showDigraphCode=1 + +This functionality is by default disabled, cause it seems to cause some delay +and screen-rendering errors in the menu. However, the preview window will +always show the digraph character in parenthesis. +Enter > + + :let g:showDigraphCode=0 + +to disable the Digraph feature afterwards. + +If you would like to specify a different URL from which to download +UnicodeData.txt, enter the URL as: > + + :let g:unicode_URL='http:....' + +To force downloading the file from that new url, enter > + + :call unicode#CheckUniFile(1) + +If you'd like Unicode completion to be always enabled, you can set the +variable g:enableUnicodeCompletion to 1 in your |.vimrc| like this: > + + let g:enableUnicodeCompletion = 1 +< +Thus, you won't need to use EnableUnicodeCompletion, it will be already +available. + +If you only want to complete the Unicode Names instead of the glyphs, +you can either set the global variable > + + let g:unicode_complete_name = 1 +< +or you can use the mapping un which swaps the completion function +between completing the unicode name and completing the unicode glyph. + +If you want the completion of the unicode chars to be opened in the preview +window, set the variable > + + let g:UnicodeShowPreviewWindow = 1 +< +in your |.vimrc|. + + *unicode-plugin-error* +If the plugin gives an error or does not complete anything, first check, that +UnicodeData.txt from the Unicode Consortium has been successfully downloaded. +It should be located below the autoload/unicode.vim script in a directory +called unicode. So if you have installed unicode.vim into +/home/user/.vim, UnicodeData.txt should be located at: +/home/user/.vim/autoload/unicode/UnicodeData.txt and should look like this: + +0020;SPACE;Zs;0;WS;;;;;N;;;;; +0021;EXCLAMATION MARK;Po;0;ON;;;;;N;;;;; +0022;QUOTATION MARK;Po;0;ON;;;;;N;;;;; +0023;NUMBER SIGN;Po;0;ET;;;;;N;;;;; +0024;DOLLAR SIGN;Sc;0;ET;;;;;N;;;;; +0025;PERCENT SIGN;Po;0;ET;;;;;N;;;;; +0026;AMPERSAND;Po;0;ON;;;;;N;;;;; +0027;APOSTROPHE;Po;0;ON;;;;;N;APOSTROPHE-QUOTE;;;; +0028;LEFT PARENTHESIS;Ps;0;ON;;;;;Y;OPENING PARENTHESIS;;;; +0029;RIGHT PARENTHESIS;Pe;0;ON;;;;;Y;CLOSING PARENTHESIS;;;; +[...] +(several thounsand lines following) + +If the file looks correct, and the plugin is still not working correctly +contact the maintainer. You'll find his email-adress in the first line of this +document. Please be patient, it might take a while, until I can take care of +your report. + +============================================================================== + *i_CTRL-X_CTRL-G* *digraph-completion* +3. Completing digraphs + +CTRL-X CTRL-G Search for the character in front of the cursor and + try to complete this letter using a digraph. If there + is no letter in front of the cursor, a list with all + available digraphs is shown in a popup menu. + If both letters in front of the cursor form a digraph, + that digraph will be completed. + (Think of Glyph) + CTRL-N Use next match. This match replaces the previous + match. + CTRL-P Use previous match. This match replaces the previous + one. + + +============================================================================== +4. unicode History *unicode-plugin-history* + 0.17: Aug 15, 2013 - disable preview window (for completing unicode chars) + by default, can be enabled by setting the variable + g:UnicodeShowPreviewWindow (patch by Marcin + Szamotulski, thanks!) + 0.16: Feb 16, 2013 - |:UnicodeName| returns html entity, if possible + 0.15: Feb 05, 2013 - make sure, the returned digraphs list is not empty. + 0.14: Dec 01, 2012 - |:Digraphs| for better display of digraphs + 0.13: Sep 08, 2012 - better output for |UnicodeName| (did previously hide + messages) + 0.12: Apr 12, 2012 - |UnicodeName| shows digraph, if it exists + - better completion of digraphs + 0.11: Apr 11, 2012 - prevent loading of autoload file too early + - Make matching digraph more error-prone + - show all matching digraphs for a char + 0.10: Dec 15, 2011 - enable completing of only the names + - Really disable the 'completefunc' when disabling + the function + 0.9: Jul 20, 2011: - |:UnicodeName| checks for existence of + UnicodeData.txt + - |:UnicodeName| now also detects combined chars + - |:UnicodeName| now also outputs control chars + 0.8: Sep 30, 2010: - Fix an issue with configuring the plugin (Thanks jgm) + - Code cleanup + - Make use of the preview window, when completing + Digraph or Unicode Glyphs + - By default, the Digraph Glyphs will now be enabled + using |i_Ctrl-X_CTRL-G| instead of using + Ctrl-X_Ctrl-C which wouldn't work in a terminal + - |:UnicodeName| now displays the hexadecimal Unicode + Codepoint instead of the decimal one (as this seems + to be the official way to display unicode + codepoints). + 0.7: Sep 23, 2010: - |:UnicodeName| + - specify g:enableUnicodeCompletion to have unicode + completion always enabled. + 0.6: Aug 26, 2010: - many small bugfixes with regard to error-handling + and error displaying + - use default netrw_http_cmd (instead of hardwiring + wget) + - small documentation update (Inlude a snippet of + UnicodeData.txt and get rid of Index.txt data) + 0.5: Apr 19, 2010: Created a public repository for this plugin at + http://github.com/chrisbra/unicode.vim + 0.4: Feb 01, 2010: Use UnicodeData.txt to generate Data + (Index.txt does not contain all glyphs). + Check for empty file UnicodeData.txt + 0.3: Oct 27, 2009: Digraph Completion + 0.2: Oct 22, 2009: Enabled GetLatestScripts (|GLVS|) + 0.1: Oct 22, 2009: First working version + +============================================================================== +vim:tw=78:ts=8:ft=help diff --git a/.vim/plugin/unicode.vim b/.vim/plugin/unicode.vim new file mode 100644 index 0000000..99d4a40 --- /dev/null +++ b/.vim/plugin/unicode.vim @@ -0,0 +1,43 @@ +" unicodePlugin : A completion plugin for Unicode glyphs +" Author: C.Brabandt +" Version: 0.17 +" Copyright: (c) 2009 by Christian Brabandt +" The VIM LICENSE applies to unicode.vim, and unicode.txt +" (see |copyright|) except use "unicode" instead of "Vim". +" No warranty, express or implied. +" *** *** Use At-Your-Own-Risk! *** *** +" +" TODO: enable GLVS: +" GetLatestVimScripts: 2822 17 :AutoInstall: unicode.vim + +" --------------------------------------------------------------------- +if version < 703 + finish +endif +" --------------------------------------------------------------------- +" Load Once: {{{1 +if &cp || exists("g:loaded_unicodePlugin") + finish +endif +let g:loaded_unicodePlugin = 1 +let s:keepcpo = &cpo +set cpo&vim + +let s:enableUnicodeCompletion = (exists("g:enableUnicodeCompletion") ? g:enableUnicodeCompletion : 0) +" ------------------------------------------------------------------------------ +" Public Interface: {{{1 +com! EnableUnicodeCompletion call unicode#Init(1) +com! DisableUnicodeCompletion call unicode#Init(0) +com! -nargs=? UnicodeName call unicode#GetUniChar() +com! -nargs=? -bang Digraphs call unicode#OutputDigraphs(, ) + +if s:enableUnicodeCompletion + exe "call unicode#Init(s:enableUnicodeCompletion)" + "let s:enableUnicodeCompletion = !s:enableUnicodeCompletion +endif + +" ===================================================================== +" Restoration And Modelines: {{{1 +" vim: fdm=marker +let &cpo= s:keepcpo +unlet s:keepcpo -- 2.7.4