Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

Tokens not highlighted in code only including standard library #35

Open
ghost opened this issue Feb 28, 2017 · 6 comments
Open

Tokens not highlighted in code only including standard library #35

ghost opened this issue Feb 28, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Feb 28, 2017

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;
}
@arakashic
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Feb 28, 2017

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.

@theowen
Copy link

theowen commented Oct 6, 2017

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
Copy link

theowen commented Oct 7, 2017

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

@arakashic
Copy link
Owner

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

@yinflying
Copy link

yinflying commented Jan 4, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants