aboutsummaryrefslogtreecommitdiffhomepage
path: root/.vim/my/indent
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2020-09-08 06:14:51 +0900
committernsfisis <nsfisis@gmail.com>2020-09-08 06:14:51 +0900
commitd2732d24689189f02d1b3680b5c560a678321564 (patch)
tree40a474a7efa3a3642e9f679fd0d98eac979bb044 /.vim/my/indent
parent7574b72a50cf2f4658e7695afd3367fec028f5e1 (diff)
downloaddotfiles-d2732d24689189f02d1b3680b5c560a678321564.tar.gz
dotfiles-d2732d24689189f02d1b3680b5c560a678321564.tar.zst
dotfiles-d2732d24689189f02d1b3680b5c560a678321564.zip
Add .vim
Diffstat (limited to '.vim/my/indent')
-rw-r--r--.vim/my/indent/todolist.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/.vim/my/indent/todolist.vim b/.vim/my/indent/todolist.vim
new file mode 100644
index 0000000..0640a93
--- /dev/null
+++ b/.vim/my/indent/todolist.vim
@@ -0,0 +1,32 @@
+if exists('b:did_indent')
+ finish
+endif
+
+
+setlocal indentexpr=TodolistIndent()
+
+
+function! TodolistIndent()
+ if v:lnum == 0
+ return 0
+ endif
+
+ let line = getline(v:lnum - 1)
+ if s:starts_with_checkbox(line)
+ return indent(v:lnum - 1)
+ else
+ return 0
+ endif
+endfunction
+
+
+function! s:starts_with_checkbox(line)
+ if a:line =~# '^\s*\[[ x]\]'
+ return 1
+ else
+ return 0
+ endif
+endfunction
+
+
+let b:did_indent = 1