vim-pandoc / vim-pandoc-syntax

pandoc markdown syntax, to be installed alongside vim-pandoc
MIT License
425 stars 61 forks source link

highlight new lines more cautiously #292

Closed Konfekt closed 5 years ago

Konfekt commented 5 years ago

do not highlight indentation and only after non-white space characters

fmoralesc commented 5 years ago

Looks good, thanks! Can you give an example where the current rules are bad? (I haven't seen it, so I'm just curious.)

Konfekt commented 5 years ago

If, for example, one indents a line because it belongs to the same item in a list, such as

1. This
    belongs to the first item
2. This to the second one.

then the indentation in the second line is initially marked red.

fmoralesc commented 5 years ago

Gotcha.

dmoerner commented 5 years ago

This commit produced a regression for me, I get the following error when opening any markdown file with vim 8.0.1453. (This is an older version of vim, but it's used in Ubuntu LTS 18.04, for example):

Error detected while processing function <SNR>57_WithConceal:
line    7:
E871: (NFA regexp) Can't have a multi follow a multi !
E62: Nested \@
E475: Invalid argument: pandocNewLine /\( \{4,4}\@<=  \|\S\@<=  \|\\\)$/ display
 containedin=pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocStrongInEmph
asis,pandocEmphasisInStrong conceal cchar=↵
fmoralesc commented 5 years ago

@dmoerner Can you try changing the code to

" New_lines: {{{3
if g:pandoc#syntax#newlines == 1
  try " temporary fix for older vim versions
      call s:WithConceal("newline", 'syn match pandocNewLine /\( \{4,4}\@<=  \|\S\@<=  \|\\\)$/ display containedin=pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocStrongInEmphasis,pandocEmphasisInStrong', 'conceal cchar='.s:cchars["newline"])
  catch /E871/
      call s:WithConceal("newline", 'syn match pandocNewLine /\(  \|\\\)$/ display containedin=pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocStrongInEmphasis,pandocEmphasisInStrong', 'conceal cchar='.s:cchars["newline"])
  endtry
endif
" }}}3
dmoerner commented 5 years ago

Thank you, that works for me. Thank you for accommodating older versions.

Konfekt commented 5 years ago

I am working on a fix.

fmoralesc commented 5 years ago

@dmoerner, let's wait for @Konfekt's fix ;)

Konfekt commented 5 years ago

Since a line that contains only white spaces and at least two of them does not give additional line breaks after compilation by pandoc, I resorted to highlighting only double white space after a non-white space character.

Konfekt commented 5 years ago

Dear @dmoerner , the error was due to my oversight that \@<= must be followed by a group \(...\). Mea culpa. This should be fixed.