Update runtime files
This commit is contained in:
@ -3,13 +3,10 @@
|
||||
" Maintainer: Nick Jensen <nickspoon@gmail.com>
|
||||
" Former Maintainers: Aquila Deus
|
||||
" Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: 2018-11-21
|
||||
" Filenames: *.cs
|
||||
" Last Change: 2020-03-26
|
||||
" License: Vim (see :h license)
|
||||
" Repository: https://github.com/nickspoons/vim-cs
|
||||
"
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
@ -22,19 +19,23 @@ set cpoptions&vim
|
||||
setlocal indentexpr=GetCSIndent(v:lnum)
|
||||
|
||||
function! s:IsCompilerDirective(line)
|
||||
return a:line =~? '^\s*#'
|
||||
" Exclude #region and #endregion - these should be indented normally
|
||||
return a:line =~# '^\s*#' && !s:IsRegionDirective(a:line)
|
||||
endf
|
||||
|
||||
function! s:IsRegionDirective(line)
|
||||
return a:line =~# '^\s*#\s*region' || a:line =~# '^\s*#\s*endregion'
|
||||
endf
|
||||
|
||||
function! s:IsAttributeLine(line)
|
||||
return a:line =~? '^\s*\[[A-Za-z]' && a:line =~? '\]$'
|
||||
return a:line =~# '^\s*\[[A-Za-z]' && a:line =~# '\]$'
|
||||
endf
|
||||
|
||||
function! s:FindPreviousNonCompilerDirectiveLine(start_lnum)
|
||||
for delta in range(0, a:start_lnum)
|
||||
let lnum = a:start_lnum - delta
|
||||
let line = getline(lnum)
|
||||
let is_directive = s:IsCompilerDirective(line)
|
||||
if !is_directive
|
||||
if !s:IsCompilerDirective(line) && !s:IsRegionDirective(line)
|
||||
return lnum
|
||||
endif
|
||||
endfor
|
||||
@ -58,8 +59,9 @@ function! GetCSIndent(lnum) abort
|
||||
let lnum = s:FindPreviousNonCompilerDirectiveLine(a:lnum - 1)
|
||||
let previous_code_line = getline(lnum)
|
||||
if s:IsAttributeLine(previous_code_line)
|
||||
let ind = indent(lnum)
|
||||
return ind
|
||||
return indent(lnum)
|
||||
elseif s:IsRegionDirective(this_line)
|
||||
return cindent(lnum)
|
||||
else
|
||||
return cindent(a:lnum)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user