Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Shougo/clang_complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Aug 23, 2011
2 parents b43cfbe + 7468fd8 commit 143e64e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
51 changes: 27 additions & 24 deletions autoload/neocomplcache/sources/clang_complete.vim
Expand Up @@ -19,20 +19,23 @@
" "


" Variables initialize. " Variables initialize.
if !exists('g:neocomplcache_clang_complete_use_library') if !exists('g:neocomplcache_clang_use_library')
let g:neocomplcache_clang_complete_use_library = 0 let g:neocomplcache_clang_use_library = 0
endif endif
if !exists('g:neocomplcache_clang_complete_macros') if !exists('g:neocomplcache_clang_macros')
let g:neocomplcache_clang_complete_macros = 0 let g:neocomplcache_clang_macros = 0
endif endif
if !exists('g:neocomplcache_clang_complete_patterns') if !exists('g:neocomplcache_clang_patterns')
let g:neocomplcache_clang_complete_patterns = 0 let g:neocomplcache_clang_patterns = 0
endif endif
if !exists('g:neocomplcache_clang_complete_auto_options') if !exists('g:neocomplcache_clang_auto_options')
let g:neocomplcache_clang_complete_auto_options = 'path, .clang_complete' let g:neocomplcache_clang_auto_options = 'path, .clang_complete'
endif endif
if !exists('g:neocomplcache_clang_complete_user_options') if !exists('g:neocomplcache_clang_user_options')
let g:neocomplcache_clang_complete_user_options = '' let g:neocomplcache_clang_user_options = ''
endif
if !exists('g:neocomplcache_clang_debug')
let g:neocomplcache_clang_debug = 0
endif endif


