diff options
author | inzuo Jiang <jiangyinzuo@foxmail.com> | 2024-06-10 21:13:56 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-06-10 21:13:56 +0200 |
commit | 2d88210b3c8516c30ed104054e5cdaef67880755 (patch) | |
tree | 7c4ec92947783e55234446356590b7184118ce9f /runtime/indent | |
parent | d03882baac712de586880775386f4c1e2cf6eade (diff) |
runtime(kdl): include syntax, indent and ftplugin files
closes: #14956
Co-authored-by: Aram Drevekenin <aram@poor.dev>
Signed-off-by: inzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/indent')
-rw-r--r-- | runtime/indent/kdl.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/runtime/indent/kdl.vim b/runtime/indent/kdl.vim new file mode 100644 index 0000000000..2d24f18dff --- /dev/null +++ b/runtime/indent/kdl.vim @@ -0,0 +1,26 @@ +" Vim indent file +" Language: KDL +" Author: Aram Drevekenin <aram@poor.dev> +" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> +" Last Change: 2024-06-10 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=KdlIndent() +let b:undo_indent = "setlocal indentexpr<" + +function! KdlIndent(...) + let line = getline(v:lnum) + let previousNum = prevnonblank(v:lnum - 1) + let previous = getline(previousNum) + + if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$" + return indent(previousNum) + &tabstop + else + return indent(previousNum) + endif +endfunction |