c_no_curly_error does not work on lambdas if filetype is not exactly 'cpp'
bmerry opened this issue ยท 8 comments
I often edit code with filetype set to 'cpp.doxygen', which gives C++ syntax highlighting for the code and doxygen highlighting on the comments. However, the lines
if exists("c_no_curly_error")
if &filetype ==# 'cpp' && !exists("cpp_no_cpp11")
do not match a filetype of cpp.doxygen, so lambda functions still have the {} marked as errors. If I change the filetype to cpp then they are no longer marked as errors.
Unfortunately I don't know enough about the vim scripting language to be able to suggest a fix.
This change was merged
What if the filetype is something like arduino
? I'm currently having an issue with the vim-polyglot arduino syntax where lambda brackets are marked as errors. Should the arduino
filetype be renamed cpp.arduino
to be compatible, or is there another way of doing this filetype check?
It would be nice to be able to set some global option that tells vim-cpp
that a file is explicitly a cpp
file as an override.
How about to setlocal filetype=cpp syntax=arduino
?
Hm, no-go. Just tried it, &ft
still ends up being 'arduino'
and thus isn't matched. I also tried set ft=cpp.arduino
and set ft=arduino.cpp
to no avail, both only use one of the syntaxes (cpp and arduino, respectively).
What problem with setlocal filetype=cpp syntax=arduino
?
It doesn't work. Still highlights the file as if it were just arduino
.
Do you set let c_no_curly_error=1
in your vimrc?
Ah okay, got it to work. I'm not actually sure why it wasn't working for me before, but setlocal filetype=cpp syntax=arduino
does work for me now. Thanks for the help!
If anyone else finds this thread, here's what I ended up putting in my vimrc:
" properly indent c++11 lambdas
autocmd FileType cpp setlocal cindent cino=j1,(0,ws,Ws
" force cpp filetype for arduino syntax
autocmd FileType arduino setlocal filetype=cpp syntax=arduino