Skip to content

Commit 02b0bfa

Browse files
committed
consider npm package at getting version (fix #39)
1 parent ecc83ff commit 02b0bfa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

autoload/clang_format.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function! clang_format#get_version()
9292
set shell=/bin/bash
9393
endif
9494
try
95-
return matchlist(s:system(g:clang_format#command.' --version 2>&1'), '\(\d\+\)\.\(\d\+\)')[1:2]
95+
let version_output = s:system(g:clang_format#command.' --version 2>&1')
96+
if stridx(version_output, 'NPM') != -1
97+
" Note:
98+
" When clang-format is installed with npm, version string is changed (#39).
99+
return matchlist(version_output, 'NPM version \d\+\.\d\+\.\(\d\)\(\d\+\)')[1:2]
100+
else
101+
return matchlist(version_output, '\(\d\+\)\.\(\d\+\)')[1:2]
102+
endif
96103
finally
97104
if exists('l:shell_save')
98105
let &shell = shell_save

0 commit comments

Comments
 (0)