.dotfiles/global/.config/nvim/after/syntax/jrnl.vim

33 lines
1 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" setlocal syntax=markdown
setlocal textwidth=80
setlocal spell
syntax match jtag "@.\{-}\w\+"
syntax match jyear /\[\d\{4}-\d\d-\d\d \d\d:\d\d:\d\{2\}\( [aApP][mM]\)\?\]/
syntax region entryLine start=/\d\{4}-\d\d-\d\d \d\d:\d\d/ end=/$/ contains=jyear
highlight def link jtag Constant
highlight def link jyear Identifier
highlight def entryLine ctermfg=250 guifg=Gray
setlocal foldmethod=expr
setlocal foldexpr=JrnlFoldExpr()
function! JrnlFoldExpr()
let line = getline(v:lnum)
" Если строка начинается с даты [YYYY-MM-DD HH:MM:SS AM/PM]
if line =~ '^\[\d\{4}-\d\d-\d\d \d\d:\d\d:\d\{2\}\( [aApP][mM]\)\?\]'
return ">1" " Открываем новую свёртку (уровень 1)
endif
" Если строка - это Weather, Geo, или другие элементы
if line =~ '^-\s\+\w\+:'
return "1" " Оставляем эти строки внутри текущей свёртки
endif
" Все остальные строки не участвуют в свёртке
return "="
endfunction