Git Product home page Git Product logo

chromatica.nvim's Introduction

chromatica.nvim

End of Project

I have decided to stop the development and maintenance of this project. First of all, the landscape of compiler-based completion and syntax support has greatly improved over the past few years since the LSP is born. I think vim-lsp-cxx-hightlight which leverages LSP to provide semantic-based syntax highlight is a much cleaner solution for the problem. After trying it a bit, I have decide to switch to it.

I wrote chromatica because back then there is no good solution for the semantic-based syntax highlight on Neovim. I did not like the situation that it cannot share the AST with my auto completion which also uses clang. But there was no good solution for that. Things have changed a lot now.

I would suggest you move on to vim-lsp-cxx-highlight because it is simply better (and probably addressed some of the issues you run into with chromatica).

Chromatica is an asynchronous syntax highlight engine for Neovim. It is a python3 remote plugin. Currently, chromatica focuses on providing semantic accurate syntax highlighting for C-family languages (using libclang).

The project is in alpha state, but it is fairly stable and usable now.

Features

  • Asynchronous parsing and highlighting provides fast and responsive highlight as you update your code.
  • Semantic-accurate highlighting for C-family languages.

Example

Prerequites

Known Incompatibility

  • Python2 (sorry, Python3 only)
  • Some syntax plugins (depending on the loading order, third-party syntax plugins may overwrite/mess up Chromatica's highlight)

Installation

Install Prerequites

Install neovim python client and latest clang

pip3 install neovim
brew install llvm

Install Chromatica

Use a plugin manager (for example, Neobundle)

NeoBundle 'arakashic/chromatica.nvim'

Or manually check out the repo and put the directory to your vim runtime path.

Essential Settings

Like many other clang-based plugins, a path to your libclang is needed. Chromatica will default to /usr/lib/libclang.so, but you can specify a different one by setting

let g:chromatica#libclang_path='/usr/local/opt/llvm/lib'

The path can be set to either the path of the libclang.dylib/libclang.so file, or the directory that contains it.

If you want Chromatica to be automatically loaded at startup, you will need to set

let g:chromatica#enable_at_startup=1

Alternatively, you can manually enable and disable Chromatica by calling, respectively, :ChromaticaStart and :ChromaticaStop.

Compilation Flags

Chromatica already has flags for simple codes. To provide the most accurate highlighting for complex projects, chromatica needs to know the correct compilation flags such as include search path and macro definitions. There are three ways to do that in chromatica.

  1. A compilation database compile_commands.json.

    This is usually generated by CMake. If the project does not use CMake, you can generate it using Bear.

  2. A file that contains the compile options for the project. Chromatica recognizes most of these files used by other plugins or LSP servers. The following are the current supported files.

    .clang (for deoplete-clang or maybe other plugins)
    .color_coded (for color_coded)
    compile_flags.txt (for clangd)
    .cquery (for cquery)
    .ccls (for ccls)
    
  3. (DEPRECATED) A .chromatica (used to be .clang, but that name is taken) file that has the compilation flags similar to the format to a .clang file.

    The .chromatica file allows you to manually set the flags. For example:

    flags=-I/home/arakshic/.local/include -DNDEBUG
    flang=-I/../src
    

    Each flags option can have one or more compiler arguments. A .chromatica file can have multiple flags options. They will be concatenated in the order of their appearance.

When chromatica initializes, it search the current directory and the ancestor directories for these two files. If both file are present, chromatica will combine the flags in them.

For convenience, you can also set the g:chromatica#dotclangfile_search_path option to the directory that you put the .clang file or the compilation database. It overrides the default search directory.

If preferred, you can set the g:chromatica#search_source_args option to have Chromatica search the compilation database for similar filenames, if an entry for the current file is not found. (This is especially useful if your compilation database does not contain entries for header files). Currently, this just searches the database for the current file's base name, with the extensions .c, .cc, .cpp, or .cxx.

Highlight Feature Level

Chromatica provides different feature levels. Each level enables a different set of highlight. This is controlled by g:chromatica#highlight_feature_level.

The default level is 1, which let Chromatica handles most of the token in the code. A modified c.vim will be load for the highlighting the % format specifier and other stuff that a parser does not understand.

Setting it to 0 would limit Chromatica to handle only the identifiers and literals. This is only recommended if you have a slow machine and are experiencing performance issue with the full functionality of Chromatica. Note the $VIMRUNTIME/syntax/c.vim will be loaded in this case and may exhibit highlight conflicts in some scenarios.

Responsive Mode

By default, chromatica only updates highlight when returned to normal mode after changing the buffer. This is quite awkward since you may have changed thousands lines of codes, but the highlight will only be updated when you finish those changes and return to normal mode.

Chromatica provides a responsive mode that reparses and updates the hightlight as soon as you change the code (in insert mode). To use the responsive mode, simply set

let g:chromatica#responsive_mode=1

in your vimrc.

Note that the responsive mode comes at the cost of frequent reparsing the buffer. Even when the highlight is done asynchronously, frequent reparsing can still cause performance (editor responsiveness) problem if you C++ code is super complex (Yes, I haven't experienced this problem with C code). Chromatica uses pre-compiled header to speed up the repasing and throttles the number of reparse requests per seconds to avoid reparse flooding. You can increase g:chromatica#delay_ms if you still experiencing performance issues.

Common Issues

It is reported in issue #52 that the libclang may be missing one include directory on Linux, which causing incorrect highlight. You can fix it by adding the missing directory through global arguments. The following is an example.

let g:chromatica#global_args = ['-isystem/usr/lib/llvm-6.0/lib/clang/6.0.0/include']

Since OSX Mojave, the XCode command line tools does not create /usr/include any more, which breaks the LLVM from homebrew. You might need to run the following command to manually install it. More details can be found at here.

Troubleshooting and Customization

When a token is not highlighted or not highlighted correctly, the first thing to check if whether Chromatica has the correct compilation arguments. Because Chromatica uses the clang compiler parser, it is very important to get all the compilation arguments right. For example, if the compiler cannot find some of the header file, it may lead to some tokens does not get highlighted. The command ChromaticaShowInfo will print the basic information for the current buffer including the location of .clang, compilation database, compilation arguments, etc.

Chromatica has a debug log. It can be enabled by executing the ChromaticaEnableLog command (for one time use) or set the g:chromatica#enable_log option. It will generate a chromatica.log file in the current directory.

installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Chromatica also provides a AST dump feature that is useful for the users who want to customize the highlight settings. Simply executing the ChromaticaDbgAST will generate a AST_out.log file in the current directory. It contains the parsed tokes in the visible part of the buffer. The file is color-coded using terminal colors. You might need to manually enable the parsing of color code in your pager or reader. I would simply do a less -R on it.

For the following sample code

#include <iostream>

int main(int argc, const char* argv[])
{
    return 0;
}

The AST_out.log is

include chromaticaInclusionDirective [1, 2, 7] PREPROC IDENTIFIER INCLUSION_DIRECTIVE 
iostream None [1, 11, 8] IDENTIFIER INVALID_FILE 
int chromaticaType [3, 1, 3] KEYWORD FUNCTION_DECL FUNCTIONPROTO INT NONE 
main chromaticaFunctionDecl [3, 5, 4] IDENTIFIER FUNCTION_DECL FUNCTIONPROTO INT NONE 
int chromaticaType [3, 10, 3] KEYWORD PARM_DECL INT NONE 
argc chromaticaParmDecl [3, 14, 4] IDENTIFIER PARM_DECL INT NONE 
const chromaticaStorageClass [3, 20, 5] KEYWORD PARM_DECL INCOMPLETEARRAY NONE 
char chromaticaType [3, 26, 4] KEYWORD PARM_DECL INCOMPLETEARRAY NONE 
argv chromaticaParmDecl [3, 32, 4] IDENTIFIER PARM_DECL INCOMPLETEARRAY NONE 
return chromaticaStatement [5, 5, 6] KEYWORD RETURN_STMT NONE 
0 Number [5, 12, 1] LITERAL INTEGER_LITERAL INT NONE 

Each line represents one token. Following the token's spelling, there is the name of syntax group. This syntax group is what you need to set customized highlight. If a token does not match any syntax group, it will be shown as None. Then, there is the position of the token in [line, start column, length] format. The rest fields are the raw info of the token which are useful for debugging when some token is not correctly highlighted.

Acknowledgement

This project is largely inspired by deoplete and color_coded.

chromatica.nvim's People

Contributors

alepez avatar arakashic avatar bvolkmer avatar c0r73x avatar danyspin97 avatar deathlyfrantic avatar drnotthatevil avatar eliasp avatar ingomeyer441 avatar jdkula avatar pierremoreau avatar unnamed42 avatar xvoidee avatar yshui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chromatica.nvim's Issues

chromatica throws error when -include-pch is used

If I add the precompile header flag to .clang, chromatica will show the following error:
2016-08-26 3 12 13

If I remove the following flag:
-include-pch ./Example/Tests/Tests-Prefix.pch

everything will be fine.

Tests-Prefix.pch is empty, so it is not related to its content.

The libclang is the one coming from brew install llvm

Output of chromatic log:

2016-08-26 02:04:45,145 INFO     (chromatica.logging) --- Chromatica Log Start ---
2016-08-26 02:04:45,145 INFO     (chromatica.logging) NVIM v0.1.5-684-gbfa8378, Python 3.5.1, neovim client 0.1.9

Class fields hightlighting if field contains :: or <> in its type.

So I've got exactly the same issue with color_coded plugin. You can see the first comment here jeaye/color_coded#140 it describes enough about it.

This problem occurs because libclang.so uses incorrect default header search paths. So the solution of this issue for chromatica is nearly the same as for color_coded with differences of used files for compilation flags. So all you have to do is to call echo | clang -v -E -x c++ - and include all paths under the #include <...> search starts here: to your compile_command.json file. So I have included them to "command" field. So after that your "command" field will look like so:

"command": "c++ -c -o program.o -I/usr/local/include -I/usr/bin/../lib/clang/3.8.1/include -I/usr/include -I/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/backward -I/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/x86_64-pc-linux-gnu -I/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1 main.cpp"

All flags started with -I included by me and after I've included them everything have started working fine. So this problem is also know in YCM plugin too https://github.com/Valloric/YouCompleteMe#completion-doesnt-work-with-the-c-standard-library-headers . So I think you can include some documentation about this issue to your FAQ, maybe it will help some guys.

raise TranslationUnitLoadError("Error parsing translation unit.")

Hi,

This is my first attempt at using chromatica, I have a compile_commands.json which was in a ROOT/build folder, I moved it to the ROOT folder and then opened a file in ROOT/examples/ in neovim:

Here is an error in neovim :messages, I was wondering if it were normal ? I have no semantic highlighting.

error caught in async handler 'chromatica_highlight [{'filetype': 'cpp', 'filename': '/home/teto/dce2/example/dce-iperf.cc', 'buffer': <
neovim.api.buffer.Buffer object at 0x7f6393d320f0>, 'position': [27, 1], 'range': [1, 58], 'bufnr': 5, 'highlight_tick': 1, 'changedtick
': 2, 'args': ['-std=c++11', '-g', '-std=c++11', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-I
/home/teto/dce2/build/include', '-I/home/teto/dce2/include', '-I/home/teto/ns3off/install/include/ns3-dev', '-I/usr/include/gtk-2.0', '-
I/usr/lib/x86_64-linux-gnu/gtk-2.0/include', '-I/usr/include/gio-unix-2.0', '-I/usr/include/cairo', '-I/usr/include/pango-1.0', '-I/usr/
include/atk-1.0', '-I/usr/include/pixman-1', '-I/usr/include/libpng12', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/harfbuzz', '-I/
usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', '-I/usr/include/freetype2', '-I/usr/include/libxml2', '-DNS3_LOG_
ENABLE', '-DNS3_ASSERT_ENABLE', '-DHAVE_STDINT_H=1', '-DHAVE_INTTYPES_H=1', '-DHAVE_SYS_TYPES_H=1', '-DHAVE_SYS_STAT_H=1', '-DHAVE_DIREN
T_H=1', '-DHAVE_GETCPUFEATURES=1', '-DHAVE_VALGRIND_VALGRIND_H=1', '-DHAVE_VALGRIND_MEMCHECK_H=1', '-DHAVE_SIM_H=1', '-DKERNEL_STACK=Y',
 '-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"', '-DHAVE_PYEMBED=1',
 '-DHAVE_PYEXT=1', '-DHAVE_PYTHON_H=1', '-DHAVE_NS3_CORE=1', '-DHAVE_NS3_INTERNET=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_POINT_TO_POINT=1',
 '-DHAVE_SQLITE3=1', '-DHAVE_NS3_NETANIM=1', '-DHAVE_GTK2=1', '-DHAVE_LIBXML2=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_CSMA=1', '-DHAVE_SQLIT
E3=1', '-DHAVE_NS3_NETWORK=1', '-DHAVE_SQLITE3=1', '../example/dce-iperf.cc'], 'rpc': 'chromatica_highlight'}]'                         
Traceback (most recent call last):                                                                                                      
  File "/home/teto/.config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/__init__.py", line 33, in highlight                  
    self.__chromatica.highlight(context)                                                                                                
  File "/home/teto/.config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 197, in highlight               
    if filename not in self.ctx: return self.parse(context)                                                                             
  File "/home/teto/.config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 99, in parse                    
    options=self.parse_options)                                                                                                         
  File "/home/teto/.config/nvim/plugged/chromatica.nvim/rplugin/python3/clang/cindex.py", line 2533, in parse                           
    self)                                                                                                                               
  File "/home/teto/.config/nvim/plugged/chromatica.nvim/rplugin/python3/clang/cindex.py", line 2665, in from_source                     
    raise TranslationUnitLoadError("Error parsing translation unit.")                                                                   
