diff options
author | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-07-18 19:37:18 +0000 |
commit | 308e1940dcd64aa6c344c403d4f9e0dda58d9c5c (patch) | |
tree | 35fe43e01755e0f312650667004487a44d6b7941 /runtime/indent/cs.vim | |
parent | 96a00c7c588b2f38a2424aeeb4ea3581d370bf2d (diff) | |
parent | e8c94697bcbe23a5c7b07c292b90a6b70aadfa87 (diff) | |
download | rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.gz rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.bz2 rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.zip |
Merge remote-tracking branch 'upstream/master' into rahm
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 |