Skip to content

Commit

Permalink
Add configuration of libclang library path
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Strothoff committed May 15, 2014
1 parent caf34b8 commit 7476bc1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
14 changes: 14 additions & 0 deletions doc/clang_doxygen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ comments, one of the supported snippet plugins has to be installed, see
==============================================================================
4. Configuration *clang_doxygen-configuration*

*'g:clang_doxygen_libclang_library_path'*
'g:clang_doxygen_libclang_library_path' string (default: unset)
global
If libClang can not be found automatically you have to set the path
where it can be found. In most cases you should not need to set this
option. If you however want to use a specific version of libClang or
your library is located in a non-standard location you can set the
path here.
This has to be set before using the clang doxygen plugin and can not
be changed after the plugin was loaded.
Example: If you are using LLVM 3.4 on Linux use: >
let g:clang_doxygen_libclang_library_path =
"/usr/lib/llvm-3.4/lib"
*'g:clang_doxygen_clang_args'*
'g:clang_doxygen_clang_args' list (default: [])
global
Expand Down
18 changes: 17 additions & 1 deletion plugin/clang_doxygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# All rights reserved.

import vim
from clang.cindex import Index, SourceLocation, Cursor, File, CursorKind, TypeKind
import re
from clang.cindex import Index, SourceLocation, Cursor, File, CursorKind, TypeKind, Config, LibclangError

# Generate doxygen comments for a class declaration.
def handleClassDecl(c):
Expand Down Expand Up @@ -252,3 +252,19 @@ def generateDoxygen():
vim.current.window.cursor = (insertLine, 0)
# Call snippet plugin
vim.command('call clang_doxygen_snippets#' + vim.eval("g:clang_doxygen_snippet_plugin") + '#trigger(\'' + "\n".join(doxygenLines).replace("\\", "\\\\") + '\')')

# Try to find liblang. Set library path if necessary.
def initialiseClangDoxygen():
conf = Config()

if vim.eval("exists(\"g:clang_doxygen_libclang_library_path\")") != "0":
Config.set_library_path(vim.eval("g:clang_doxygen_libclang_library_path"))
conf.set_library_path(vim.eval("g:clang_doxygen_libclang_library_path"))

try:
conf.get_cindex_library()
except LibclangError as e:
print "Error: " + str(e)
return

vim.command("let g:initialised_clang_doxygen = 1")
14 changes: 11 additions & 3 deletions plugin/clang_doxygen.vim
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ else
endif

function! s:GenerateDoxygen()
python import sys
exe 'python sys.path = ["' . s:plugin_path . '"] + sys.path'
exe 'pyfile ' . s:plugin_path . '/clang_doxygen.py'
if !exists("g:initialised_clang_doxygen")
python import sys
exe 'python sys.path = ["' . s:plugin_path . '"] + sys.path'
exe 'pyfile ' . s:plugin_path . '/clang_doxygen.py'

python initialiseClangDoxygen()

if !exists("g:initialised_clang_doxygen")
return
endif
endif

python generateDoxygen()
endfunction
Expand Down

0 comments on commit 7476bc1

Please sign in to comment.