clang.cindex.TranslationUnitLoadError: Error parsing translation unit.  

Here is the log, it doesn't say that it found my compile_commands.json - IMO it should - but it did as the flags are good:

2016-08-21 02:25:42,274 INFO     (chromatica.logging) --- Chromatica Log Start ---
2016-08-21 02:25:42,275 INFO     (chromatica.logging) NVIM v0.1.5-777-gae6db26, Python 3.5.2, neovim client 0.1.9
2016-08-21 02:26:53,185 DEBUG    (chromatica.core) filename: /home/teto/dce2/example/dce-iperf.cc
2016-08-21 02:26:53,188 INFO     (chromatica.core) args: ['-std=c++11', '-g', '-std=c++11', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-I/home/teto/dce2/build/include', '-I/home/teto/dce2/include', '-I/home/teto/ns3off/install/include/ns3-dev', '-I/usr/include/gtk-2.0', '-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include', '-I/usr/include/gio-unix-2.0', '-I/usr/include/cairo', '-I/usr/include/pango-1.0', '-I/usr/include/atk-1.0', '-I/usr/include/pixman-1', '-I/usr/include/libpng12', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/harfbuzz', '-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', '-I/usr/include/freetype2', '-I/usr/include/libxml2', '-DNS3_LOG_ENABLE', '-DNS3_ASSERT_ENABLE', '-DHAVE_STDINT_H=1', '-DHAVE_INTTYPES_H=1', '-DHAVE_SYS_TYPES_H=1', '-DHAVE_SYS_STAT_H=1', '-DHAVE_DIRENT_H=1', '-DHAVE_GETCPUFEATURES=1', '-DHAVE_VALGRIND_VALGRIND_H=1', '-DHAVE_VALGRIND_MEMCHECK_H=1', '-DHAVE_SIM_H=1', '-DKERNEL_STACK=Y', '-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"', '-DHAVE_PYEMBED=1', '-DHAVE_PYEXT=1', '-DHAVE_PYTHON_H=1', '-DHAVE_NS3_CORE=1', '-DHAVE_NS3_INTERNET=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_POINT_TO_POINT=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_NETANIM=1', '-DHAVE_GTK2=1', '-DHAVE_LIBXML2=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_CSMA=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_NETWORK=1', '-DHAVE_SQLITE3=1', '../example/dce-iperf.cc']
2016-08-21 02:26:53,195 DEBUG    (chromatica.core) {'filetype': 'cpp', 'filename': '/home/teto/dce2/example/dce-iperf.cc', 'buffer': <neovim.api.buffer.Buffer object at 0x7f6393d320f0>, 'position': [27, 1], 'range': [1, 58], 'bufnr': 5, 'highlight_tick': 1, 'changedtick': 2, 'args': ['-std=c++11', '-g', '-std=c++11', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-pthread', '-I/home/teto/dce2/build/include', '-I/home/teto/dce2/include', '-I/home/teto/ns3off/install/include/ns3-dev', '-I/usr/include/gtk-2.0', '-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include', '-I/usr/include/gio-unix-2.0', '-I/usr/include/cairo', '-I/usr/include/pango-1.0', '-I/usr/include/atk-1.0', '-I/usr/include/pixman-1', '-I/usr/include/libpng12', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/harfbuzz', '-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', '-I/usr/include/freetype2', '-I/usr/include/libxml2', '-DNS3_LOG_ENABLE', '-DNS3_ASSERT_ENABLE', '-DHAVE_STDINT_H=1', '-DHAVE_INTTYPES_H=1', '-DHAVE_SYS_TYPES_H=1', '-DHAVE_SYS_STAT_H=1', '-DHAVE_DIRENT_H=1', '-DHAVE_GETCPUFEATURES=1', '-DHAVE_VALGRIND_VALGRIND_H=1', '-DHAVE_VALGRIND_MEMCHECK_H=1', '-DHAVE_SIM_H=1', '-DKERNEL_STACK=Y', '-DPYTHONDIR="/usr/local/lib/python2.7/dist-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/dist-packages"', '-DHAVE_PYEMBED=1', '-DHAVE_PYEXT=1', '-DHAVE_PYTHON_H=1', '-DHAVE_NS3_CORE=1', '-DHAVE_NS3_INTERNET=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_POINT_TO_POINT=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_NETANIM=1', '-DHAVE_GTK2=1', '-DHAVE_LIBXML2=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_CSMA=1', '-DHAVE_SQLITE3=1', '-DHAVE_NS3_NETWORK=1', '-DHAVE_SQLITE3=1', '../example/dce-iperf.cc'], 'rpc': 'chromatica_highlight'}

