Closed mananaBanana closed 6 years ago
The highlight group cppStructure
is set in Vim's default cpp syntax file. You can find it under $VIMRUNTIME/syntax/cpp.vim
, or on github.
Run :scriptnames
to see what files were sourced on startup. If that file isn't sourced, you don't get any default c++ syntax highlighting.
If I run :scriptnames
, I can see both /usr/share/vim/vim80/syntax/cpp.vim
and ~/.vim/bundle/syntax/after/syntax/cpp.vim
being loaded. But I think first file is loaded after the latter (I'm assuming :scriptnames
lists in the order in which the files are loaded.) Can that be the reason behind the error?
1: ~/.vimrc
2: /usr/share/vim/vim80/filetype.vim
3: /usr/share/vim/vim80/ftplugin.vim
...
34: /usr/share/vim/vim80/indent/cpp.vim
35: ~/.vim/bundle/syntax/after/syntax/cpp.vim
36: /usr/share/vim/vim80/syntax/cpp.vim
37: ~/.vim/bundle/syntax/after/syntax/c.vim
38: /usr/share/vim/vim80/syntax/c.vim
The problem indeed comes from the fact that your vim80/syntax/c*.vim
files are loaded after.
To resolve this, I simply did the following:
$> cd ~/.vim/bundle/
$> git clone https://github.com/octol/vim-cpp-enhanced-highlight.git
I removed the ~/.vim/syntax/
folder and followed what @MrBananane said, but the error still comes up. :scriptnames
now reads:
37: /usr/share/vim/vim80/indent/cpp.vim
38: ~/.vim/bundle/vim-cpp-enhanced-highlight/after/syntax/cpp.vim
39: /usr/share/vim/vim80/syntax/cpp.vim
40: ~/.vim/bundle/vim-cpp-enhanced-highlight/after/syntax/c.vim
41: /usr/share/vim/vim80/syntax/c.vim
Fixed this by setting the order of directories in runtimepath
in my .vimrc
file. I had appended /usr/share/vim/vim80
directory after upgrading to vim 8.0 and messed up the order.
Original:
set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after,/usr/share/vim/vim80,
Fixed:
set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
I had this same error and learned that $VIMRUNTIME/syntax/cpp.vim
was missing along with most other syntax files.
I solved this problem by installing vim-data
.
On a fresh install (using pathogen), I get an error whenever I open a
.cpp
file.The error goes away on commenting line 61.
But if I do that none of the additional features, like member highlighting, work. I have had a look at Issue #26 and #53 but the solutions listed there don't seem to help.