let s:source = { let s:source = {
Expand All @@ -48,9 +51,9 @@ let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
function! s:init_ClangCompletePython() function! s:init_ClangCompletePython()
python import sys python import sys


if exists('g:neocomplcache_clang_complete_library_path') if exists('g:neocomplcache_clang_library_path')
" Load the library from the given library path. " Load the library from the given library path.
execute 'python sys.argv = ["' . escape(g:neocomplcache_clang_complete_library_path, '\') . '"]' execute 'python sys.argv = ["' . escape(g:neocomplcache_clang_library_path, '\') . '"]'
else else
" By setting argv[0] to '' force the python bindings to load the library " By setting argv[0] to '' force the python bindings to load the library
" from the normal system search path. " from the normal system search path.
Expand All @@ -59,13 +62,13 @@ function! s:init_ClangCompletePython()


execute 'python sys.path = ["' . s:plugin_path . '/clang_complete"] + sys.path' execute 'python sys.path = ["' . s:plugin_path . '/clang_complete"] + sys.path'
execute 'pyfile ' . s:plugin_path . '/clang_complete/libclang.py' execute 'pyfile ' . s:plugin_path . '/clang_complete/libclang.py'
python initClangComplete(vim.eval('g:neocomplcache_clang_complete_lib_flags')) python initClangComplete(vim.eval('g:neocomplcache_clang_lib_flags'))
endfunction endfunction


function! s:init_ClangComplete() function! s:init_ClangComplete()
let b:should_overload = 0 let b:should_overload = 0


call LoadUserOptions() call s:loadUserOptions()


let b:clang_exec = 'clang' let b:clang_exec = 'clang'
let b:clang_parameters = '-x c' let b:clang_parameters = '-x c'
Expand All @@ -82,34 +85,34 @@ function! s:init_ClangComplete()
let b:clang_parameters .= '-header' let b:clang_parameters .= '-header'
endif endif


let g:neocomplcache_clang_complete_lib_flags = 0 let g:neocomplcache_clang_lib_flags = 0
if g:neocomplcache_clang_complete_macros if g:neocomplcache_clang_macros
let b:clang_parameters .= ' -code-completion-macros' let b:clang_parameters .= ' -code-completion-macros'
let g:neocomplcache_clang_complete_lib_flags = 1 let g:neocomplcache_clang_lib_flags = 1
endif endif
if g:neocomplcache_clang_complete_patterns if g:neocomplcache_clang_patterns
let b:clang_parameters .= ' -code-completion-patterns' let b:clang_parameters .= ' -code-completion-patterns'
let g:clang_complete_lib_flags += 2 let g:clang_complete_lib_flags += 2
endif endif


" Load the python bindings of libclang. " Load the python bindings of libclang.
if g:neocomplcache_clang_complete_use_library if g:neocomplcache_clang_use_library
if has('python') if has('python')
call s:init_ClangCompletePython() call s:init_ClangCompletePython()
else else
echoe 'clang_complete: No python support available.' echoe 'clang_complete: No python support available.'
echoe 'Cannot use clang library, using executable' echoe 'Cannot use clang library, using executable'
echoe 'Compile vim with python support to use libclang' echoe 'Compile vim with python support to use libclang'
let g:neocomplcache_clang_complete_use_library = 0 let g:neocomplcache_clang_use_library = 0
return return
endif endif
endif endif
endfunction endfunction


function! LoadUserOptions() function! s:loadUserOptions()
let b:clang_user_options = '' let b:clang_user_options = ''


let l:option_sources = split(g:neocomplcache_clang_complete_auto_options, ',') let l:option_sources = split(g:neocomplcache_clang_auto_options, ',')
let l:remove_spaces_cmd = 'substitute(v:val, "\\s*\\(.*\\)\\s*", "\\1", "")' let l:remove_spaces_cmd = 'substitute(v:val, "\\s*\\(.*\\)\\s*", "\\1", "")'
let l:option_sources = map(l:option_sources, l:remove_spaces_cmd) let l:option_sources = map(l:option_sources, l:remove_spaces_cmd)


Expand Down Expand Up @@ -254,7 +257,7 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)
return [] return []
endif endif


if g:neocomplcache_clang_complete_use_library if g:neocomplcache_clang_use_library
python vim.command('let l:clang_output = ' + str(getCurrentCompletions(vim.eval('a:cur_keyword_str'), int(vim.eval('a:cur_keyword_pos+1'))))) python vim.command('let l:clang_output = ' + str(getCurrentCompletions(vim.eval('a:cur_keyword_str'), int(vim.eval('a:cur_keyword_pos+1')))))
" echomsg string(l:clang_output) " echomsg string(l:clang_output)
else else
Expand All @@ -278,7 +281,7 @@ function! s:complete_from_clang_binary(cur_keyword_pos, cur_keyword_str)
\ . ' -code-completion-at=' \ . ' -code-completion-at='
\ . l:escaped_tempfile . ":" . line('.') . ":" . (a:cur_keyword_pos+1) \ . l:escaped_tempfile . ":" . line('.') . ":" . (a:cur_keyword_pos+1)
\ . ' ' . l:escaped_tempfile \ . ' ' . l:escaped_tempfile
\ . ' ' . b:clang_parameters . ' ' . b:clang_user_options . ' ' . g:neocomplcache_clang_complete_user_options \ . ' ' . b:clang_parameters . ' ' . b:clang_user_options . ' ' . g:neocomplcache_clang_user_options
let l:clang_output = split(neocomplcache#system(l:command), '\n') let l:clang_output = split(neocomplcache#system(l:command), '\n')


call delete(l:tempfile) call delete(l:tempfile)
Expand Down
8 changes: 3 additions & 5 deletions autoload/neocomplcache/sources/clang_complete/libclang.py
Expand Up @@ -46,7 +46,7 @@ def getCurrentFile():
return (vim.current.buffer.name, file) return (vim.current.buffer.name, file)


def getCurrentTranslationUnit(update = False): def getCurrentTranslationUnit(update = False):
userOptionsGlobal = splitOptions(vim.eval("g:neocomplcache_clang_complete_user_options")) userOptionsGlobal = splitOptions(vim.eval("g:neocomplcache_clang_user_options"))
userOptionsLocal = splitOptions(vim.eval("b:clang_user_options")) userOptionsLocal = splitOptions(vim.eval("b:clang_user_options"))
args = userOptionsGlobal + userOptionsLocal args = userOptionsGlobal + userOptionsLocal


Expand Down Expand Up @@ -174,8 +174,7 @@ def getCurrentQuickFixList():


def updateCurrentDiagnostics(): def updateCurrentDiagnostics():
global debug global debug
# debug = int(vim.eval("g:clang_debug")) == 1 debug = int(vim.eval("g:neocomplcache_clang_debug")) == 1
debug = 0
getCurrentTranslationUnit(update = True) getCurrentTranslationUnit(update = True)


def getCurrentCompletionResults(line, column): def getCurrentCompletionResults(line, column):
Expand Down Expand Up @@ -227,8 +226,7 @@ def formatResult(result):


def getCurrentCompletions(base, column): def getCurrentCompletions(base, column):
global debug global debug
# debug = int(vim.eval("g:clang_debug")) == 1 debug = int(vim.eval("g:neocomplcache_clang_debug")) == 1
debug = False
# priority = vim.eval("g:clang_sort_algo") == 'priority' # priority = vim.eval("g:clang_sort_algo") == 'priority'
priority = True priority = True
line = int(vim.eval("line('.')")) line = int(vim.eval("line('.')"))
Expand Down

0 comments on commit 143e64e

Please sign in to comment.