Really excited by this plugin, thanks for your job so far

Run chromatica on header files using compile_commands.json

I've managed to setup chromatica to run successuflly on cpp files of a C++ project using the compile_commands.json file generated by cmake. However chromatica doesn't seem to highlight at all the include (.h or _impl.h where there is actual implememtation and where highlighting is quite useful) files.

I assume that's because there is no information about these files in the compile_commans.json file. Am I missing something? Any way of solving this?
Is there support for something similar to neoinclude as with deoplete-clang?

Thanks,
Nikos

Highlighting problems if cursorline is activated

First: Thanks for your project! Chromatica helps a lot for daily work.

If the cursorline setting is activated, the syntax highlighting of chromatica is overriden by the default highlighting:
image
Unfortunately, I am not sure if this is a issue with chromatica, neovim or maybe my colorscheme (vim-one).

Performance improvement

Maybe using matchaddpos() would improve the performance:

  1. reduce the number of RPC calls
  2. avoid re-highlighting of existing codes

Debug logging assumes location of clang binary relative to library

I'm on Ubuntu 16.04, and I'm running Neovim with Chromatica. Some highlighting is missing, so I wanted to debug it. However, when trying to run ChromaticaEnableLog, the following occurs:

[chromatica] Logging to chromatica.log
Error detected while processing function chromatica#enable_logging:
line    6:
error caught in request handler 'chromatica_enable_logging ['INFO', 'chromatica.log']':
Traceback (most recent call last):
  File "/home/student.unimelb.edu.au/mnazecic/.config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/__init__.py", line 29, in enable_logging
    self.__chromatica.dump_debug_info()
  File "/home/student.unimelb.edu.au/mnazecic/.config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 94, in dump_debug_info
    clang_verbose_info = util.get_clang_include_path(self.library_path).decode()
  File "/home/student.unimelb.edu.au/mnazecic/.config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/util.py", line 108, in get_clang_include_path
    stderr=subprocess.STDOUT)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/bin/clang'

