mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 15:14:04 +00:00
vim-patch:2750b83: runtime(java): Make the bundled &foldtext function optional
- Obtain and pass through translated messages with this
function.
- If "g:java_foldtext_show_first_or_second_line" is defined,
assign this function to &foldtext.
closes: vim/vim#15549
2750b83fa1
Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
This commit is contained in:
@@ -1663,6 +1663,14 @@ Note that these three variables are maintained in the HTML syntax file.
|
|||||||
Numbers and strings can be recognized in non-Javadoc comments with >
|
Numbers and strings can be recognized in non-Javadoc comments with >
|
||||||
:let g:java_comment_strings = 1
|
:let g:java_comment_strings = 1
|
||||||
|
|
||||||
|
When 'foldmethod' is set to "syntax", blocks of code and multi-line comments
|
||||||
|
will be folded. No text is usually written in the first line of a multi-line
|
||||||
|
comment, making folded contents of Javadoc comments less informative with the
|
||||||
|
default 'foldtext' value; you may opt for showing the contents of a second
|
||||||
|
line for any comments written in this way, and showing the contents of a first
|
||||||
|
line otherwise, with >
|
||||||
|
:let g:java_foldtext_show_first_or_second_line = 1
|
||||||
|
|
||||||
Trailing whitespace characters or a run of space characters before a tab
|
Trailing whitespace characters or a run of space characters before a tab
|
||||||
character can be marked as an error with >
|
character can be marked as an error with >
|
||||||
:let g:java_space_errors = 1
|
:let g:java_space_errors = 1
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
|
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
|
||||||
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
|
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
|
||||||
" Repository: https://github.com/zzzyxwvut/java-vim.git
|
" Repository: https://github.com/zzzyxwvut/java-vim.git
|
||||||
" Last Change: 2024 Jul 30
|
" Last Change: 2024 Aug 22
|
||||||
|
|
||||||
" 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.
|
||||||
|
|
||||||
@@ -39,17 +39,27 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! JavaSyntaxFoldTextExpr() abort
|
if exists("g:java_foldtext_show_first_or_second_line")
|
||||||
return getline(v:foldstart) !~ '/\*\+\s*$'
|
function! s:LazyPrefix(prefix, dashes, count) abort
|
||||||
\ ? foldtext()
|
return empty(a:prefix)
|
||||||
\ : printf('+-%s%3d lines: ',
|
\ ? printf('+-%s%3d lines: ', a:dashes, a:count)
|
||||||
\ v:folddashes,
|
\ : a:prefix
|
||||||
\ (v:foldend - v:foldstart + 1)) .
|
endfunction
|
||||||
\ getline(v:foldstart + 1)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" E120 for "fdt=s:JavaSyntaxFoldTextExpr()" before v8.2.3900.
|
function! JavaSyntaxFoldTextExpr() abort
|
||||||
setlocal foldtext=JavaSyntaxFoldTextExpr()
|
" Piggyback on NGETTEXT.
|
||||||
|
let summary = foldtext()
|
||||||
|
return getline(v:foldstart) !~ '/\*\+\s*$'
|
||||||
|
\ ? summary
|
||||||
|
\ : s:LazyPrefix(matchstr(summary, '^+-\+\s*\d\+\s.\{-1,}:\s'),
|
||||||
|
\ v:folddashes,
|
||||||
|
\ (v:foldend - v:foldstart + 1)) .
|
||||||
|
\ getline(v:foldstart + 1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" E120 for "fdt=s:JavaSyntaxFoldTextExpr()" before v8.2.3900.
|
||||||
|
setlocal foldtext=JavaSyntaxFoldTextExpr()
|
||||||
|
endif
|
||||||
|
|
||||||
" Admit the ASCII dollar sign to keyword characters (JLS-17, §3.8):
|
" Admit the ASCII dollar sign to keyword characters (JLS-17, §3.8):
|
||||||
try
|
try
|
||||||
@@ -624,15 +634,25 @@ if !has("vim9script")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
def! s:JavaSyntaxFoldTextExpr(): string
|
if exists("g:java_foldtext_show_first_or_second_line")
|
||||||
return getline(v:foldstart) !~ '/\*\+\s*$'
|
def! s:LazyPrefix(prefix: string, dashes: string, count: number): string
|
||||||
? foldtext()
|
return empty(prefix)
|
||||||
: printf('+-%s%3d lines: ',
|
? printf('+-%s%3d lines: ', dashes, count)
|
||||||
v:folddashes,
|
: prefix
|
||||||
(v:foldend - v:foldstart + 1)) ..
|
enddef
|
||||||
getline(v:foldstart + 1)
|
|
||||||
enddef
|
|
||||||
|
|
||||||
setlocal foldtext=s:JavaSyntaxFoldTextExpr()
|
def! s:JavaSyntaxFoldTextExpr(): string
|
||||||
delfunction! g:JavaSyntaxFoldTextExpr
|
# Piggyback on NGETTEXT.
|
||||||
|
const summary: string = foldtext()
|
||||||
|
return getline(v:foldstart) !~ '/\*\+\s*$'
|
||||||
|
? summary
|
||||||
|
: LazyPrefix(matchstr(summary, '^+-\+\s*\d\+\s.\{-1,}:\s'),
|
||||||
|
v:folddashes,
|
||||||
|
(v:foldend - v:foldstart + 1)) ..
|
||||||
|
getline(v:foldstart + 1)
|
||||||
|
enddef
|
||||||
|
|
||||||
|
setlocal foldtext=s:JavaSyntaxFoldTextExpr()
|
||||||
|
delfunction! g:JavaSyntaxFoldTextExpr
|
||||||
|
endif
|
||||||
" vim: sw=2 ts=8 noet sta
|
" vim: sw=2 ts=8 noet sta
|
||||||
|
|||||||
Reference in New Issue
Block a user