Skip to content

Commit

Permalink
feat: Add g:doge_clang_args configurable option (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Nov 17, 2019
1 parent bd4892b commit c56c00c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ on a function, press `<Leader>d`, jump quickly through `TODO` items using
- [FAQ](#faq)
+ [Using C / C++](#using-c--c)
- [Prerequisites](#prerequisites)
- [Adding additional clang args](#adding-additional-clang-args)
- [Package manager](#package-manager)
- [Manual compiling](#manual-compiling)
- [Help](#help)
Expand Down Expand Up @@ -212,6 +213,15 @@ This is the parser that is being used for generating proper documentation.
- Python 3.5+
- `pip3 install clang`

#### Adding additional clang args

The Python binding for clang allows additional arguments. These arguments can be
set with `g:doge_clang_args`. For example:

```vim
g:doge_clang_args = ['-I', '/my/include/path']
```

#### Package manager

If you've installed clang via your package manager then you might have a file
Expand All @@ -236,7 +246,7 @@ $ python3
#### Manual compiling

If you compiled libclang manually, then make sure that your `$PATH` and
`$LD_LIBRARY_PATH` are set correctly.
`$LD_LIBRARY_PATH` are set correctly.

The libclang binary its location should be defined in the `$LD_LIBRARY_PATH`:

Expand Down
7 changes: 6 additions & 1 deletion generators/libclang.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ def main():
ext = file_ext if file_ext else vim.eval('&filetype')
workdir = vim.eval("expand('%:p:h')")

try:
args = vim.eval('g:doge_clang_args')
except vim.error:
args = []

lines = vim.eval("getline(line(1), line('$'))")
current_line = int(vim.eval("line('.')"))

Expand All @@ -155,7 +160,7 @@ def main():
tmp.write('\n'.join(lines))

index = Index.create()
tu = index.parse(filename)
tu = index.parse(filename, args=args)
if tu:
node = find_node(tu.cursor, current_line)
if node and node.kind in filters:
Expand Down

0 comments on commit c56c00c

Please sign in to comment.