I found that it was because it was trying to find the Clang binary relative to the library path, but my Clang library is in /usr/lib/x86_64-linux-gnu/, so it ends up looking for /usr/lib/bin/clang. Could we perhaps also specify a path to the Clang binary?

Chromatica can't find libclang_path

Hello,
I have some trouble to make chromatica work.
I'm using:

  • ubuntu 16.04
  • libclang 3.8
  • python 2.7
  • neovim 0.2.0

I've set

let g:chromatica#libclang_path="/usr/lib/llvm-3.8/lib/libclang.so"

But when doing ChromaticaStart, I still have the same error message:

[chromatica] There was an error starting chromatica. Please check g:chromatica#libclang_path.

Is there any way to see what is not working here ?

Also, what does g:chromatica#enable_debug does ?
i've tried to set it, but nothing changed.
Could you document it ?

Chromatica works poorly with Solarized Color Scheme

Hi! I've tried to setup Chromatica with my vim-colors-solarized colorscheme setup and noticed major issues:

  • Default colors are overriden
  • Similar syntax constructions are colored differently (see includes for the reference)
  • Some code becomes not colored at all (see struct Line members)

Here is my nvim config, I only added two lines where appropriate:

Plug 'arakashic/chromatica.nvim'

and

let g:chromatica#libclang_path = '/usr/lib/libclang.so'

I also attached the screenshot. Left pane: colorscheme solarized enabled, chromatica enabled, middle pane: colorscheme solarized disabled, chromatica enabled, right pane: colorscheme solarized enabled, chromatica disabled.

chromatica

Different coloring in a header vs cpp file

I noticed slightly different coloring in a header vs a cpp file, see screenshot:

chromatica_bug

Don't know if this is expected, seems wrong to me.
The relevant settings in my vimrc are:

let g:chromatica#enable_at_startup=1
let g:chromatica#highlight_feature_level=1

Chromatica crashes with compile_commands.json file generated by Bear.

I've got very simple Makefile and little test program. When I've generated compile_commands.json file chromatica have crashed with the following Traceback:

error caught in async handler 'chromatica_highlight [{'highlight_tick': 1, 'filetype': 'cpp', 'args': ['g++', 'program.o', 'main.cpp'], 'pos
ition': [1, 1], 'filename': '/home/melon/Temp/Test_project/main.cpp', 'rpc': 'chromatica_highlight', 'bufnr': 1, 'changedtick': 3, 'buffer':
<neovim.api.buffer.Buffer object at 0x7f041353a1d0>, 'range': [1, 40]}]'
Traceback (most recent call last):
File "/home/melon/.config/nvim/bundle/chromatica.nvim/rplugin/python3/chromatica/init.py", line 33, in highlight
self.__chromatica.highlight(context)
File "/home/melon/.config/nvim/bundle/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 197, in highlight
if filename not in self.ctx: return self.parse(context)
File "/home/melon/.config/nvim/bundle/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 99, in parse
options=self.parse_options)
File "/home/melon/.config/nvim/bundle/chromatica.nvim/rplugin/python3/clang/cindex.py", line 2533, in parse
self)
File "/home/melon/.config/nvim/bundle/chromatica.nvim/rplugin/python3/clang/cindex.py", line 2665, in from_source
raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex.TranslationUnitLoadError: Error parsing translation unit.

Here is my simple test project.
chromatica-test.tar.gz

So maybe I'm doing something wrong or maybe it is a bug.

chromatica doesn't work with clang 7

Distro: ArchLinux with testing on.
Neovim version: 0.3.1
log

