Skip to content

Commit aae2df9

Browse files
committed
Make Exuberant Ctags discovery (version checking) verbose (easier to debug)
See also issue #58 on GitHub: #58
1 parent 8c59ddd commit aae2df9

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

addon-info.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"vim_script_nr": 3114, "dependencies": {"vim-misc": {}}, "homepage": "http://peterodding.com/code/vim/easytags", "name": "vim-easytags"}

autoload/xolox/easytags.vim

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: June 22, 2013
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '3.3.11'
6+
let g:xolox#easytags#version = '3.3.12'
77

88
" Plug-in initialization. {{{1
99

@@ -54,25 +54,36 @@ function! xolox#easytags#check_ctags_compatible(name, min_version) " {{{2
5454
" This function makes sure it is because the easytags plug-in requires the
5555
" --list-languages option (and more).
5656
call xolox#misc#msg#debug("easytags.vim %s: Checking if Exuberant Ctags is installed as '%s'.", g:xolox#easytags#version, a:name)
57-
if executable(a:name)
58-
let command = a:name . ' --version'
59-
let result = xolox#misc#os#exec({'command': command, 'check': 0})
60-
if result['exit_code'] == 0
61-
let pattern = 'Exuberant Ctags \zs\(\d\+\(\.\d\+\)*\|Development\)'
62-
let g:easytags_ctags_version = matchstr(get(result['stdout'], 0, ''), pattern)
63-
call xolox#misc#msg#debug("easytags.vim %s: Executable '%s' reported version '%s'.", g:xolox#easytags#version, a:name, g:easytags_ctags_version)
64-
if g:easytags_ctags_version == 'Development'
65-
call xolox#misc#msg#debug("easytags.vim %s: Assuming development build is compatible ..", g:xolox#easytags#version, a:name)
66-
return 1
67-
elseif xolox#misc#version#at_least(a:min_version, g:easytags_ctags_version)
68-
call xolox#misc#msg#debug("easytags.vim %s: Version is compatible! :-)", g:xolox#easytags#version)
69-
return 1
70-
else
71-
call xolox#misc#msg#debug("easytags.vim %s: Version is not compatible! :-(", g:xolox#easytags#version)
72-
return 0
73-
endif
57+
" Make sure the given program is executable.
58+
if !executable(a:name)
59+
call xolox#misc#msg#debug("easytags.vim %s: Program '%s' is not executable!", g:xolox#easytags#version, a:name)
60+
return 0
61+
endif
62+
" Make sure the command exits without reporting an error.
63+
let command = a:name . ' --version'
64+
let result = xolox#misc#os#exec({'command': command, 'check': 0})
65+
if result['exit_code'] != 0
66+
call xolox#misc#msg#debug("easytags.vim %s: Command '%s' returned nonzero exit code %i!", g:xolox#easytags#version, a:name, result['exit_code'])
67+
else
68+
" Extract the version number from the output.
69+
let pattern = 'Exuberant Ctags \zs\(\d\+\(\.\d\+\)*\|Development\)'
70+
let g:easytags_ctags_version = matchstr(get(result['stdout'], 0, ''), pattern)
71+
" Deal with development builds.
72+
if g:easytags_ctags_version == 'Development'
73+
call xolox#misc#msg#debug("easytags.vim %s: Assuming development build is compatible ..", g:xolox#easytags#version, a:name)
74+
return 1
75+
endif
76+
" Make sure the version is compatible.
77+
if xolox#misc#version#at_least(a:min_version, g:easytags_ctags_version)
78+
call xolox#misc#msg#debug("easytags.vim %s: Version is compatible! :-)", g:xolox#easytags#version)
79+
return 1
80+
else
81+
call xolox#misc#msg#debug("easytags.vim %s: Version is not compatible! :-(", g:xolox#easytags#version)
7482
endif
7583
endif
84+
call xolox#misc#msg#debug("easytags.vim %s: Standard output of command: %s", g:xolox#easytags#version, string(result['stdout']))
85+
call xolox#misc#msg#debug("easytags.vim %s: Standard error of command: %s", g:xolox#easytags#version, string(result['stderr']))
86+
return 0
7687
endfunction
7788

7889
function! xolox#easytags#register(global) " {{{2

0 commit comments

Comments
 (0)