|
1 | 1 | " Vim plug-in
|
2 | 2 | " Author: Peter Odding <peter@peterodding.com>
|
3 |
| -" Last Change: June 20, 2013 |
| 3 | +" Last Change: June 22, 2013 |
4 | 4 | " URL: http://peterodding.com/code/vim/easytags/
|
5 | 5 | " Requires: Exuberant Ctags (http://ctags.sf.net)
|
6 | 6 |
|
@@ -48,96 +48,31 @@ if !exists('g:easytags_python_script')
|
48 | 48 | let g:easytags_python_script = expand('<sfile>:p:h') . '/../misc/easytags/highlight.py'
|
49 | 49 | endif
|
50 | 50 |
|
51 |
| -function! s:InitEasyTags(version) |
52 |
| - " Check that the location of Exuberant Ctags has been configured or that the |
53 |
| - " correct version of the program exists in one of its default locations. |
54 |
| - if exists('g:easytags_cmd') && s:CheckCtags(g:easytags_cmd, a:version) |
55 |
| - return 1 |
56 |
| - endif |
57 |
| - if xolox#misc#os#is_win() |
58 |
| - " FIXME The code below that searches the $PATH is not used on Windows at |
59 |
| - " the moment because xolox#misc#path#which() generally produces absolute |
60 |
| - " paths and on Windows these absolute paths tend to contain spaces which |
61 |
| - " makes xolox#shell#execute_with_dll() fail. I've tried quoting the |
62 |
| - " program name with double quotes but it fails just the same (it works |
63 |
| - " with system() though). Anyway the problem of having multiple conflicting |
64 |
| - " versions of Exuberant Ctags installed is not that relevant to Windows |
65 |
| - " since it doesn't have a package management system. I still want to fix |
66 |
| - " xolox#shell#execute_with_dll() though. |
67 |
| - if s:CheckCtags('ctags', a:version) |
68 |
| - let g:easytags_cmd = 'ctags' |
69 |
| - return 1 |
70 |
| - endif |
71 |
| - else |
72 |
| - " Exuberant Ctags can be installed under multiple names: |
73 |
| - " - On Ubuntu Linux, Exuberant Ctags is installed as `ctags-exuberant' |
74 |
| - " (and possibly `ctags' but that one can't be trusted :-) |
75 |
| - " - On Debian Linux, Exuberant Ctags is installed as `exuberant-ctags'. |
76 |
| - " - On Free-BSD, Exuberant Ctags is installed as `exctags'. |
77 |
| - " IIUC on Mac OS X the program /usr/bin/ctags is installed by default but |
78 |
| - " unusable and when the user installs Exuberant Ctags in an alternative |
79 |
| - " location, it doesn't come before /usr/bin/ctags in the search path. To |
80 |
| - " solve this problem in a general way and to save every Mac user out there |
81 |
| - " some frustration the plug-in will search the path and consider every |
82 |
| - " possible location, meaning that as long as Exuberant Ctags is installed |
83 |
| - " in the $PATH the plug-in should find it automatically. |
84 |
| - for program in xolox#misc#path#which('exuberant-ctags', 'ctags-exuberant', 'ctags', 'exctags') |
85 |
| - if s:CheckCtags(program, a:version) |
86 |
| - let g:easytags_cmd = program |
87 |
| - return 1 |
88 |
| - endif |
89 |
| - endfor |
90 |
| - endif |
91 |
| -endfunction |
92 |
| - |
93 |
| -function! s:CheckCtags(name, version) |
94 |
| - " Not every executable out there named `ctags' is in fact Exuberant Ctags. |
95 |
| - " This function makes sure it is because the easytags plug-in requires the |
96 |
| - " --list-languages option (and more). |
97 |
| - if executable(a:name) |
98 |
| - let command = a:name . ' --version' |
99 |
| - let result = xolox#misc#os#exec({'command': command, 'check': 0}) |
100 |
| - if result['exit_code'] == 0 |
101 |
| - let pattern = 'Exuberant Ctags \zs\(\d\+\(\.\d\+\)*\|Development\)' |
102 |
| - let g:easytags_ctags_version = matchstr(result['stdout'][0], pattern) |
103 |
| - if g:easytags_ctags_version == 'Development' |
104 |
| - return 1 |
| 51 | +" Make sure Exuberant Ctags >= 5.5 is installed. |
| 52 | +if !xolox#easytags#initialize('5.5') |
| 53 | + " Did the user configure the plug-in to suppress the regular warning message? |
| 54 | + if !(exists('g:easytags_suppress_ctags_warning') && g:easytags_suppress_ctags_warning) |
| 55 | + " Explain to the user what went wrong: |
| 56 | + if !exists('g:easytags_ctags_version') || empty(g:easytags_ctags_version) |
| 57 | + " Exuberant Ctags is not installed / could not be found. |
| 58 | + let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags isn't installed!" |
| 59 | + if executable('apt-get') |
| 60 | + let s:msg .= " On Ubuntu & Debian you can install Exuberant Ctags by" |
| 61 | + let s:msg .= " installing the package named `exuberant-ctags':" |
| 62 | + let s:msg .= " sudo apt-get install exuberant-ctags" |
105 | 63 | else
|
106 |
| - return s:VersionToNumber(g:easytags_ctags_version) >= a:version |
| 64 | + let s:msg .= " Please download & install Exuberant Ctags from http://ctags.sf.net" |
107 | 65 | endif
|
108 |
| - endif |
109 |
| - endif |
110 |
| -endfunction |
111 |
| - |
112 |
| -function! s:VersionToNumber(s) |
113 |
| - let values = split(a:s, '\.') |
114 |
| - if len(values) == 1 |
115 |
| - return values[0] * 10 |
116 |
| - elseif len(values) >= 2 |
117 |
| - return values[0] * 10 + values[1][0] |
118 |
| - endif |
119 |
| -endfunction |
120 |
| - |
121 |
| -if !s:InitEasyTags(55) |
122 |
| - if exists('g:easytags_suppress_ctags_warning') && g:easytags_suppress_ctags_warning |
123 |
| - finish |
124 |
| - endif |
125 |
| - if !exists('g:easytags_ctags_version') || empty(g:easytags_ctags_version) |
126 |
| - let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags isn't installed!" |
127 |
| - if executable('apt-get') |
128 |
| - let s:msg .= " On Ubuntu & Debian you can install Exuberant Ctags by" |
129 |
| - let s:msg .= " installing the package named `exuberant-ctags':" |
130 |
| - let s:msg .= " sudo apt-get install exuberant-ctags" |
| 66 | + call xolox#misc#msg#warn(s:msg, g:xolox#easytags#version) |
131 | 67 | else
|
132 |
| - let s:msg .= " Please download & install Exuberant Ctags from http://ctags.sf.net" |
| 68 | + " The installed version is too old. |
| 69 | + let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags 5.5" |
| 70 | + let s:msg .= " or newer is required while you have version %s installed!" |
| 71 | + call xolox#misc#msg#warn(s:msg, g:xolox#easytags#version, g:easytags_ctags_version) |
133 | 72 | endif
|
134 |
| - echomsg printf(s:msg, g:xolox#easytags#version) |
135 |
| - else |
136 |
| - let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags 5.5" |
137 |
| - let s:msg .= " or newer is required while you have version %s installed!" |
138 |
| - echomsg printf(s:msg, g:xolox#easytags#version, g:easytags_ctags_version) |
| 73 | + unlet s:msg |
139 | 74 | endif
|
140 |
| - unlet s:msg |
| 75 | + " Stop loading the plug-in; don't define the (automatic) commands. |
141 | 76 | finish
|
142 | 77 | endif
|
143 | 78 |
|
|
0 commit comments