From 2b8232332cdcf24edc08ab0a9fa8e1dc614f95f7 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 3 Nov 2020 10:06:23 -0500 Subject: [PATCH] add gemtext highlighting --- vim/.vim/ftdetect/gemtext.vim | 4 ++++ vim/.vim/syntax/gemtext.vim | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 vim/.vim/ftdetect/gemtext.vim create mode 100644 vim/.vim/syntax/gemtext.vim diff --git a/vim/.vim/ftdetect/gemtext.vim b/vim/.vim/ftdetect/gemtext.vim new file mode 100644 index 0000000..d47d324 --- /dev/null +++ b/vim/.vim/ftdetect/gemtext.vim @@ -0,0 +1,4 @@ +" Vim file type detection for Gemtext markup + +au BufRead,BufNewFile *.gmi set filetype=gemtext +au BufRead,BufNewFile *.gemini set filetype=gemtext diff --git a/vim/.vim/syntax/gemtext.vim b/vim/.vim/syntax/gemtext.vim new file mode 100644 index 0000000..0dbc3f3 --- /dev/null +++ b/vim/.vim/syntax/gemtext.vim @@ -0,0 +1,40 @@ +" Vim syntax file for Gemtext markup +" as described by section 5 of the Gemini Specification +" https://gemini.circumlunar.space/docs/specification.html + +if exists("b:current_syntax") + finish +endif + +syntax sync fromstart + +syntax match gemtextLinkOperator '\v^\=\>' nextgroup=gemtextLinkURL skipwhite +syntax match gemtextLinkURL '\v\S+' contained nextgroup=gemtextLinkText skipwhite +syntax match gemtextLinkText '\v\S.*$' contained + +syntax match gemtextHeadingOperator '\v^\##?#?' nextgroup=gemtextHeadingText skipwhite +syntax match gemtextHeadingText '\v\s*\S.*$' contained +syntax match gemtextNotAHeadingOperator '\v^\####' + +syntax match gemtextUnorderedListItemOperator '\v^\*\s' + +syntax match gemtextQuoteOperator '\v^\>' nextgroup=gemtextQuoteText skipwhite +syntax match gemtextQuoteText '\v.*$' contained + +syntax region gemtextPreformatBlock start="\v^```.*$" end="\v^```" keepend + +let b:current_syntax = "gemtext" + +hi def link gemtextLinkOperator Operator +hi def link gemtextLinkURL Underlined +hi def link gemtextLinkText String + +hi def link gemtextHeadingOperator Operator +hi def link gemtextHeadingText Identifier + +hi def link gemtextUnorderedListItemOperator Operator + +hi def link gemtextQuoteOperator Operator +hi def link gemtextQuoteText String + +hi def link gemtextPreformatBlock PreProc