diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-10-13 16:34:01 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-10-13 16:34:01 -0700 |
commit | a6868c444a444df4d7a3963c0f6bf693e4829131 (patch) | |
tree | 083396fad97e438a060f00a34785030a6f65dc0a | |
parent | 3fb78aa6158134497c17e5288a8ee9af64d1fac0 (diff) | |
download | mnpgr-a6868c444a444df4d7a3963c0f6bf693e4829131.tar.gz mnpgr-a6868c444a444df4d7a3963c0f6bf693e4829131.tar.bz2 mnpgr-a6868c444a444df4d7a3963c0f6bf693e4829131.zip |
New mnpgr.vim syntax file.
- Bugfix in mnpgr.tl: recognize bold + italic which is
encoded as the five char sequence _ BS <char> BS <char>.
- 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}.
-rwxr-xr-x | mnpgr.tl | 18 | ||||
-rw-r--r-- | mnpgr.vim | 16 |
2 files changed, 27 insertions, 7 deletions
@@ -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 <kaz@kylheku.com> + +" 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 |