Skip to content

Commit

Permalink
Merge pull request #17 from jreybert/master
Browse files Browse the repository at this point in the history
add an option to load vim-clang only if .clang file is found
  • Loading branch information
justmao945 committed Oct 29, 2014
2 parents b2bb6ef + 1e7632f commit 095dfeb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
6 changes: 6 additions & 0 deletions doc/clang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ g:clang_dotfile_overwrite *g:clang_dotfile_overwrite*
Default: >
let g:clang_dotfile_overwrite = '.clang.ow'
<
g:clang_load_if_clang_dotfile g:clang_load_if_clang_dotfile
If equals to 1, this plugin will be loaded only if g:clang_dotfile or
g:clang_dotfile_overwrite file is found in the at his root.
Default: >
let g:clang_load_if_clang_dotfile = 0
g:clang_exec *g:clang_exec*
Name or path of executable clang. Use this if clang has a
non-standard name, or isn't in the path.
Expand Down
30 changes: 22 additions & 8 deletions plugin/clang.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ if exists('g:clang_loaded')
endif
let g:clang_loaded = 1

if !exists('g:clang_load_if_clang_dotfile')
let g:clang_load_if_clang_dotfile = 0
endif

if !exists('g:clang_dotfile')
let g:clang_dotfile = '.clang'
endif

if !exists('g:clang_dotfile_overwrite')
let g:clang_dotfile_overwrite = '.clang.ow'
endif

func! s:isClangFileExists()
let l:dotclang = findfile(g:clang_dotfile, '.;')
let l:dotclangow = findfile(g:clang_dotfile_overwrite, '.;')
return strlen(l:dotclang) + strlen(l:dotclangow)
endf

if ( s:isClangFileExists() == 0 && g:clang_load_if_clang_dotfile == 1 )
finish
endif

if !exists('g:clang_auto')
let g:clang_auto = 1
endif
Expand Down Expand Up @@ -63,14 +85,6 @@ if !exists('g:clang_diagsopt') || g:clang_diagsopt !~# '^[a-z]\+\(:[0-9]\)\?$'
let g:clang_diagsopt = 'rightbelow:6'
endif

if !exists('g:clang_dotfile')
let g:clang_dotfile = '.clang'
endif

if !exists('g:clang_dotfile_overwrite')
let g:clang_dotfile_overwrite = '.clang.ow'
endif

if !exists('g:clang_exec')
let g:clang_exec = 'clang'
endif
Expand Down

0 comments on commit 095dfeb

Please sign in to comment.