From 4899585281beab51e5dff1d9ae4d3159244a8275 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 9 Jun 2021 21:37:56 +0200 Subject: Add org mode, close #706 --- autoload/org.vim | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 autoload/org.vim (limited to 'autoload/org.vim') diff --git a/autoload/org.vim b/autoload/org.vim new file mode 100644 index 00000000..de8282c2 --- /dev/null +++ b/autoload/org.vim @@ -0,0 +1,30 @@ +if polyglot#init#is_disabled(expand(':p'), 'org', 'autoload/org.vim') + finish +endif + +" Helper functions for org.vim +" +" Maintainer: Alex Vear +" License: Vim (see `:help license`) +" Location: autoload/org.vim +" Website: https://github.com/axvr/org.vim +" Last Change: 2020-01-04 + +" Fallback chain for options. Buffer local --> Global --> default. +function org#option(name, default) abort + return get(b:, a:name, get(g:, a:name, a:default)) +endfunction + +" Emacs-like fold text. +function org#fold_text() abort + return getline(v:foldstart) . '...' +endfunction + +" Check fold depth of a line. +function org#fold_expr() + let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=') + if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') =~# '\m^o\(rg\|utline\)Heading' + return ">" . l:depth + endif + return "=" +endfunction -- cgit v1.2.3