From a6868c444a444df4d7a3963c0f6bf693e4829131 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 13 Oct 2023 16:34:01 -0700 Subject: New mnpgr.vim syntax file. - Bugfix in mnpgr.tl: recognize bold + italic which is encoded as the five char sequence _ BS BS . - Another bugfix: we must turn on the conceal level and set concealcursor. Setting the syntax alone won't do it. - Switch from Vim help syntax to mnpgr syntax, where bold is {B{...}B}, italic is {I{...}I} and bold italic is {C{...}C}. --- mnpgr.tl | 18 +++++++++++------- mnpgr.vim | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 mnpgr.vim diff --git a/mnpgr.tl b/mnpgr.tl index b43959c..e88eb15 100755 --- a/mnpgr.tl +++ b/mnpgr.tl @@ -5,7 +5,8 @@ (defvarl mnpgr-dir (path-cat home-dir ".mnpgr-dir")) (defvarl vim-commands - (join-with "|" '("set syntax=help" + (join-with "|" '("set syntax=mnpgr" + "set conceallevel=2 concealcursor=nc" "map q :q!\r"))) (defun make-overstrike-filter (put-string-fn) @@ -15,19 +16,22 @@ (when (neq mode cur-mode) [put-string-fn closer] (caseq (set cur-mode mode) - (:bold [put-string-fn "*"] - (set closer "*")) - (:ital [put-string-fn "|"] - (set closer "|")) + (:bold [put-string-fn "{B{"] + (set closer "}B}")) + (:ital [put-string-fn "{I{"] + (set closer "}I}")) + (:bital [put-string-fn "{C{"] + (set closer "}C}")) (:norm (set closer "")))) [put-string-fn str])) (lambda (line) - (each ((tok (tok #/.\b./ t line))) + (each ((tok (tok #/.\b.(\b.)?/ t line))) (match-case tok ("") (`@{x #/ +/}` (output-text x :norm)) - (`@x\b@x` (output-text x :bold)) + (`_\b@x\b@x` (output-text x :bital)) (`_\b@x` (output-text x :ital)) + (`@x\b@x` (output-text x :bold)) (@else (output-text else :norm)))) (output-text "\n" :norm))))) diff --git a/mnpgr.vim b/mnpgr.vim new file mode 100644 index 0000000..f024cea --- /dev/null +++ b/mnpgr.vim @@ -0,0 +1,16 @@ +" Syntax file for mnpgr +" Kaz Kylheku + +" INSTALL-HOWTO: +" +" 1. Create the directory .vim/syntax in your home directory and +" put the files mnpgr.vim into this directory. + +syn region mnpgr_bold start="{B{" end="}B}" contains=mnpgr_hidden keepend +syn region mnpgr_ital start="{I{" end="}I}" contains=mnpgr_hidden keepend +syn region mnpgr_bital start="{C{" end="}C}" contains=mnpgr_hidden keepend +syntax match mnpgr_hidden /{[BIC]{/ contained conceal +syntax match mnpgr_hidden /}[BIC]}/ contained conceal +hi def link mnpgr_bold Number +hi def link mnpgr_ital Identifier +hi def link mnpgr_bital Type -- cgit v1.2.3