diff runtime/indent/java.vim @ 11160:d0a20101ecb2

Update runtime files. commit https://github.com/vim/vim/commit/036986f1507d223549d110af300144468bd3a1f7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 16 17:41:02 2017 +0100 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Thu, 16 Mar 2017 17:45:05 +0100
parents dd6c2497c997
children
line wrap: on
line diff
--- a/runtime/indent/java.vim
+++ b/runtime/indent/java.vim
@@ -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< inde
 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