From d671e862e4442f8559c5462c19566a427c27bb41 Mon Sep 17 00:00:00 2001 From: Alex Vear Date: Sat, 15 Feb 2020 02:12:12 +0000 Subject: [PATCH] Syntax highlight and correctly format/manipulate lists Adds support for syntax highlighting and formatting both ordered and unordered lists (excluding unordered lists delimited with `*`, as they conflict with headings and are generally not recommended). e.g. 1. Foo 2. Bar 1) Biz 2) Baz - Foo - Bar + Biz + Baz --- TODO | 2 +- ftplugin/org.vim | 3 +++ syntax/org.vim | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 6aa780f..f759d27 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ MAYBE: - Better link syntax highlighting (more similar to links in vim-markdown) - - Syntax highlight bullets and checkboxes + - Syntax highlight checkboxes and checkbox cookies - Different syntax group for heading delimiters UNLIKELY: diff --git a/ftplugin/org.vim b/ftplugin/org.vim index 8a3ad16..3140224 100644 --- a/ftplugin/org.vim +++ b/ftplugin/org.vim @@ -11,6 +11,9 @@ " Web: setlocal commentstring=#%s +setlocal comments=fb:*,fb:-,fb:+,b:#,b:\: +setlocal formatoptions+=ncqlt +let &l:formatlistpat = '^\s*\(\d\+[.)]\|[+-]\)\s\+' setlocal foldexpr=org#fold_expr() setlocal foldmethod=expr diff --git a/syntax/org.vim b/syntax/org.vim index b1a3e00..a189816 100644 --- a/syntax/org.vim +++ b/syntax/org.vim @@ -85,6 +85,13 @@ highlight def link orgTodo Todo highlight def link orgTag Type +" Lists +syntax match orgUnorderedListMarker "^\s*[-+]\s\+" keepend contains=@Spell +syntax match orgOrderedListMarker "^\s*\d\+[.)]\s\+" keepend contains=@Spell +highlight def link orgUnorderedListMarker Statement +highlight def link orgOrderedListMarker orgUnorderedListMarker + + " Timestamps syntax match orgTimestampActive /<\d\{4}-\d\{2}-\d\{2}.\{-}>/ keepend syntax match orgTimestampInactive /\[\d\{4}-\d\{2}-\d\{2}.\{-}\]/ keepend