diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-06-09 20:45:54 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-06-09 20:45:54 +0100 |
commit | 63f32603789d1a27c559fc440325955fd0b8b500 (patch) | |
tree | 4704249d1618c6e126e41c6889c29d353f39e59c /runtime/indent/cs.vim | |
parent | 2813f38e021c6e6581c0c88fcf107e41788bc835 (diff) |
Update runtime files
Diffstat (limited to 'runtime/indent/cs.vim')
-rw-r--r-- | runtime/indent/cs.vim | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/runtime/indent/cs.vim b/runtime/indent/cs.vim index 76c12efecf..acc3ba75d5 100644 --- a/runtime/indent/cs.vim +++ b/runtime/indent/cs.vim @@ -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 |