lervag / wiki-ft.vim

Simple Vim filetype plugin for wiki-files
MIT License
14 stars 5 forks source link

Incorrect code highlighting when two seperate code blocks have C-like function definitions #1

Closed meyamay closed 4 years ago

meyamay commented 4 years ago
```c
() {}
```
```c
() {}
```

In the above, each { will be highlighted red (the same highlight vim uses to convey a missing ending bracket). This works with actual function definitions too, i.e. void main() {} and with C++ code highlighting.

This behavior is not present with only one code block:

```c
() {}
```

It is also fine if multiple definitions are contained in exactly one code block.

I'm fairly sure the bug is confined to this highlighting plugin, as I am unable to reproduce the behavior using vimwiki's code block highlighting.

lervag commented 4 years ago

I've tested with a minimal example:

test.vim file:

set nocompatible

" You should of course make sure the following paths are correct on your
" system. That is, `~/.vim/bundle` should be replaced with whereever you put
" your plugins.
let &rtp = '~/.vim/bundle/wiki-ft.vim,' . &rtp
let &rtp = '~/.vim/bundle/wiki.vim,' . &rtp
let &rtp .= ',~/.vim/bundle/wiki.vim/after'
let &rtp .= ',~/.vim/bundle/wiki-ft.vim/after'

filetype plugin indent on
syntax enable

test.wiki file:

```c
void main() {}
void main() {}


When I open with `nvim -u test.vim test.wiki`, it seems to work as expected.
meyamay commented 4 years ago

You're right, my bad. The culprit is vim-polyglot. Seems like it doesn't play nice with the nested highlighting.

meyamay commented 4 years ago

For anyone else who may stumble upon this issue, the following variable fixes said conflict: let g:cpp_no_function_highlight = 1

lervag commented 4 years ago

Ah, great, and thanks for the hint.