diff options
author | Yinzuo Jiang <jiangyinzuo@foxmail.com> | 2024-06-16 14:47:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-16 08:47:47 +0200 |
commit | 79da22de755e28bd8d4f58fc4bf34cf94f45de63 (patch) | |
tree | ecd0d173bb37741725cfa5842daf9584121d3c54 /runtime/indent/kdl.vim | |
parent | acc87469415ba10283e5a53a8a11424f4867bbcf (diff) |
runtime(kdl): fix KdlIndent and kdlComment in indent script (#15019)
Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/indent/kdl.vim')
-rw-r--r-- | runtime/indent/kdl.vim | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim index b1b004d0a2..b0a6bd90d9 100644 --- a/runtime/indent/kdl.vim +++ b/runtime/indent/kdl.vim @@ -2,7 +2,7 @@ " Language: KDL " Author: Aram Drevekenin <aram@poor.dev> " Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> -" Last Change: 2024-06-11 +" Last Change: 2024-06-16 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -14,13 +14,17 @@ setlocal indentexpr=KdlIndent() let b:undo_indent = "setlocal indentexpr<" function! KdlIndent(...) - let line = getline(v:lnum) + let line = substitute(getline(v:lnum), '//.*$', '', '') let previousNum = prevnonblank(v:lnum - 1) - let previous = getline(previousNum) + let previous = substitute(getline(previousNum), '//.*$', '', '') - if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$" - return indent(previousNum) + shiftwidth() - else - return indent(previousNum) + let l:indent = indent(previousNum) + if previous =~ "{" && previous !~ "}" + let l:indent += shiftwidth() endif + if line =~ "}" && line !~ "{" + let l:indent -= shiftwidth() + endif + return l:indent endfunction +" vim: sw=2 sts=2 et |