arakashic / chromatica.nvim

Clang based syntax highlighting for Neovim
MIT License
299 stars 17 forks source link

Automatically search for compile arguments defined for a source file with a matching name… #61

Closed jdkula closed 5 years ago

jdkula commented 5 years ago

…if configured to do so. (Also update README.md to document this.)

Resolves #59 and (I believe) #40. Header highlighting would fail if compile arguments for the header file were omitted from compile_commands.json. This resolves the issue by simply searching for a matching source file in the database.

Rahlir commented 5 years ago

Could this be merged please?

arakashic commented 5 years ago

Thanks for the contribution! Although I think the patch will only work if there is a source file with the same name as the header file.

horta commented 4 years ago

I believe i'm having a similar issue.

I have a C11 project with the following relevant files:

include/nmm/codon.h
src/codon.c

I open first src/codon.c for which chromatica is able to parse correctly. If I then try to open include/nmm/codon.h, it fails.

Is chromatica not doing the association between src/codon.c and include/nmm/codon.h or that is something else?

2019-11-21 12:23:16,381 INFO     (chromatica.logging) --- Chromatica Log Start ---
2019-11-21 12:23:16,382 INFO     (chromatica.logging) NVIM v0.4.3, Python 3.7.5, neovim client 0.3.2
2019-11-21 12:23:16,383 INFO     (chromatica.core) --------- runtime variables ---------
2019-11-21 12:23:16,383 INFO     (chromatica.core) g:chromatica#_channel_id=4
2019-11-21 12:23:16,383 INFO     (chromatica.core) g:chromatica#enable_profiling=0
2019-11-21 12:23:16,383 INFO     (chromatica.core) g:chromatica#highlight_feature_level=1
2019-11-21 12:23:16,383 INFO     (chromatica.core) g:chromatica#delay_ms=80
2019-11-21 12:23:16,383 INFO     (chromatica.core) g:chromatica#libclang_path=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib
2019-11-21 12:23:16,383 INFO     (chromatica.core) g:chromatica#dotclangfile_search_path=
2019-11-21 12:23:16,384 INFO     (chromatica.core) g:chromatica#responsive_mode=1
2019-11-21 12:23:16,384 INFO     (chromatica.core) g:chromatica#enable_at_startup=1
2019-11-21 12:23:16,384 INFO     (chromatica.core) g:chromatica#syntax_src_id=100
2019-11-21 12:23:16,384 INFO     (chromatica.core) g:chromatica#enable_log=1
2019-11-21 12:23:16,384 INFO     (chromatica.core) g:chromatica#use_pch=1
2019-11-21 12:23:16,384 INFO     (chromatica.core) g:chromatica#search_source_args=1
2019-11-21 12:23:16,384 INFO     (chromatica.core) -------------------------------------
2019-11-21 12:23:16,414 INFO     (chromatica.core) Apple clang version 11.0.0 (clang-1100.0.33.12)
2019-11-21 12:23:16,414 INFO     (chromatica.core) Target: x86_64-apple-darwin19.0.0
2019-11-21 12:23:16,414 INFO     (chromatica.core) Thread model: posix
2019-11-21 12:23:16,414 INFO     (chromatica.core) InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
2019-11-21 12:23:16,414 INFO     (chromatica.core)  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 520 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-extra-semi-stmt -Wno-quoted-include-in-framework-header -fdeprecated-macro -fdebug-compilation-dir /Users/horta/code/nmm -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.15.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o - -x c++ -
2019-11-21 12:23:16,414 INFO     (chromatica.core) clang -cc1 version 11.0.0 (clang-1100.0.33.12) default target x86_64-apple-darwin19.0.0
2019-11-21 12:23:16,414 INFO     (chromatica.core) ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
2019-11-21 12:23:16,414 INFO     (chromatica.core) ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
2019-11-21 12:23:16,414 INFO     (chromatica.core) ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
2019-11-21 12:23:16,414 INFO     (chromatica.core) #include "..." search starts here:
2019-11-21 12:23:16,414 INFO     (chromatica.core) #include <...> search starts here:
2019-11-21 12:23:16,414 INFO     (chromatica.core)  /usr/local/include
2019-11-21 12:23:16,414 INFO     (chromatica.core)  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
2019-11-21 12:23:16,414 INFO     (chromatica.core)  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
2019-11-21 12:23:16,414 INFO     (chromatica.core)  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
2019-11-21 12:23:16,414 INFO     (chromatica.core)  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
2019-11-21 12:23:16,414 INFO     (chromatica.core)  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
2019-11-21 12:23:16,414 INFO     (chromatica.core) End of search list.
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 1 "<stdin>"
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 1 "<built-in>" 1
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 1 "<built-in>" 3
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 374 "<built-in>" 3
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 1 "<command line>" 1
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 1 "<built-in>" 2
2019-11-21 12:23:16,415 INFO     (chromatica.core) # 1 "<stdin>" 2
2019-11-21 12:23:16,415 INFO     (chromatica.core) 
2019-11-21 12:23:16,415 INFO     (chromatica.core) -------------------------------------
2019-11-21 12:23:16,443 INFO     (chromatica.compile_args) cdb: /Users/horta/code/nmm
2019-11-21 12:23:16,444 INFO     (chromatica.compile_args) Read cdb for: /Users/horta/code/nmm/src/codon.c
2019-11-21 12:23:16,444 DEBUG    (chromatica.core) filename: /Users/horta/code/nmm/src/codon.c
2019-11-21 12:23:16,444 DEBUG    (chromatica.core) args: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -DNMM_EXPORTS -I/Users/horta/code/nmm/include -I/Users/horta/code/nmm/include -I/Users/horta/code/nmm/src -I/Users/horta/code/nmm/src -isystem/usr/local/include -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fPIC -Wall -Wextra -pedantic -Wstrict-prototypes -Wshadow -Wconversion -Wmissing-prototypes -Wno-unused-parameter -Wno-empty-translation-unit
2019-11-21 12:23:16,492 DEBUG    (chromatica.syntax) get_highlight
2019-11-21 12:23:23,606 INFO     (chromatica.compile_args) Read cdb for: /Users/horta/code/nmm/include/nmm/codon.h
2019-11-21 12:23:23,606 DEBUG    (chromatica.core) filename: /Users/horta/code/nmm/include/nmm/codon.h
2019-11-21 12:23:23,606 DEBUG    (chromatica.core) args: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -DNMM_EXPORTS -I/Users/horta/code/nmm/include -I/Users/horta/code/nmm/include -I/Users/horta/code/nmm/src -I/Users/horta/code/nmm/src -isystem/usr/local/include -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fPIC -Wall -Wextra -pedantic -Wstrict-prototypes -Wshadow -Wconversion -Wmissing-prototypes -Wno-unused-parameter -Wno-empty-translation-unit /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -DNMM_EXPORTS -I/Users/horta/code/nmm/include -I/Users/horta/code/nmm/include -I/Users/horta/code/nmm/src -I/Users/horta/code/nmm/src -isystem/usr/local/include -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fPIC -Wall -Wextra -pedantic -Wstrict-prototypes -Wshadow -Wconversion -Wmissing-prototypes -Wno-unused-parameter -Wno-empty-translation-unit -x