2018-10-01 17:12:33,065 INFO     (chromatica.logging) --- Chromatica Log Start ---
2018-10-01 17:12:33,070 INFO     (chromatica.logging) NVIM v0.3.1, Python 3.7.0, neovim client 0.2.6
2018-10-01 17:12:33,071 INFO     (chromatica.core) --------- runtime variables ---------
2018-10-01 17:12:33,071 INFO     (chromatica.core) g:chromatica#_channel_id=6
2018-10-01 17:12:33,071 INFO     (chromatica.core) g:chromatica#enable_profiling=1
2018-10-01 17:12:33,071 INFO     (chromatica.core) g:chromatica#highlight_feature_level=1
2018-10-01 17:12:33,071 INFO     (chromatica.core) g:chromatica#delay_ms=80
2018-10-01 17:12:33,071 INFO     (chromatica.core) g:chromatica#libclang_path=/usr/lib/libclang.so
2018-10-01 17:12:33,072 INFO     (chromatica.core) g:chromatica#dotclangfile_search_path=
2018-10-01 17:12:33,072 INFO     (chromatica.core) g:chromatica#responsive_mode=1
2018-10-01 17:12:33,072 INFO     (chromatica.core) g:chromatica#enable_at_startup=1
2018-10-01 17:12:33,072 INFO     (chromatica.core) g:chromatica#syntax_src_id=100
2018-10-01 17:12:33,072 INFO     (chromatica.core) g:chromatica#enable_log=1
2018-10-01 17:12:33,072 INFO     (chromatica.core) g:chromatica#use_pch=1
2018-10-01 17:12:33,072 INFO     (chromatica.core) -------------------------------------
2018-10-01 17:12:33,139 INFO     (chromatica.core) clang version 7.0.0 (tags/RELEASE_700/final)
2018-10-01 17:12:33,139 INFO     (chromatica.core) Target: x86_64-pc-linux-gnu
2018-10-01 17:12:33,139 INFO     (chromatica.core) Thread model: posix
2018-10-01 17:12:33,140 INFO     (chromatica.core) InstalledDir: /usr/bin
2018-10-01 17:12:33,140 INFO     (chromatica.core) Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/8.2.1
2018-10-01 17:12:33,140 INFO     (chromatica.core) Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1
2018-10-01 17:12:33,140 INFO     (chromatica.core) Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1
2018-10-01 17:12:33,140 INFO     (chromatica.core) Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.1
2018-10-01 17:12:33,140 INFO     (chromatica.core) Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1
2018-10-01 17:12:33,140 INFO     (chromatica.core) Candidate multilib: .;@m64
2018-10-01 17:12:33,140 INFO     (chromatica.core) Candidate multilib: 32;@m32
2018-10-01 17:12:33,140 INFO     (chromatica.core) Selected multilib: .;@m64
2018-10-01 17:12:33,140 INFO     (chromatica.core)  "/usr/bin/clang-7" -cc1 -triple x86_64-pc-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/7.0.0 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/7.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/zwindl/project/srain -ferror-limit 19 -fmessage-length 0 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o - -x c++ - -faddrsig
2018-10-01 17:12:33,140 INFO     (chromatica.core) clang -cc1 version 7.0.0 based upon LLVM 7.0.0 default target x86_64-pc-linux-gnu
2018-10-01 17:12:33,140 INFO     (chromatica.core) ignoring nonexistent directory "/include"
2018-10-01 17:12:33,140 INFO     (chromatica.core) #include "..." search starts here:
2018-10-01 17:12:33,140 INFO     (chromatica.core) #include <...> search starts here:
2018-10-01 17:12:33,141 INFO     (chromatica.core)  /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1
2018-10-01 17:12:33,141 INFO     (chromatica.core)  /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu
2018-10-01 17:12:33,141 INFO     (chromatica.core)  /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/backward
2018-10-01 17:12:33,141 INFO     (chromatica.core)  /usr/local/include
2018-10-01 17:12:33,141 INFO     (chromatica.core)  /usr/lib/clang/7.0.0/include
2018-10-01 17:12:33,141 INFO     (chromatica.core)  /usr/include
2018-10-01 17:12:33,141 INFO     (chromatica.core) End of search list.
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 1 "<stdin>"
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 1 "<built-in>" 1
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 1 "<built-in>" 3
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 394 "<built-in>" 3
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 1 "<command line>" 1
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 1 "<built-in>" 2
2018-10-01 17:12:33,141 INFO     (chromatica.core) # 1 "<stdin>" 2
2018-10-01 17:12:33,141 INFO     (chromatica.core) 
2018-10-01 17:12:33,142 INFO     (chromatica.core) -------------------------------------
2018-10-01 17:12:33,271 INFO     (chromatica.compile_args) Read cdb for: /home/zwindl/project/srain/src/core/chat_command.c
2018-10-01 17:12:33,271 DEBUG    (chromatica.core) filename: /home/zwindl/project/srain/src/core/chat_command.c
2018-10-01 17:12:33,272 DEBUG    (chromatica.core) args: gcc -std=gnu99 -O2 -Wall -I/home/zwindl/project/srain/src/inc -Iinc -Wno-deprecated-declarations -D -D PACKAGE_NAME="Srain" -D PACKAGE_VERSION="1.0.0rc1" -D PACKAGE_BUILD="[email protected]" -D PACKAGE_APPID="im.srain.Srain" -D PACKAGE_AUTHOR="Shengyu Zhang" -D PACKAGE_EMAIL="[email protected]" -D PACKAGE_DESC="Modern, beautiful IRC client written in GTK+ 3." -D PACKAGE_WEBSITE="https://srain.im" -D PACKAGE_DATA_DIR="/home/zwindl/project/srain/build" -D PACKAGE_CONFIG_DIR="/home/zwindl/project/srain/build/etc" -D PACKAGE_COPYRIGHT_DATES="2016 - 2018" -I/usr/include/gtk-3.0 -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/lib/libffi-3.2.1/include -I/usr/include/fribidi -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/harfbuzz -I/usr/include/uuid -I/usr/include/uuid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/libdrm -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/lib/dbus-1.0/include -pthread -I/usr/include/libsoup-2.4 -I/usr/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/lib/libffi-3.2.1/include -pthread -I/usr/include/libmount -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/uuid -I/usr/include/libxml2 -I/usr/include/libxml2 -ggdb
2018-10-01 17:12:33,300 DEBUG    (chromatica.core) [profile] parse index.parse: 0.020319s
2018-10-01 17:12:33,311 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:33,371 DEBUG    (chromatica.core) [profile] _highlight: 0.017553s
2018-10-01 17:12:33,873 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:33,891 DEBUG    (chromatica.core) [profile] _highlight: 0.015136s
2018-10-01 17:12:34,031 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:34,050 DEBUG    (chromatica.core) [profile] _highlight: 0.013768s
2018-10-01 17:12:34,193 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:34,203 DEBUG    (chromatica.core) [profile] _highlight: 0.009851s
2018-10-01 17:12:34,384 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:34,392 DEBUG    (chromatica.core) [profile] _highlight: 0.009056s
2018-10-01 17:12:34,892 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:34,902 DEBUG    (chromatica.core) [profile] _highlight: 0.010936s
2018-10-01 17:12:35,062 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:35,072 DEBUG    (chromatica.core) [profile] _highlight: 0.010338s
2018-10-01 17:12:35,871 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:35,881 DEBUG    (chromatica.core) [profile] _highlight: 0.010514s
2018-10-01 17:12:36,009 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:36,019 DEBUG    (chromatica.core) [profile] _highlight: 0.010841s
2018-10-01 17:12:36,151 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:36,160 DEBUG    (chromatica.core) [profile] _highlight: 0.009951s
2018-10-01 17:12:36,510 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:36,520 DEBUG    (chromatica.core) [profile] _highlight: 0.010133s
2018-10-01 17:12:36,667 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:36,676 DEBUG    (chromatica.core) [profile] _highlight: 0.009728s
2018-10-01 17:12:36,820 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:36,828 DEBUG    (chromatica.core) [profile] _highlight: 0.008548s
2018-10-01 17:12:37,099 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,109 DEBUG    (chromatica.core) [profile] _highlight: 0.009941s
2018-10-01 17:12:37,714 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,727 DEBUG    (chromatica.core) [profile] _highlight: 0.013194s
2018-10-01 17:12:37,732 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,744 DEBUG    (chromatica.core) [profile] _highlight: 0.011793s
2018-10-01 17:12:37,749 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,761 DEBUG    (chromatica.core) [profile] _highlight: 0.012042s
2018-10-01 17:12:37,765 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,776 DEBUG    (chromatica.core) [profile] _highlight: 0.010584s
2018-10-01 17:12:37,800 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,813 DEBUG    (chromatica.core) [profile] _highlight: 0.012508s
2018-10-01 17:12:37,820 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,829 DEBUG    (chromatica.core) [profile] _highlight: 0.009746s
2018-10-01 17:12:37,851 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,861 DEBUG    (chromatica.core) [profile] _highlight: 0.011154s
2018-10-01 17:12:37,866 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,876 DEBUG    (chromatica.core) [profile] _highlight: 0.010489s
2018-10-01 17:12:37,898 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,908 DEBUG    (chromatica.core) [profile] _highlight: 0.009844s
2018-10-01 17:12:37,933 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,947 DEBUG    (chromatica.core) [profile] _highlight: 0.012591s
2018-10-01 17:12:37,954 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,964 DEBUG    (chromatica.core) [profile] _highlight: 0.011473s
2018-10-01 17:12:37,969 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,981 DEBUG    (chromatica.core) [profile] _highlight: 0.010536s
2018-10-01 17:12:37,987 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:37,999 DEBUG    (chromatica.core) [profile] _highlight: 0.012841s
2018-10-01 17:12:38,004 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,019 DEBUG    (chromatica.core) [profile] _highlight: 0.014002s
2018-10-01 17:12:38,025 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,034 DEBUG    (chromatica.core) [profile] _highlight: 0.009986s
2018-10-01 17:12:38,039 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,053 DEBUG    (chromatica.core) [profile] _highlight: 0.012228s
2018-10-01 17:12:38,059 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,070 DEBUG    (chromatica.core) [profile] _highlight: 0.011628s
2018-10-01 17:12:38,075 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,086 DEBUG    (chromatica.core) [profile] _highlight: 0.010609s
2018-10-01 17:12:38,091 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,103 DEBUG    (chromatica.core) [profile] _highlight: 0.011672s
2018-10-01 17:12:38,108 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,119 DEBUG    (chromatica.core) [profile] _highlight: 0.010923s
2018-10-01 17:12:38,125 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,134 DEBUG    (chromatica.core) [profile] _highlight: 0.009271s
2018-10-01 17:12:38,139 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,153 DEBUG    (chromatica.core) [profile] _highlight: 0.011798s
2018-10-01 17:12:38,159 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,167 DEBUG    (chromatica.core) [profile] _highlight: 0.008854s
2018-10-01 17:12:38,172 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,186 DEBUG    (chromatica.core) [profile] _highlight: 0.010895s
2018-10-01 17:12:38,191 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,200 DEBUG    (chromatica.core) [profile] _highlight: 0.009206s
2018-10-01 17:12:38,205 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,214 DEBUG    (chromatica.core) [profile] _highlight: 0.008069s
2018-10-01 17:12:38,223 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,231 DEBUG    (chromatica.core) [profile] _highlight: 0.008210s
2018-10-01 17:12:38,261 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,268 DEBUG    (chromatica.core) [profile] _highlight: 0.007622s
2018-10-01 17:12:38,274 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,279 DEBUG    (chromatica.core) [profile] _highlight: 0.005558s
2018-10-01 17:12:38,289 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,295 DEBUG    (chromatica.core) [profile] _highlight: 0.006148s
2018-10-01 17:12:38,329 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,338 DEBUG    (chromatica.core) [profile] _highlight: 0.007581s
2018-10-01 17:12:38,361 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,369 DEBUG    (chromatica.core) [profile] _highlight: 0.007134s
2018-10-01 17:12:38,375 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,382 DEBUG    (chromatica.core) [profile] _highlight: 0.007279s
2018-10-01 17:12:38,390 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,397 DEBUG    (chromatica.core) [profile] _highlight: 0.006410s
2018-10-01 17:12:38,407 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,412 DEBUG    (chromatica.core) [profile] _highlight: 0.006192s
2018-10-01 17:12:38,424 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,430 DEBUG    (chromatica.core) [profile] _highlight: 0.006179s
2018-10-01 17:12:38,441 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,451 DEBUG    (chromatica.core) [profile] _highlight: 0.009969s
2018-10-01 17:12:38,459 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,465 DEBUG    (chromatica.core) [profile] _highlight: 0.006268s
2018-10-01 17:12:38,476 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,487 DEBUG    (chromatica.core) [profile] _highlight: 0.010216s
2018-10-01 17:12:38,492 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,498 DEBUG    (chromatica.core) [profile] _highlight: 0.005865s
2018-10-01 17:12:38,510 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,519 DEBUG    (chromatica.core) [profile] _highlight: 0.009356s
2018-10-01 17:12:38,525 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,531 DEBUG    (chromatica.core) [profile] _highlight: 0.005397s
2018-10-01 17:12:38,544 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,552 DEBUG    (chromatica.core) [profile] _highlight: 0.008213s
2018-10-01 17:12:38,559 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,575 DEBUG    (chromatica.core) [profile] _highlight: 0.011942s
2018-10-01 17:12:38,581 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,595 DEBUG    (chromatica.core) [profile] _highlight: 0.013832s
2018-10-01 17:12:38,602 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,610 DEBUG    (chromatica.core) [profile] _highlight: 0.006300s
2018-10-01 17:12:38,616 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,623 DEBUG    (chromatica.core) [profile] _highlight: 0.006497s
2018-10-01 17:12:38,627 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,633 DEBUG    (chromatica.core) [profile] _highlight: 0.006774s
2018-10-01 17:12:38,645 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,654 DEBUG    (chromatica.core) [profile] _highlight: 0.009096s
2018-10-01 17:12:38,661 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,668 DEBUG    (chromatica.core) [profile] _highlight: 0.007269s
2018-10-01 17:12:38,679 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,690 DEBUG    (chromatica.core) [profile] _highlight: 0.010061s
2018-10-01 17:12:38,698 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,707 DEBUG    (chromatica.core) [profile] _highlight: 0.008085s
2018-10-01 17:12:38,714 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,725 DEBUG    (chromatica.core) [profile] _highlight: 0.011152s
2018-10-01 17:12:38,754 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,762 DEBUG    (chromatica.core) [profile] _highlight: 0.008768s
2018-10-01 17:12:38,767 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,777 DEBUG    (chromatica.core) [profile] _highlight: 0.009226s
2018-10-01 17:12:38,803 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,812 DEBUG    (chromatica.core) [profile] _highlight: 0.009085s
2018-10-01 17:12:38,833 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,840 DEBUG    (chromatica.core) [profile] _highlight: 0.008035s
2018-10-01 17:12:38,888 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,900 DEBUG    (chromatica.core) [profile] _highlight: 0.009113s
2018-10-01 17:12:38,939 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:38,950 DEBUG    (chromatica.core) [profile] _highlight: 0.010729s
2018-10-01 17:12:39,042 DEBUG    (chromatica.syntax) get_highlight
2018-10-01 17:12:39,052 DEBUG    (chromatica.core) [profile] _highlight: 0.008463s

