From 77f21e936579d9f7eb938fe80bb66f188d8ee666 Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Sun, 25 Aug 2013 03:51:54 -0600 Subject: [PATCH 1/3] Added ability to specify paths for options files For both compile_commands.json and .clang_complete, there were added some global variables to allow the user to customize where to find these files. --- doc/clang_complete.txt | 24 ++++++++++++++++++++++++ plugin/clang_complete.vim | 28 ++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/doc/clang_complete.txt b/doc/clang_complete.txt index d6a6e765..e7e98272 100644 --- a/doc/clang_complete.txt +++ b/doc/clang_complete.txt @@ -194,6 +194,30 @@ time before doing completion. Default: "path, .clang_complete" + *clang_complete-compilation_database_search_path* + *g:clang_compilation_database_search_path* +By default, when the compile_commands.json option is specified for +|g:clang_user_options| the upwards search is for that filename. To change the +name of this file or to search different subdirectories, you may set +|g:clang_compilation_database_search_path|. + +For example, specifing build/compile_commands.json will allow out of source +builds with cmake. + +Default: "compile_commands.json" + + *clang_complete-clang_complete_search_path* + *g:clang_complete_search_path* +By default, when the .clang_complete option is specified for +|g:clang_user_options| the upwards search is for that filename. To change the +name of this file or to search different subdirectories, you may set +|g:clang_complete_search_path|. + +For example, specifing build/.clang_complete will allow out of source +builds with cmake. + +Default: ".clang_complete" + *clang_complete-compilation_database* *g:clang_compilation_database* By default, clang_complete will search upwards from where it was started to diff --git a/plugin/clang_complete.vim b/plugin/clang_complete.vim index a1ce0e79..2b2deadf 100644 --- a/plugin/clang_complete.vim +++ b/plugin/clang_complete.vim @@ -17,6 +17,10 @@ let b:my_changedtick = 0 " not during a function call. let s:plugin_path = escape(expand(':p:h'), '\') +" Default filenames +let s:default_compilation_database_filename = 'compile_commands.json' +let s:default_clang_complete_filename = '.clang_complete' + function! s:ClangCompleteInit() let l:bufname = bufname("%") if l:bufname == '' @@ -58,7 +62,7 @@ function! s:ClangCompleteInit() endif if !exists('g:clang_snippets_engine') - let g:clang_snippets_engine = 'clang_complete' + let g:clang_snippets_engine = s:default_clang_complete_filename endif if !exists('g:clang_user_options') @@ -75,6 +79,14 @@ function! s:ClangCompleteInit() let g:clang_trailing_placeholder = 0 endif + if !exists("g:clang_compilation_database_search_path") + let g:clang_compilation_database_search_path = s:default_compilation_database_filename + endif + + if !exists('g:clang_complete_search_path') + let g:clang_complete_search_path = s:default_clang_complete_filename + endif + if !exists('g:clang_compilation_database') let g:clang_compilation_database = '' endif @@ -100,7 +112,7 @@ function! s:ClangCompleteInit() endif if !exists('g:clang_auto_user_options') - let g:clang_auto_user_options = 'path, .clang_complete' + let g:clang_auto_user_options = 'path, ' . s:default_clang_complete_filename endif if !exists('g:clang_jumpto_declaration_key') @@ -187,10 +199,10 @@ function! LoadUserOptions() endif if l:source == 'path' call s:parsePathOption() - elseif l:source == 'compile_commands.json' - call s:findCompilationDatase(l:source) - elseif l:source == '.clang_complete' - call s:parseConfig() + elseif l:source == s:default_compilation_database_filename + call s:findCompilationDatase(g:clang_compilation_database_search_path) + elseif l:source == s:default_clang_complete_filename + call s:parseConfig(g:clang_complete_search_path) else let l:getopts = 'getopts#' . l:source . '#getopts' silent call eval(l:getopts . '()') @@ -198,8 +210,8 @@ function! LoadUserOptions() endfor endfunction -function! s:parseConfig() - let l:local_conf = findfile('.clang_complete', getcwd() . ',.;') +function! s:parseConfig(ccpath) + let l:local_conf = findfile(a:ccpath, getcwd() . ',.;') if l:local_conf == '' || !filereadable(l:local_conf) return endif From 85fea6fc98b8c22ec6786ceb8ad9b0e8611b1c73 Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Mon, 26 Aug 2013 08:28:16 -0600 Subject: [PATCH 2/3] Typos fixed --- doc/clang_complete.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/clang_complete.txt b/doc/clang_complete.txt index e7e98272..83e576d8 100644 --- a/doc/clang_complete.txt +++ b/doc/clang_complete.txt @@ -201,7 +201,7 @@ By default, when the compile_commands.json option is specified for name of this file or to search different subdirectories, you may set |g:clang_compilation_database_search_path|. -For example, specifing build/compile_commands.json will allow out of source +For example, specifying build/compile_commands.json will allow out of source builds with cmake. Default: "compile_commands.json" @@ -213,7 +213,7 @@ By default, when the .clang_complete option is specified for name of this file or to search different subdirectories, you may set |g:clang_complete_search_path|. -For example, specifing build/.clang_complete will allow out of source +For example, specifying build/.clang_complete will allow out of source builds with cmake. Default: ".clang_complete" From b76d0ab2db33f44451e68db0af26e32927d5c9fd Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Mon, 26 Aug 2013 08:31:03 -0600 Subject: [PATCH 3/3] Removed tab spacing to be more consistent --- doc/clang_complete.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/clang_complete.txt b/doc/clang_complete.txt index 83e576d8..b1f435de 100644 --- a/doc/clang_complete.txt +++ b/doc/clang_complete.txt @@ -195,7 +195,7 @@ time before doing completion. Default: "path, .clang_complete" *clang_complete-compilation_database_search_path* - *g:clang_compilation_database_search_path* + *g:clang_compilation_database_search_path* By default, when the compile_commands.json option is specified for |g:clang_user_options| the upwards search is for that filename. To change the name of this file or to search different subdirectories, you may set @@ -207,7 +207,7 @@ builds with cmake. Default: "compile_commands.json" *clang_complete-clang_complete_search_path* - *g:clang_complete_search_path* + *g:clang_complete_search_path* By default, when the .clang_complete option is specified for |g:clang_user_options| the upwards search is for that filename. To change the name of this file or to search different subdirectories, you may set