habamax / vim-asciidoctor

Asciidoctor plugin for Vim
MIT License
182 stars 16 forks source link

Comments are in code blocks #92

Closed rickalex21 closed 3 years ago

rickalex21 commented 3 years ago

The comments are in code blocks. AFAIK comments are this.

I fixed the comments with this.

syn region asciidocCommentBlock start=+^/\{4,}$+ end=+^/\{4,}$+

I didn't want to rename all my files to asciidoctor so I did this. Not sure why 'asciidoctor' is the default? Then I have to rename all my syntax files/files.

autocmd BufNewFile,BufRead *.adoc,*.asciidoc set ft=asciidoc

Here is the patch:

diff --git a/ftdetect/asciidoctor.vim b/ftdetect/asciidoctor.vim
index 32afa43..c05d5e0 100644
--- a/ftdetect/asciidoctor.vim
+++ b/ftdetect/asciidoctor.vim
@@ -1 +1 @@
-autocmd BufNewFile,BufRead *.adoc,*.asciidoc set ft=asciidoctor
+autocmd BufNewFile,BufRead *.adoc,*.asciidoc set ft=asciidoc
diff --git a/syntax/asciidoctor.vim b/syntax/asciidoctor.vim
index 6840107..379f70e 100644
--- a/syntax/asciidoctor.vim
+++ b/syntax/asciidoctor.vim
@@ -167,7 +167,7 @@ syn region asciidoctorOpenBlock matchgroup=asciidoctorBlock start="^--\s*$" end=
 " block that will not be
 " highlighted
 " ----
-syn region asciidoctorListingBlock matchgroup=asciidoctorBlock start="^----\+\s*$" end="^----\s*$"
+syn region asciidoctorListingBlock matchgroup=asciidoctorBlock start=+^/\{4,}$+ end=+^/\{4,}$+

 " General [source] block
 syn region asciidoctorSourceBlock matchgroup=asciidoctorBlock start="^\[source\%(,.*\)*\]\s*$" end="^\s*$" keepend

I'm not sure how to add langauges to the code block? The docs indicate this:

 let g:asciidoctor_fenced_languages = ['python', 'c', 'javascript']

I took care of it with my own function.

execute 'syntax region asciidocListingBlock  start=/^-\{4,}$/ end=/^-\{4,}$/  keepend contains=asciidocCallout,asciidocToDo'.join(map(copy(languages),{_,val->',@'.val.'Lang'}))

I haven't tried all the other features. I was mostly intrested in trying out the syntax. Other than that everything else looks good so far, thanks.

habamax commented 3 years ago

Not sure what is this issue about, to be honest.

With this patch you actually use built-in asciidoc filetype and for that you don't even need to install this one in the first place.

Then you change listing block with comment block, again I don't know why -- you don't use this syntax of asciidoctor and even if you have used it -- comment block and listing blocks are just different things.

rickalex21 commented 3 years ago

There was a conflicting plugin that I later discovered. It was commenting out my code blocks. Nothing is wrong with your plugin. You can delete this issue.

Thanks