chromatica.nvim icon indicating copy to clipboard operation
chromatica.nvim copied to clipboard

Tokens not highlighted in code only including standard library

Open ghost opened this issue 7 years ago • 6 comments

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;
}

ghost avatar Feb 28 '17 20:02 ghost

Thanks for submitting this. Can you also attach the chromatica settings in your vimrc? That would be helpful to reproduce the problem.

arakashic avatar Feb 28 '17 20:02 arakashic

This is my entire init.vim. I use vim-plug for plugin management.

set cindent 
set tabstop=4
set shiftwidth=4
set ruler
set number
set showcmd
set formatoptions+=ro
set showmode

call plug#begin('~/.local/share/nvim/plugged')

Plug 'arakashic/chromatica.nvim'

call plug#end()

let g:chromatica#enable_at_startup=1

I think I found a way to reproduce it. Launch nvim (don't open a file). Then :set syntax=cpp. Write the code I wrote above but without the for loops. Save the file with :w filename.cpp. Then add both for loops. On my systemprintfand scanf aren't highlighted. They aren't highlighted even after saving the file and reopening it in a new terminal and nvim. I think it has to do something with caching if there is any.

ghost avatar Feb 28 '17 20:02 ghost

I could reproduce this with the following code:

#include <string>

 int main()
 {
     std::string x;

     x.push_back('a');
 }

push_back should be highlighted, but it isn't.

theowen avatar Oct 06 '17 05:10 theowen

In fact, if I produce preprocessed code i.e. g++ test.cpp -E > prep.cpp, everything is processed correctly.

theowen avatar Oct 07 '17 01:10 theowen

@theowen Thanks for reporting. I will take a look at it.

arakashic avatar Oct 07 '17 16:10 arakashic

Same problem here, Manjaro linux, All standard library function can't highlight as expected. (I have added such compile flags:

Compile Flags: -std=c++14 -isystem/usr/include/c++/8.2.1/ -isystem/usr/lib/clang/7.0.1/include

Edit: after I change the flag to:

Compile Flags: -std=c++14 -isystem/usr/lib/clang/7.0.1/include

it works fine. However, It seems that I can not add gcc include header.

yinflying avatar Jan 04 '19 02:01 yinflying