[RFC] Possible performance improvements using neovim Live Updates

Hello! A friend showed me your Chromatica plugin which looks like it has a lot of potential. Personally I'm very excited to see some new async Syntax engines since vim's :syntax commands haven't kept up with what other modern editors can do.

I also had plans to write an external syntax engine for neovim, but first I wanted to deal with the problem of how to efficiently feed text changes into the external parser. I have made a working patch to neovim which solves this problem: neovim/neovim#5269

I would love to hear your thoughts on that PR I have submitted, and whether you think it would help your Chromatica plugin, because the PR was specifically designed to help with plugins such as yours.

The docs I wrote should hopefully be enough to explain how the new feature works and give you an idea as to whether it would be useful for you or not: https://github.com/neovim/neovim/pull/5269/files#diff-f87461134f13a9308795c382e03cbfa8

Highlighting is not updated on viewport change

Hey,
chromatica does not update highlighting when only the viewport is changed (e.g. by pressing zz or <C-y>) and the cursor stays in place. Would it maybe be better to call chromatica#handlers#_highlight() on CursorHold and not on CursorMoved? (see handlers.vim)

cTodo 不高亮

当 g:chromatica#responsive_mode=1时,注释中的TODO关键字只有当光标移动到该行时才会高亮,如下图:
screenshot from 2016-11-02 16 12 26

