mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
Update runtime files.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
" Vim indent file
|
||||
" Language: Java
|
||||
" Previous Maintainer: Toby Allsopp <toby.allsopp@peace.com>
|
||||
" Current Maintainer: Hong Xu <xuhdev@gmail.com>
|
||||
" Last Change: 2012 May 18
|
||||
" Version: 1.0
|
||||
" Current Maintainer: Hong Xu <hong@topbug.net>
|
||||
" Homepage: http://www.vim.org/scripts/script.php?script_id=3899
|
||||
" https://github.com/xuhdev/indent-java.vim
|
||||
" Last Change: 2016 Mar 7
|
||||
" Version: 1.1
|
||||
" License: Same as Vim.
|
||||
" Copyright (c) 2012 Hong Xu
|
||||
" Before 2012, this file is maintained by Toby Allsopp.
|
||||
" Copyright (c) 2012-2016 Hong Xu
|
||||
" Before 2012, this file was maintained by Toby Allsopp.
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
@@ -29,6 +31,7 @@ let b:undo_indent = "set cin< cino< indentkeys< indentexpr<"
|
||||
if exists("*GetJavaIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:keepcpo= &cpo
|
||||
set cpo&vim
|
||||
|
||||
@@ -70,7 +73,7 @@ function GetJavaIndent()
|
||||
|
||||
" If the previous line starts with '@', we should have the same indent as
|
||||
" the previous one
|
||||
if getline(lnum) =~ '^\s*@\S\+\s*$'
|
||||
if getline(lnum) =~ '^\s*@.*$'
|
||||
return indent(lnum)
|
||||
endif
|
||||
|
||||
@@ -85,9 +88,9 @@ function GetJavaIndent()
|
||||
|
||||
" Try to align "throws" lines for methods and "extends" and "implements" for
|
||||
" classes.
|
||||
if getline(v:lnum) =~ '^\s*\(extends\|implements\)\>'
|
||||
\ && getline(lnum) !~ '^\s*\(extends\|implements\)\>'
|
||||
let theIndent = theIndent + &sw
|
||||
if getline(v:lnum) =~ '^\s*\(throws\|extends\|implements\)\>'
|
||||
\ && getline(lnum) !~ '^\s*\(throws\|extends\|implements\)\>'
|
||||
let theIndent = theIndent + shiftwidth()
|
||||
endif
|
||||
|
||||
" correct for continuation lines of "throws", "implements" and "extends"
|
||||
@@ -96,27 +99,27 @@ function GetJavaIndent()
|
||||
if strlen(cont_kw) > 0
|
||||
let amount = strlen(cont_kw) + 1
|
||||
if getline(lnum) !~ ',\s*$'
|
||||
let theIndent = theIndent - (amount + &sw)
|
||||
let theIndent = theIndent - (amount + shiftwidth())
|
||||
if theIndent < 0
|
||||
let theIndent = 0
|
||||
endif
|
||||
elseif prev == lnum
|
||||
let theIndent = theIndent + amount
|
||||
if cont_kw ==# 'throws'
|
||||
let theIndent = theIndent + &sw
|
||||
let theIndent = theIndent + shiftwidth()
|
||||
endif
|
||||
endif
|
||||
elseif getline(prev) =~ '^\s*\(throws\|implements\|extends\)\>'
|
||||
\ && (getline(prev) =~ '{\s*$'
|
||||
\ || getline(v:lnum) =~ '^\s*{\s*$')
|
||||
let theIndent = theIndent - &sw
|
||||
let theIndent = theIndent - shiftwidth()
|
||||
endif
|
||||
|
||||
" When the line starts with a }, try aligning it with the matching {,
|
||||
" skipping over "throws", "extends" and "implements" clauses.
|
||||
if getline(v:lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$'
|
||||
call cursor(v:lnum, 1)
|
||||
silent normal %
|
||||
silent normal! %
|
||||
let lnum = line('.')
|
||||
if lnum < v:lnum
|
||||
while lnum > 1
|
||||
|
Reference in New Issue
Block a user