[ADD] conf for archlinux, <init>
[arrow.git] / archlinux_conf / home / .vim / autoload / tlib / syntax.vim
blob5f85b733fc0f106de68b5f08eefccc1775306023
1 " syntax.vim
2 " @Author:      Thomas Link (mailto:micathom AT gmail com?subject=[vim])
3 " @Website:     http://www.vim.org/account/profile.php?user_id=4037
4 " @License:     GPL (see http://www.gnu.org/licenses/gpl.txt)
5 " @Created:     2007-11-19.
6 " @Last Change: 2007-11-19.
7 " @Revision:    0.0.9
9 if &cp || exists("loaded_tlib_syntax_autoload")
10     finish
11 endif
12 let loaded_tlib_syntax_autoload = 1
13 let s:save_cpo = &cpo
14 set cpo&vim
17 function! tlib#syntax#Collect() "{{{3
18     let acc = {}
19     let syn = ''
20     for line in tlib#cmd#OutputAsList('syntax')
21         if line =~ '^---'
22             continue
23         elseif line =~ '^\w'
24             let ml = matchlist(line, '^\(\w\+\)\s\+\(xxx\s\+\(.*\)\|\(cluster.*\)\)$')
25             if empty(ml)
26                 echoerr 'Internal error: '. line
27             else
28                 let [m_0, syn, m_1, m_def1, m_def2; m_rest] = ml
29                 let acc[syn] = [empty(m_def1) ? m_def2 : m_def1]
30             endif
31         else
32             call add(acc[syn], matchstr(line, '^\s\+\zs.*$'))
33         endif
34     endfor
35     return acc
36 endf
39 " :def: function! tlib#syntax#Names(?rx='')
40 function! tlib#syntax#Names(...) "{{{3
41     TVarArg 'rx'
42     let names = keys(tlib#syntax#Collect())
43     if !empty(rx)
44         call filter(names, 'v:val =~ rx')
45     endif
46     return names
47 endf
50 let &cpo = s:save_cpo
51 unlet s:save_cpo