Tokens not highlighted in code only including standard library

Image
The code compiles without any flags on both g++ and clang++ and works correctly.
As we can see, scanf on line 12 is not highlighted, as well as variables i and v on lines 12 and 15.

I use Neovim 0.1.7

% clang --version  
clang version 3.9.1 (tags/RELEASE_391/final)  
Target: x86_64-unknown-linux-gnu  
Thread model: posix  
InstalledDir: /usr/bin  
% pip3 --version                                                               
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

The code

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	for (int i = 0; i < n; i++) {
		int x = v[i];
		printf("%d ", x);	
	}
	return 0;
}

Chromatica results for junegunn/seoul256

Hi,
I'm posting some images to show the results of Chromatica used with the colorscheme of junegunn/seoul256.
Here is the results, I concatenated 4 images of cpp codes (hpp in term, src in term, hpp in gui, src in gui).

For comparison, when chromatica is not active:
nofeat

When chromatica feature lvl 0 is active:
feat0

When chromatica feature lvl 1 is active:
feat1

For now, I think the feature lvl 0 of Chromatica is doing the best job.
However, I found the gui color for the namespace and include file is really ugly. Is there a way to change it? (the term color is ok though)
Also, the color for local variable is grey and not very visible on dark/grey background.

Thanks again for your great plugin!

Can't find compile_commands.json or .clang file on Windows

:ChromaticaShowInfo tells me that neither a .clang or compile_commands.json are found, even though both exist in the root of the cd path in Neovim. The log files show me that Chromatica is looking for Clang includes and executables in /usr/bin which is not a directory on Windows 10. I have already supplied Chromatica with the dynamic library of libclang (libclang.dll) and it still seems to be looking elsewhere. Is this perhaps a conflict with the Windows Linux Subsystem or MSYS2 (both of which provide Linux-like tools), as I have both installed? I am doing everything within nvim-qt. Thank you for this plugin, and your time.

Adding Feature Level 2

Allow macros to be highlighted according to the build configuration. This is useful for code with many #ifdef and #if.

Creating test suite

Creating a test suite to check the highlight for various language features.

Maybe by combining the code snippets from www.cppreference.com

The codes are not necessarily to be compilable/runnable.

6d374fb ("Update libclang bindings") breaks Chromatica

After updating to the latest HEAD (8f89c0d) on master, I get the following error message:

