mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
vim-patch:60310a4: runtime(java): Manage circularity for every :syn-included syntax file
With "g:markdown_fenced_languages" defined and "java" added
to its list, a circular dependency between the Markdown and
Java syntax files will be made. To break it, no Markdown
documentation comments will be recognised in fenced blocks
in Markdown files; in order to view Java source files,
"java" must be removed from "g:markdown_fenced_languages",
and this task can be automated as follows.
1) Add to "~/.after/ftplugin/java.vim":
------------------------------------------------------------
if exists("g:markdown_fenced_languages") &&
\ !(exists("g:java_ignore_javadoc") ||
\ exists("g:java_ignore_markdown"))
let s:idx = index(g:markdown_fenced_languages, 'java')
if s:idx > -1
call remove(g:markdown_fenced_languages, s:idx)
endif
unlet s:idx
endif
------------------------------------------------------------
2) Optionally add to "~/.after/ftplugin/markdown.vim":
------------------------------------------------------------
if exists("g:markdown_fenced_languages") &&
\ index(g:markdown_fenced_languages, 'java') < 0
call add(g:markdown_fenced_languages, 'java')
endif
------------------------------------------------------------
(Make sure that the above snippets appear in the files under
the "ftplugin" NOT "syntax" directory.)
Finally, unless the new version of the syntax file is made
available from "$VIMRUNTIME" (and from "~/.vim/syntax" if
necessary), OTHER discoverable file versions will be used
whose behaviour may interfere with this fix.
related: vim/vim#15740
closes: vim/vim#15796
60310a4b26
Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
This commit is contained in:
parent
ab98c5b5a0
commit
988482d942
@ -3,16 +3,32 @@
|
||||
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
|
||||
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
|
||||
" Repository: https://github.com/zzzyxwvut/java-vim.git
|
||||
" Last Change: 2024 Sep 28
|
||||
" Last Change: 2024 Oct 03
|
||||
|
||||
" Please check :help java.vim for comments on some of the options available.
|
||||
" Please check ":help java.vim" for comments on some of the options
|
||||
" available.
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if !exists("g:main_syntax")
|
||||
if exists("b:current_syntax")
|
||||
" Do not aggregate syntax items from circular inclusion.
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists("g:main_syntax")
|
||||
" Reject attendant circularity for every :syn-included syntax file,
|
||||
" but ACCEPT FAILURE when "g:main_syntax" is set to "java".
|
||||
if g:main_syntax == 'html'
|
||||
if !exists("g:java_ignore_html")
|
||||
let g:java_ignore_html = 1
|
||||
let s:clear_java_ignore_html = 1
|
||||
endif
|
||||
" we define it here so that included files can test for it
|
||||
elseif g:main_syntax == 'markdown'
|
||||
if !exists("g:java_ignore_markdown")
|
||||
let g:java_ignore_markdown = 1
|
||||
let s:clear_java_ignore_markdown = 1
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" Allow syntax files that include this file test for its inclusion.
|
||||
let g:main_syntax = 'java'
|
||||
endif
|
||||
|
||||
@ -364,15 +380,17 @@ if !exists("g:java_ignore_javadoc") && (s:with_html || s:with_markdown) && g:mai
|
||||
|
||||
" Include HTML syntax coloring for Javadoc comments.
|
||||
if s:with_html
|
||||
try
|
||||
syntax include @javaHtml syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
finally
|
||||
unlet! b:current_syntax
|
||||
endtry
|
||||
endif
|
||||
|
||||
" Include Markdown syntax coloring (v7.2.437) for Javadoc comments.
|
||||
if s:with_markdown
|
||||
try
|
||||
syntax include @javaMarkdown syntax/markdown.vim
|
||||
unlet b:current_syntax
|
||||
let s:ff.WithMarkdown = s:ff.LeftConstant
|
||||
catch /\<E48[45]:/
|
||||
call s:ReportOnce(v:exception)
|
||||
@ -383,6 +401,8 @@ if !exists("g:java_ignore_javadoc") && (s:with_html || s:with_markdown) && g:mai
|
||||
hi clear markdownCodeBlock
|
||||
hi clear markdownCodeDelimiter
|
||||
hi clear markdownLinkDelimiter
|
||||
finally
|
||||
unlet! b:current_syntax
|
||||
endtry
|
||||
endif
|
||||
|
||||
@ -839,6 +859,14 @@ if g:main_syntax == 'java'
|
||||
unlet g:main_syntax
|
||||
endif
|
||||
|
||||
if exists("s:clear_java_ignore_html")
|
||||
unlet! s:clear_java_ignore_html g:java_ignore_html
|
||||
endif
|
||||
|
||||
if exists("s:clear_java_ignore_markdown")
|
||||
unlet! s:clear_java_ignore_markdown g:java_ignore_markdown
|
||||
endif
|
||||
|
||||
let b:spell_options = "contained"
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save s:ff s:with_html s:with_markdown
|
||||
|
Loading…
Reference in New Issue
Block a user