Update runtime files
This commit is contained in:
@ -1,19 +1,78 @@
|
||||
" Vim indent file
|
||||
" Language: nginx.conf
|
||||
" Maintainer: Chris Aumann <me@chr4.org>
|
||||
" Last Change: 2022 Apr 06
|
||||
" Last Change: 2022 Dec 01
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=
|
||||
setlocal indentexpr=GetNginxIndent()
|
||||
|
||||
" cindent actually works for nginx' simple file structure
|
||||
setlocal cindent
|
||||
setlocal indentkeys=0{,0},0#,!^F,o,O
|
||||
|
||||
" Just make sure that the comments are not reset as defs would be.
|
||||
setlocal cinkeys-=0#
|
||||
let b:undo_indent = 'setl inde< indk<'
|
||||
|
||||
let b:undo_indent = "setl inde< cin< cink<"
|
||||
" Only define the function once.
|
||||
if exists('*GetNginxIndent')
|
||||
finish
|
||||
endif
|
||||
|
||||
function GetNginxIndent() abort
|
||||
let plnum = s:PrevNotAsBlank(v:lnum - 1)
|
||||
|
||||
" Hit the start of the file, use zero indent.
|
||||
if plnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(plnum)
|
||||
|
||||
" Add a 'shiftwidth' after '{'
|
||||
if s:AsEndWith(getline(plnum), '{')
|
||||
let ind = ind + shiftwidth()
|
||||
end
|
||||
|
||||
" Subtract a 'shiftwidth' on '}'
|
||||
" This is the part that requires 'indentkeys'.
|
||||
if getline(v:lnum) =~ '^\s*}'
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
|
||||
let pplnum = s:PrevNotAsBlank(plnum - 1)
|
||||
|
||||
if s:IsLineContinuation(plnum)
|
||||
if !s:IsLineContinuation(pplnum)
|
||||
let ind = ind + shiftwidth()
|
||||
end
|
||||
else
|
||||
if s:IsLineContinuation(pplnum)
|
||||
let ind = ind - shiftwidth()
|
||||
end
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
" Find the first line at or above {lnum} that is non-blank and not a comment.
|
||||
function s:PrevNotAsBlank(lnum) abort
|
||||
let lnum = prevnonblank(a:lnum)
|
||||
while lnum > 0
|
||||
if getline(lnum) !~ '^\s*#'
|
||||
break
|
||||
endif
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
endwhile
|
||||
return lnum
|
||||
endfunction
|
||||
|
||||
" Check whether {line} ends with {pat}, ignoring trailing comments.
|
||||
function s:AsEndWith(line, pat) abort
|
||||
return a:line =~ a:pat . '\m\s*\%(#.*\)\?$'
|
||||
endfunction
|
||||
|
||||
function s:IsLineContinuation(lnum) abort
|
||||
return a:lnum > 0 && !s:AsEndWith(getline(a:lnum), '[;{}]')
|
||||
endfunction
|
||||
|
||||
134
runtime/indent/testdir/vb.in
Normal file
134
runtime/indent/testdir/vb.in
Normal file
@ -0,0 +1,134 @@
|
||||
' vim: filetype=vb shiftwidth=4 expandtab
|
||||
'
|
||||
' START_INDENT
|
||||
Public Type GEmployeeRecord ' Create user-defined type.
|
||||
ID As Integer ' Define elements of data type.
|
||||
Name As String * 20
|
||||
Address As String * 30
|
||||
Phone As Long
|
||||
HireDate As Date
|
||||
End Type
|
||||
|
||||
Public Enum InterfaceColors
|
||||
icMistyRose = &HE1E4FF&
|
||||
icSlateGray = &H908070&
|
||||
icDodgerBlue = &HFF901E&
|
||||
icDeepSkyBlue = &HFFBF00&
|
||||
icSpringGreen = &H7FFF00&
|
||||
icForestGreen = &H228B22&
|
||||
icGoldenrod = &H20A5DA&
|
||||
icFirebrick = &H2222B2&
|
||||
End Enum
|
||||
|
||||
Enum SecurityLevel
|
||||
IllegalEntry = -1
|
||||
SecurityLevel1 = 0
|
||||
SecurityLevel2 = 1
|
||||
End Enum
|
||||
|
||||
Public Function TestConditional (number As Integer, ext As String) As Boolean
|
||||
Dim inRange As Boolean
|
||||
|
||||
Select Case number
|
||||
Case <= 0
|
||||
inRange = False
|
||||
Case > 10
|
||||
inRange = False
|
||||
Case Else
|
||||
inRange = True
|
||||
End Select
|
||||
|
||||
' This is a special case identified in the indent script.
|
||||
Select Case number
|
||||
End Select
|
||||
|
||||
If ext = ".xlm" Then
|
||||
If inRange Then
|
||||
TestConditional = True
|
||||
Else
|
||||
TestConditional = False
|
||||
End If
|
||||
ElseIf ext = ".xlsx" Then
|
||||
If inRange Then
|
||||
TestConditional = False
|
||||
Else
|
||||
TestConditional = True
|
||||
End If
|
||||
Else
|
||||
TestConditional = False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub TestIterators (lLimit As Integer, uLimit As Integer)
|
||||
Dim a() As Variant
|
||||
Dim elmt As Variant
|
||||
Dim found As Boolean
|
||||
Dim indx As Integer
|
||||
Const specialValue As Integer = 5
|
||||
|
||||
If uLimit < lLimit Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ReDim a(lLimit To uLimit)
|
||||
For indx=lLimit To Ulimit
|
||||
a(indx) = 2 * indx
|
||||
Next indx
|
||||
|
||||
found = False
|
||||
For Each elmt in a
|
||||
If elmt = specialValue Then
|
||||
found = True
|
||||
End If
|
||||
Next elmt
|
||||
|
||||
If found then
|
||||
indx = uLimit
|
||||
Do While indx >= lLimit
|
||||
indx = indx - 1
|
||||
Loop
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub TestMultiline (cellAddr As String, rowNbr As Long)
|
||||
Dim rng As Range
|
||||
|
||||
Set rng = Range(cellAddr)
|
||||
With rng
|
||||
.Cells(1,1).Value = _
|
||||
"Line 1 of multiline string; " & _
|
||||
"Line 2 of multiline string; " & _
|
||||
"Line 3 of multiline string"
|
||||
End With
|
||||
|
||||
' The following lines have whitespace after the underscore character
|
||||
' and therefore do not form a valid multiline statement. The indent
|
||||
' script correctly treats them as four single line statements contrary
|
||||
' to the author's obvious indent.
|
||||
rng..Cells(1,1).Value = _
|
||||
"Line 1 of multiline string; " & _
|
||||
"Line 2 of multiline string; " & _
|
||||
"Line 3 of multiline string"
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub TestStmtLabel()
|
||||
GoTo stmtLabel
|
||||
|
||||
' Statement labels are never indented
|
||||
stmtLabel:
|
||||
|
||||
End Sub
|
||||
|
||||
Sub TestTypeKeyword()
|
||||
Type EmployeeRecord ' Create user-defined type.
|
||||
ID As Integer ' Define elements of data type.
|
||||
Name As String * 20
|
||||
Address As String * 30
|
||||
Phone As Long
|
||||
HireDate As Date
|
||||
End Type
|
||||
Dim varType As EmployeeRecord
|
||||
End Sub
|
||||
' END_INDENT
|
||||
134
runtime/indent/testdir/vb.ok
Normal file
134
runtime/indent/testdir/vb.ok
Normal file
@ -0,0 +1,134 @@
|
||||
' vim: filetype=vb shiftwidth=4 expandtab
|
||||
'
|
||||
' START_INDENT
|
||||
Public Type GEmployeeRecord ' Create user-defined type.
|
||||
ID As Integer ' Define elements of data type.
|
||||
Name As String * 20
|
||||
Address As String * 30
|
||||
Phone As Long
|
||||
HireDate As Date
|
||||
End Type
|
||||
|
||||
Public Enum InterfaceColors
|
||||
icMistyRose = &HE1E4FF&
|
||||
icSlateGray = &H908070&
|
||||
icDodgerBlue = &HFF901E&
|
||||
icDeepSkyBlue = &HFFBF00&
|
||||
icSpringGreen = &H7FFF00&
|
||||
icForestGreen = &H228B22&
|
||||
icGoldenrod = &H20A5DA&
|
||||
icFirebrick = &H2222B2&
|
||||
End Enum
|
||||
|
||||
Enum SecurityLevel
|
||||
IllegalEntry = -1
|
||||
SecurityLevel1 = 0
|
||||
SecurityLevel2 = 1
|
||||
End Enum
|
||||
|
||||
Public Function TestConditional (number As Integer, ext As String) As Boolean
|
||||
Dim inRange As Boolean
|
||||
|
||||
Select Case number
|
||||
Case <= 0
|
||||
inRange = False
|
||||
Case > 10
|
||||
inRange = False
|
||||
Case Else
|
||||
inRange = True
|
||||
End Select
|
||||
|
||||
' This is a special case identified in the indent script.
|
||||
Select Case number
|
||||
End Select
|
||||
|
||||
If ext = ".xlm" Then
|
||||
If inRange Then
|
||||
TestConditional = True
|
||||
Else
|
||||
TestConditional = False
|
||||
End If
|
||||
ElseIf ext = ".xlsx" Then
|
||||
If inRange Then
|
||||
TestConditional = False
|
||||
Else
|
||||
TestConditional = True
|
||||
End If
|
||||
Else
|
||||
TestConditional = False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub TestIterators (lLimit As Integer, uLimit As Integer)
|
||||
Dim a() As Variant
|
||||
Dim elmt As Variant
|
||||
Dim found As Boolean
|
||||
Dim indx As Integer
|
||||
Const specialValue As Integer = 5
|
||||
|
||||
If uLimit < lLimit Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ReDim a(lLimit To uLimit)
|
||||
For indx=lLimit To Ulimit
|
||||
a(indx) = 2 * indx
|
||||
Next indx
|
||||
|
||||
found = False
|
||||
For Each elmt in a
|
||||
If elmt = specialValue Then
|
||||
found = True
|
||||
End If
|
||||
Next elmt
|
||||
|
||||
If found then
|
||||
indx = uLimit
|
||||
Do While indx >= lLimit
|
||||
indx = indx - 1
|
||||
Loop
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub TestMultiline (cellAddr As String, rowNbr As Long)
|
||||
Dim rng As Range
|
||||
|
||||
Set rng = Range(cellAddr)
|
||||
With rng
|
||||
.Cells(1,1).Value = _
|
||||
"Line 1 of multiline string; " & _
|
||||
"Line 2 of multiline string; " & _
|
||||
"Line 3 of multiline string"
|
||||
End With
|
||||
|
||||
' The following lines have whitespace after the underscore character
|
||||
' and therefore do not form a valid multiline statement. The indent
|
||||
' script correctly treats them as four single line statements contrary
|
||||
' to the author's obvious indent.
|
||||
rng..Cells(1,1).Value = _
|
||||
"Line 1 of multiline string; " & _
|
||||
"Line 2 of multiline string; " & _
|
||||
"Line 3 of multiline string"
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub TestStmtLabel()
|
||||
GoTo stmtLabel
|
||||
|
||||
' Statement labels are never indented
|
||||
stmtLabel:
|
||||
|
||||
End Sub
|
||||
|
||||
Sub TestTypeKeyword()
|
||||
Type EmployeeRecord ' Create user-defined type.
|
||||
ID As Integer ' Define elements of data type.
|
||||
Name As String * 20
|
||||
Address As String * 30
|
||||
Phone As Long
|
||||
HireDate As Date
|
||||
End Type
|
||||
Dim varType As EmployeeRecord
|
||||
End Sub
|
||||
' END_INDENT
|
||||
@ -1,8 +1,12 @@
|
||||
" Vim indent file
|
||||
" Language: VisualBasic (ft=vb) / Basic (ft=basic) / SaxBasic (ft=vb)
|
||||
" Author: Johannes Zellner <johannes@zellner.org>
|
||||
" Maintainer: Michael Soyka (mssr953@gmail.com)
|
||||
" Last Change: Fri, 18 Jun 2004 07:22:42 CEST
|
||||
" Small update 2010 Jul 28 by Maxim Kim
|
||||
" 2022/12/15: add support for multiline statements.
|
||||
" 2022/12/21: move VbGetIndent from global to script-local scope
|
||||
" 2022/12/26: recognize "Type" keyword
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
@ -10,28 +14,33 @@ endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=VbGetIndent(v:lnum)
|
||||
setlocal indentexpr=s:VbGetIndent(v:lnum)
|
||||
setlocal indentkeys&
|
||||
setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,=~loop,<:>
|
||||
setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,=~loop
|
||||
|
||||
let b:undo_indent = "set ai< indentexpr< indentkeys<"
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*VbGetIndent")
|
||||
if exists("*s:VbGetIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
fun! VbGetIndent(lnum)
|
||||
function s:VbGetIndent(lnum)
|
||||
let this_lnum = a:lnum
|
||||
let this_line = getline(this_lnum)
|
||||
|
||||
" labels and preprocessor get zero indent immediately
|
||||
let this_line = getline(a:lnum)
|
||||
let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)'
|
||||
if this_line =~? LABELS_OR_PREPROC
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Get the current value of "shiftwidth"
|
||||
let bShiftwidth = shiftwidth()
|
||||
|
||||
" Find a non-blank line above the current line.
|
||||
" Skip over labels and preprocessor directives.
|
||||
let lnum = a:lnum
|
||||
let lnum = this_lnum
|
||||
while lnum > 0
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
let previous_line = getline(lnum)
|
||||
@ -45,34 +54,102 @@ fun! VbGetIndent(lnum)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(lnum)
|
||||
" Variable "previous_line" now contains the text in buffer line "lnum".
|
||||
|
||||
" Multi-line statements have the underscore character at end-of-line:
|
||||
"
|
||||
" object.method(arguments, _
|
||||
" arguments, _
|
||||
" arguments)
|
||||
"
|
||||
" and require extra logic to determine the correct indentation.
|
||||
"
|
||||
" Case 1: Line "lnum" is the first line of a multiline statement.
|
||||
" Line "lnum" will have a trailing underscore character
|
||||
" but the preceding non-blank line does not.
|
||||
" Line "this_lnum" will be indented relative to "lnum".
|
||||
"
|
||||
" Case 2: Line "lnum" is the last line of a multiline statement.
|
||||
" Line "lnum" will not have a trailing underscore character
|
||||
" but the preceding non-blank line will.
|
||||
" Line "this_lnum" will have the same indentation as the starting
|
||||
" line of the multiline statement.
|
||||
"
|
||||
" Case 3: Line "lnum" is neither the first nor last line.
|
||||
" Lines "lnum" and "lnum-1" will have a trailing underscore
|
||||
" character.
|
||||
" Line "this_lnum" will have the same indentation as the preceding
|
||||
" line.
|
||||
"
|
||||
" No matter which case it is, the starting line of the statement must be
|
||||
" found. It will be assumed that multiline statements cannot have
|
||||
" intermingled comments, statement labels, preprocessor directives or
|
||||
" blank lines.
|
||||
"
|
||||
let lnum_is_continued = (previous_line =~ '_$')
|
||||
if lnum > 1
|
||||
let before_lnum = prevnonblank(lnum-1)
|
||||
let before_previous_line = getline(before_lnum)
|
||||
else
|
||||
let before_lnum = 0
|
||||
let before_previous_line = ""
|
||||
endif
|
||||
|
||||
if before_previous_line !~ '_$'
|
||||
" Variable "previous_line" contains the start of a statement.
|
||||
"
|
||||
let ind = indent(lnum)
|
||||
if lnum_is_continued
|
||||
let ind += bShiftwidth
|
||||
endif
|
||||
elseif ! lnum_is_continued
|
||||
" Line "lnum" contains the last line of a multiline statement.
|
||||
" Need to find where this multiline statement begins
|
||||
"
|
||||
while before_lnum > 0
|
||||
let before_lnum -= 1
|
||||
if getline(before_lnum) !~ '_$'
|
||||
let before_lnum += 1
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if before_lnum == 0
|
||||
let before_lnum = 1
|
||||
endif
|
||||
let previous_line = getline(before_lnum)
|
||||
let ind = indent(before_lnum)
|
||||
else
|
||||
" Line "lnum" is not the first or last line of a multiline statement.
|
||||
"
|
||||
let ind = indent(lnum)
|
||||
endif
|
||||
|
||||
" Add
|
||||
if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\|else\|elseif\|do\|for\|while\|enum\|with\)\>'
|
||||
let ind = ind + shiftwidth()
|
||||
if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\|enum\|type\)\|select\|case\|default\|if\|else\|elseif\|do\|for\|while\|with\)\>'
|
||||
let ind = ind + bShiftwidth
|
||||
endif
|
||||
|
||||
" Subtract
|
||||
if this_line =~? '^\s*\<end\>\s\+\<select\>'
|
||||
if previous_line !~? '^\s*\<select\>'
|
||||
let ind = ind - 2 * shiftwidth()
|
||||
let ind = ind - 2 * bShiftwidth
|
||||
else
|
||||
" this case is for an empty 'select' -- 'end select'
|
||||
" (w/o any case statements) like:
|
||||
"
|
||||
" select case readwrite
|
||||
" end select
|
||||
let ind = ind - shiftwidth()
|
||||
let ind = ind - bShiftwidth
|
||||
endif
|
||||
elseif this_line =~? '^\s*\<\(end\|else\|elseif\|until\|loop\|next\|wend\)\>'
|
||||
let ind = ind - shiftwidth()
|
||||
let ind = ind - bShiftwidth
|
||||
elseif this_line =~? '^\s*\<\(case\|default\)\>'
|
||||
if previous_line !~? '^\s*\<select\>'
|
||||
let ind = ind - shiftwidth()
|
||||
let ind = ind - bShiftwidth
|
||||
endif
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfun
|
||||
endfunction
|
||||
|
||||
" vim:sw=4
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
" Vim indent file placeholder
|
||||
" Language: Vue
|
||||
" Maintainer: None, please volunteer if you have a real Vue indent script
|
||||
" Last Change: 2022 Dec 24
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
" don't set b:did_indent, otherwise html indenting won't be activated
|
||||
" let b:did_indent = 1
|
||||
|
||||
" Html comes closest
|
||||
runtime! indent/html.vim
|
||||
|
||||
Reference in New Issue
Block a user