error caught in async handler 'chromatica_highlight [{'filename': '/home/pmoreau/teaching/LU_Computer_Graphics_Labs/src/core/opengl.cpp', 'position': [1, 1], 'highlight_tick': 1, 'range': [1, 88], 'filetype': 'cpp', 'rpc': 'chromatica_highlight', 'args': ['/usr/bin/clang++', '-DGLFW_DLL', '-I/home/pmoreau/privat/bui
ld/LU_Computer_Graphics_Labs/imgui/include', '-I/home/pmoreau/privat/build/LU_Computer_Graphics_Labs/imgui/include', '-I/home/pmoreau/teaching/LU_Computer_Graphics_Labs/src', '-I/home/pmoreau/teaching/LU_Computer_Graphics_Labs/src', '-I/home/pmoreau/teaching/LU_Computer_Graphics_Labs/src/external', '-I/home/pmoreau/
teaching/LU_Computer_Graphics_Labs/src/external', '-g', '-std=c++14'], 'tu': <clang.cindex.TranslationUnit object at 0x7fe00ebfbdd8>, 'buffer': <neovim.api.buffer.Buffer object at 0x7fe00ebefc50>, 'bufnr': 1, 'changedtick': 3}]'
Traceback (most recent call last):
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/__init__.py", line 33, in highlight
    self.__chromatica.highlight(context)
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 198, in highlight
    if filename not in self.ctx: return self.parse(context)
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 115, in parse
    self.highlight(context) # update highlight on entire file
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 202, in highlight
    self._highlight(filename, lbegin, lend)
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 157, in _highlight
    syn_group = syntax.get_highlight(tu, buffer.name, _lbegin, _lend)
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/chromatica/syntax.py", line 409, in get_highlight
    n_moreline = token.spelling.count("\n")
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/clang/cindex.py", line 3188, in spelling
    return str(conf.lib.clang_getTokenSpelling(self._tu, self))
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/clang/cindex.py", line 89, in __str__
    return str(self.value)
  File "/home/pmoreau/privat/dotfiles/config/nvim/plugged/chromatica.nvim/rplugin/python3/clang/cindex.py", line 95, in value
    return super(c_char_p, self).value.decode("utf8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 1: invalid start byte

Bisecting the last commits points to 6d374fb being the one introducing the regression.

clang: 3.9.0
neovim: 0.1.7
CMake: 3.6.3

I use CMake to generate the compile_commands.json, which is read by Chromatica. You can find the code I used to trigger the error here.

Error "Key not found"

Sometimes I get this error when opening a cpp file:

error caught in async handler 'chromatica_parse [{'rpc': 'chromatica_parse', 'filetype': 'cpp', 'buffer': <neovim.api.buffer.  Buffer object at 0x7fd205247780>, 'args': [ ... ], 'tu': <clang.cindex.TranslationUnit object at 0x7fd205249d68>, 'filename': '...', 'bufnr': 1, 'range': [1, 31], 'highlight_tick': 0, 'position': [1, 1], 'changedti ck': 4}]'
Traceback (most recent call last):
  File "/home/_/.vim/plugged/chromatica.nvim/rplugin/python3/chromatica/__init__.py", line 42, in parse
    self.__chromatica.parse(context)
  File "/home/_/.vim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 121, in parse
    self.highlight(context) # update highlight on entire file
  File "/home/_/.vim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 210, in highlight
    if highlight_tick != buffer.vars["highlight_tick"]: return
  File "/usr/local/lib/python3.4/dist-packages/neovim/api/common.py", line 81, in __getitem__
    return self._get(key)
  File "/usr/local/lib/python3.4/dist-packages/neovim/api/common.py", line 44, in request
    return self._session.request(name, self, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/neovim/api/nvim.py", line 131, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/neovim/msgpack_rpc/session.py", line 98, in request
    raise self.error_wrapper(err)
neovim.api.nvim.NvimError: b'Key not found'

I don't know why but... opening a file with ":e filename" always raise this error, while opening with ctrlp works as expected.

Memory

Hello,

I notice python 3 use wich chromatica use 500Mb of RAM in 10 minute and more after 1 hour in the same file.

is that normal ? or just me ?

Remote plugin for JS highlighting

I don't really know Vimscript so I used chromatica as inspiration. I've managed to create a remote plugin (node) that uses an AST to highlight js source code.

My question is would you want to see this bundled with chromatica, or would you rather it be a separate plugin?

Stop the annoying error

chromatica will keep popping up the message error caught in async handler 'chromatica_parse' when there are some errors in the code.
Is there a way to stop this message from showing up?

Set the path to the compilation database via a variable

It would be very useful to set the path to the compilation database via a variable in init.vim.

I output the compilation database in the build folder of my project because I don't want it to pollute the main source tree where I only keep the source files; after all the compilation database is an artifact of building but it doesn't need to be tracked and be in the root folder of the project.
Hence it would make sense to instruct chromatica where to find it, rather than it just looking in the root folder and up the directory structure.

neovim.api.nvim.NvimError: b'Invalid method name'

Commit 6d374fb introduced an incompatibility here that leads to the following backtrace:

We have clang 3.9.1, YCM works fine, and chromatica used to as well (although with very limited success).

error caught in async handler 'chromatica_highlight [{'position': [52, 2], 'filename': '/home/fiesh/wsmaster/wsgeo/src/d3/assembly.cpp', 'highlight_tick': 2, 'range': [1, 70], 'bufnr': 1, 'rpc': 'chromatica_highlight', 'changedtick'
: 3}]'                                                                                                                                                                                                                                  
Traceback (most recent call last):                                                                                                                                                                                                      
  File "/home/fiesh/.vim/plugged/chromatica.nvim/rplugin/python3/chromatica/__init__.py", line 33, in highlight                                                                                                                         
    self.__chromatica.highlight(context)                                                                                                                                                                                                
  File "/home/fiesh/.vim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 213, in highlight                                                                                                                      
    self._highlight(filename, lbegin, lend)                                                                                                                                                                                             
  File "/home/fiesh/.vim/plugged/chromatica.nvim/rplugin/python3/chromatica/chromatica.py", line 186, in _highlight                                                                                                                     
    retvals, errors = self.__vim.api.call_atomic(highlight_reqs)                                                                                                                                                                        
  File "/usr/lib64/python3.4/site-packages/neovim/api/nvim.py", line 129, in request                                                                                                                                                    
    res = self._session.request(name, *args, **kwargs)                                                                                                                                                                                  
  File "/usr/lib64/python3.4/site-packages/neovim/msgpack_rpc/session.py", line 98, in request                                                                                                                                          
    raise self.error_wrapper(err)                                                                                                                                                                                                       
neovim.api.nvim.NvimError: b'Invalid method name'  

Libclang does not find its include directory on Linux

On Linux (tested it on Debian buster), libclang does only search for system headers in the default system locations but not in clang's own include directory /usr/lib/llvm-6.0/lib/clang/6.0.0/include (the version depends on the installed clang package). This directory for example contains stddef.h, so chromatica currently cannot highlight common types like size_t. A simple workaround for this issue is adding clang's include directory to the global chromatica flags:

let g:chromatica#global_args = ['-isystem/usr/lib/llvm-6.0/lib/clang/6.0.0/include']

On macos, I did not experience such problems. Maybe Apple's libclang got some patches to read all include directories.

In my opinion, that is actually a libclang issue but users of chromatica should know about this (maybe a hint in the README file?). YouCompleteMe, which is also libclang based, brings its own copy of clang headers to avoid this issue. They have a very long issue about libclang search path problems.

There's no `--with-clang` option for installing LLVM

This is probably something that has changed since the library was released, but

brew install llvm --HEAD --with-clang

returns the following error

Warning: llvm: this formula has no --with-clang option so it will be ignored!

Is there any other way the dependencies should be setup instead?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.