Révision | 191de01af32cf9110cc40b8655d76161ec537fb5 (tree) |
---|---|
l'heure | 2018-12-12 07:34:38 |
Auteur | Markus <Markus@dark...> |
Commiter | Markus |
put highlighting of tagged types and functions in a single function
@@ -2,10 +2,9 @@ | ||
2 | 2 | " Description: Some support functions and mappings for C code files. |
3 | 3 | " Maintainer: markus prepens (markus dot prepens at gmail dot com) |
4 | 4 | |
5 | -command! -buffer -nargs=0 ShowFunctions call c#HighlightTaggedFunctions() | |
6 | -command! -buffer -nargs=0 ShowTypes call c#HighlightTaggedTypes() | |
7 | -command! -buffer -nargs=0 ToggleSourceHeaderFile call c#ToggleSourceHeaderFile() | |
8 | -command! -buffer -nargs=0 PrettifyCode call c#CodeCleanup() | |
5 | +command! -buffer -nargs=0 ShowTags call c#HighlightTaggedFunctions() | |
6 | +command! -buffer -nargs=0 ToggleSourceHeaderFile call c#ToggleSourceHeaderFile() | |
7 | +command! -buffer -nargs=0 PrettifyCode call c#CodeCleanup() | |
9 | 8 | |
10 | 9 | nnoremap <buffer> <LocalLeader><TAB> :ToggleSourceHeaderFile<CR> |
11 | 10 |
@@ -56,28 +56,21 @@ function! c#ToggleSourceHeaderFile() | ||
56 | 56 | endfor |
57 | 57 | endfunction |
58 | 58 | |
59 | -" Description: scan trough current TAG file, find the function symbols and | |
60 | -" highlight them as keyword. | |
61 | -function! c#HighlightTaggedFunctions() | |
62 | - for l:tagsfile in tagfiles() | |
63 | - for l:line in readfile(l:tagsfile) | |
64 | - if match(l:line, '\<f\>') > 0 | |
65 | - let l:symbolStr = split(l:line, '\s\+')[0] | |
66 | - execute "syntax keyword Function " . l:symbolStr | |
67 | - endif | |
68 | - endfor | |
69 | - endfor | |
70 | -endfunction | |
71 | - | |
72 | -" Description: scan trough current TAG file, find the type symbols and | |
73 | -" highlight them as keyword. | |
74 | -function! c#HighlightTaggedTypes() | |
59 | +" Description: scan trough current TAG file, find the type and function symbols | |
60 | +" and highlight them as keyword. | |
61 | +function! c#HighlightTags() | |
62 | + let g:tagged_files = [] | |
75 | 63 | for l:tagsfile in tagfiles() |
76 | 64 | for l:line in readfile(l:tagsfile) |
65 | + let l:line_split = split(l:line, '\s\+'); | |
77 | 66 | if match(l:line, '\<t\>') > 0 |
78 | - let l:typeStr = split(l:line, '\s\+')[0] | |
79 | - execute "syntax keyword cType " . l:typeStr | |
67 | + execute "syntax keyword cType l:line_split[0]" | |
68 | + call insert(g:tagged_files, line_split[1]) | |
69 | + elseif match(l:line, '\<f\>') > 0 | |
70 | + execute "syntax keyword Function l:line_split[0]" | |
71 | + call insert(g:tagged_files, line_split[1]) | |
80 | 72 | endif |
81 | 73 | endfor |
74 | + call uniq(sort(g:tagged_files)) | |
82 | 75 | endfor |
83 | 76 | endfunction |