├── README.md ├── autoload ├── tiddlywiki.vim └── tiddlywiki │ └── completion.vim ├── ftdetect └── tiddlywiki.vim ├── ftplugin └── tiddlywiki.vim ├── plugin └── tiddlywiki.vim └── syntax └── tiddlywiki.vim /README.md: -------------------------------------------------------------------------------- 1 | This is a fork of http://www.vim.org/scripts/script.php?script_id=2705 2 | 3 | For people who like the TiddlyWiki formatting syntax. 4 | 5 | http://tiddlywiki.org/wiki/TiddlyWiki_Markup 6 | 7 | It has since been highly customized and updated. 8 | 9 | This plugin provides syntax highlighting for tiddlywiki files (`*.tid`) as well 10 | as some helpers for editing TiddlyWiki files. It is probably best used in 11 | conjunction with [TiddlyWiki Bob](https://github.com/OokTech/TW5-Bob), since it 12 | is designed to smoothly handle tiddlers being changed both via TiddlyWiki as 13 | well as directly on the file system. 14 | 15 | 16 | # Usage 17 | 18 | 19 | ## Provided Commands 20 | 21 | * `TiddlyWikiUpdateMetadata` : Update the 'modifier' and 'modified' fields in the current tiddler's metadata. 22 | * `TiddlyWikiInitializeTemplate` : Insert tiddler metadata (timestamps, creator / modifier / title) at the top of the file 23 | * `TiddlyWikiEditTiddler ` : Open the tiddler with that name (without '.tid' extension) or create it if it doesn't exist. 24 | * `TiddlyWikiEditJournal` : Open the journal tiddler for today or create it if it doesn't exist 25 | * `TiddlyWikiOpenLink` : Open the link under the cursor 26 | * `TiddlyWikiInsertLink ` : Insert a link to the given tiddler at the cursor position. 27 | 28 | The `...Edit...` and `...InsertLink` commands look for tiddlers in the following locations (in that order): 29 | * If `g:tiddlywiki_dir` is set: 30 | * `g:tiddlywiki_dir/` 31 | * `g:tiddlywiki_dir/tiddlers/` 32 | * Otherwise: 33 | * `./` 34 | * `./tiddlers/` 35 | * `~/wiki/` 36 | * `~/wiki/tiddlers/` 37 | 38 | The `TiddlyWikiEditTiddler` and `TiddlyWikiInsertLink` commands have completion for the tiddler name. 39 | In addition, if you call them without arguments and have [fzf](https://github.com/junegunn/fzf) 40 | installed, you will get extra fancy completion. 41 | 42 | 43 | ## Completion 44 | 45 | The plugin contains a first user completion function that can be invoked in 46 | insert mode via ``. It can complete WikiWords and bracket `[[Links]]` 47 | (as long as both leading brackets are there). It is still rather rudimentary, 48 | but should still make things a lot easier. 49 | 50 | 51 | ## Default Mappings 52 | 53 | ``` 54 | nmap tm :TiddlyWikiUpdateMetadata 55 | nmap tt :TiddlyWikiInitializeTemplate 56 | nmap te :TiddlyWikiEditTiddler 57 | nmap tE :vsplit:TiddlyWikiEditTiddler 58 | nmap tj :TiddlyWikiEditJournal 59 | nmap tJ :vsplit:TiddlyWikiEditJournal 60 | nmap to :TiddlyWikiOpenLink 61 | nmap tl :TiddlyWikiInsertLink 62 | ``` 63 | 64 | 65 | ## Configuration 66 | 67 | ``` 68 | " Explicitly set the username of the tiddler 'creator' and 'modifier' 69 | " If not set, this defaults to `$USER` or `$LOGNAME` (in that order) 70 | let g:tiddlywiki_author = 'thisisme' 71 | 72 | " Specify the location of your tiddlers. The subdir "tiddlers" is appended 73 | " automatically if required. 74 | let g:tiddlywiki_dir = '~/docs/notes/wiki' 75 | 76 | " Set the date format to use for journal tiddlers, as in the format string of date(1). 77 | " This does not have to be at 'day' granularity - you can also use 78 | " months / weeks / hours / whatever makes sense to you. 79 | " Defaults to '%F' (ISO date = yyyy-mm-dd) 80 | let g:tiddlywiki_journal_format = '%A, %F (Week %V)' 81 | 82 | " Disable the default mappings 83 | let g:tiddlywiki_no_mappings=1 84 | 85 | " Automatically update tiddler metadata ('modified' timestamp, 'modifier' 86 | " username) on write 87 | let g:tiddlywiki_autoupdate=1 88 | ``` 89 | 90 | -------------------------------------------------------------------------------- /autoload/tiddlywiki.vim: -------------------------------------------------------------------------------- 1 | " check if the given dir contains at least one system tiddler 2 | function! s:HasSystemTiddlers(dir) 3 | return len(globpath(a:dir, '*.tid', 1, 1)) > 0 4 | endfunction 5 | 6 | " Determine the dir containing all tiddlers 7 | function! tiddlywiki#TiddlyWikiDir() 8 | if exists("s:tiddlywiki_dir") 9 | if s:tiddlywiki_dir == '' 10 | echom 'ERROR: tiddler dir could not be determined' 11 | endif 12 | return s:tiddlywiki_dir 13 | endif 14 | 15 | let candidates = [] 16 | 17 | if exists("g:tiddlywiki_dir") 18 | let candidates = [g:tiddlywiki_dir, g:tiddlywiki_dir . '/tiddlers'] 19 | else 20 | let candidates = ['.', './tiddlers', '~/wiki', '~/wiki/tiddlers'] 21 | endif 22 | 23 | for candidate in candidates 24 | let abs = fnamemodify(candidate, ':p') 25 | if(s:HasSystemTiddlers(abs)) 26 | silent echom "Tiddler dir = <" abs ">" 27 | let s:tiddlywiki_dir = abs 28 | return abs 29 | endif 30 | endfor 31 | 32 | echom 'ERROR: tiddler dir could not be determined' 33 | return '' 34 | endfunction 35 | 36 | 37 | " Get the name for the journal tiddler for right now 38 | function! tiddlywiki#GetJournalTiddlerName() 39 | if exists('g:tiddlywiki_journal_format') 40 | let fmt = g:tiddlywiki_journal_format 41 | else 42 | let fmt = '%F' 43 | endif 44 | 45 | return trim(system("date +'" . fmt . "'")) 46 | endfunction 47 | 48 | 49 | " Completion func for tiddler names 50 | function! tiddlywiki#CompleteTiddlerName(ArgLead, CmdLine, CursorPos) 51 | let dir = tiddlywiki#TiddlyWikiDir() 52 | let fqns = globpath(dir, a:ArgLead . '*.tid', 1, 1) 53 | let files = map(fqns, 'strpart(v:val, strridx(v:val, "/") +1)') 54 | return map(files, 'strpart(v:val, 0, strridx(v:val, "."))') 55 | endfunction 56 | 57 | 58 | function! tiddlywiki#FuzzyFindTiddler(sink) 59 | if exists('*fzf#run') 60 | call fzf#run({ 61 | \ 'source': tiddlywiki#CompleteTiddlerName('', '', 0), 62 | \ 'sink': a:sink, 63 | \ 'down': '40%' 64 | \ }) 65 | else 66 | echom "no tiddler name given and no fzf available for fancy completion" 67 | endif 68 | endfunction 69 | 70 | 71 | " Main completefunc body 72 | function! tiddlywiki#UserCompletionFunc(findstart, base) 73 | return tiddlywiki#completion#UserFunc(a:findstart, a:base) 74 | endfunction 75 | -------------------------------------------------------------------------------- /autoload/tiddlywiki/completion.vim: -------------------------------------------------------------------------------- 1 | 2 | " Main completefunc body 3 | function! tiddlywiki#completion#UserFunc(findstart, base) 4 | if a:findstart 5 | return tiddlywiki#completion#FindStart() 6 | else 7 | return tiddlywiki#completion#ListCandidates(a:base) 8 | endif 9 | endfunction 10 | 11 | 12 | function! tiddlywiki#completion#FindStart() 13 | let line = getline('.') 14 | let start = col('.') - 1 15 | 16 | while (start > 0) && 17 | \ ((line[start - 1] =~ '\a') || (line[start - 1] == '[')) && 18 | \ (strpart(line, start, 2) != '[[') 19 | let start -= 1 20 | endwhile 21 | 22 | if strpart(line, start, 2) == '[[' 23 | echom "FindStart: found <" . strpart(line, start, (col('.') - start)) . ">" 24 | return start 25 | elseif match(line[start], '\v[A-Z]') == 0 26 | echom "FindStart: found <" . strpart(line, start, (col('.') - start)) . ">" 27 | return start 28 | else 29 | echom "FindStart: NOTfound <" . strpart(line, start, (col('.') - start)) . ">" 30 | return -3 31 | endif 32 | endfunction 33 | 34 | 35 | function! tiddlywiki#completion#ListCandidates(base) 36 | if strpart(a:base, 0, 2) == '[[' 37 | let baseStr = strpart(a:base, 2) 38 | let withBrackets = 1 39 | else 40 | let baseStr = a:base 41 | let withBrackets = 0 42 | endif 43 | 44 | echom "baseStr = <" . baseStr . ">, withBrackets=" . withBrackets 45 | let candidates = tiddlywiki#completion#FindTiddlers(baseStr, !withBrackets) 46 | echom "candidates = " 47 | echom candidates 48 | let words = [] 49 | 50 | for candidate in candidates 51 | let replacement = candidate 52 | if withBrackets 53 | let replacement = '[[' . candidate . ']]' 54 | endif 55 | 56 | call add(words, {'abbr': candidate, 'word': replacement }) 57 | endfor 58 | 59 | echom "words = " 60 | echom words 61 | return words 62 | endfunction 63 | 64 | 65 | " Completion func for tiddler names 66 | function! tiddlywiki#completion#FindTiddlers(prefix, wordsOnly) 67 | let dir = tiddlywiki#TiddlyWikiDir() 68 | let fqns = globpath(dir, a:prefix . '*.tid', 1, 1) 69 | let files = map(fqns, 'strpart(v:val, strridx(v:val, "/") +1)') 70 | let names = map(files, 'strpart(v:val, 0, strridx(v:val, "."))') 71 | 72 | echom "wordsOnly= " . a:wordsOnly . ", names = " 73 | echom names 74 | if a:wordsOnly 75 | echom "filtering" 76 | call filter(names, 'v:val =~# ' ."'" . '\v^(\u(\l|\d)+)+$' . "'") 77 | return names 78 | else 79 | return names 80 | endif 81 | endfunction 82 | -------------------------------------------------------------------------------- /ftdetect/tiddlywiki.vim: -------------------------------------------------------------------------------- 1 | " Vim file detect for TiddlyWiki 2 | " Language: tiddlywiki 3 | " Maintainer: Devin Weaver 4 | " License: http://www.apache.org/licenses/LICENSE-2.0.txt 5 | 6 | autocmd BufNewFile,BufRead *.tid setf tiddlywiki 7 | -------------------------------------------------------------------------------- /ftplugin/tiddlywiki.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin for TiddlyWiki 2 | " Language: tiddlywiki 3 | " Maintainer: Devin Weaver 4 | " License: http://www.apache.org/licenses/LICENSE-2.0.txt 5 | 6 | " Only do this when not done yet for this buffer 7 | if exists("b:did_ftplugin") 8 | finish 9 | endif 10 | let b:did_ftplugin = 1 11 | 12 | let s:save_cpo = &cpo 13 | set cpo-=C 14 | 15 | 16 | 17 | function! TiddlyWikiTime() 18 | let l:ts = system("date -u +'%Y%m%d%H%M%S'")[:-2] . "000" 19 | " on windows/powershell 'date' returns its result as UTF-16 and vim doesn't 20 | " automatically recognize it => we have to strip the "garbage" 21 | return substitute(l:ts, '\v[^0-9]', '', 'g') 22 | endfunction 23 | 24 | " Get the username to use as 'creator' and/or 'modifier' 25 | " Uses the 'g:tiddlywiki_author' variable if present or the system username 26 | " otherwise 27 | function! s:TiddlyWikiUser() 28 | if exists('g:tiddlywiki_author') 29 | return g:tiddlywiki_author 30 | elseif $USER !=# '' 31 | " Fall back to OS username 32 | return $USER 33 | else 34 | " Contains the username in termux/android (among other systems probably) 35 | return $LOGNAME 36 | endif 37 | endfunction 38 | 39 | function! s:AutoUpdateModifiedTime() 40 | if &modified 41 | call UpdateHeaders([]) 42 | endif 43 | endfunction 44 | 45 | function! s:SetHeader(key, value, replace) 46 | let save_cursor = getcurpos() 47 | normal! gg0 48 | 49 | let key_pattern = '\v^' . a:key . ': ' 50 | let replacement = a:key . ': ' . a:value 51 | if search(key_pattern, 'c', 7) 52 | if a:replace 53 | silent execute 's/' . key_pattern . '.*/' . replacement . "/" 54 | endif 55 | else 56 | call append(0, replacement) 57 | endif 58 | 59 | call setpos('.', save_cursor) 60 | endfunction 61 | 62 | function! s:InitializeTemplate(tags) 63 | call s:UpdateHeaders(a:tags) 64 | 65 | if line('$') <= 8 66 | call append(7, "") 67 | endif 68 | 69 | normal! G 70 | endfunction 71 | 72 | function! s:UpdateHeaders(tags) 73 | let save_cursor = getcurpos() 74 | let timestamp = TiddlyWikiTime() 75 | 76 | call s:SetHeader('created', timestamp, 0) 77 | call s:SetHeader('creator', s:TiddlyWikiUser(), 0) 78 | call s:SetHeader('modified', timestamp, 1) 79 | call s:SetHeader('modifier', s:TiddlyWikiUser(), 1) 80 | " Title defaults to filename without extension 81 | call s:SetHeader('title', expand('%:t:r'), 0) 82 | call s:SetHeader('tags', join(a:tags, ' '), 0) 83 | call s:SetHeader('type', 'text/vnd.tiddlywiki', 0) 84 | 85 | silent execute "1,7sort" 86 | "silent execute "normal! \" 87 | call setpos('.', save_cursor) 88 | endfunction 89 | 90 | 91 | " Get the [[link]] / WikiLink under the cursor or an empty string if there 92 | " isn't any. Uses the syntax definitions. 93 | function! s:GetLink() 94 | let cline = line('.') 95 | let ccol = col('.') 96 | let synid = synID(cline, ccol, 0) 97 | let synname = synIDattr(synid, "name") 98 | 99 | " if the cursor is not on a link, return empty string 100 | if (synname !=# 'twLink') && (synname !=# 'twCamelCaseLink') 101 | return '' 102 | endif 103 | 104 | " scan backward and forward in the line to find the link boundaries 105 | let startcol = ccol 106 | let endcol = ccol 107 | 108 | let c = ccol 109 | while synID(cline, c, 0) == synid 110 | let startcol = c 111 | let c = c - 1 112 | endwhile 113 | 114 | let c = ccol 115 | while synID(cline, c, 0) == synid 116 | let endcol = c 117 | let c = c + 1 118 | endwhile 119 | 120 | " extract the link token 121 | let linkstr = strpart(getline('.'), startcol - 1, (endcol - startcol) + 1) 122 | 123 | " ... and the link itself 124 | if synname == 'twLink' 125 | return strpart(linkstr, 2, strlen(linkstr) - 4) 126 | else 127 | return linkstr 128 | endif 129 | endfunction 130 | 131 | 132 | 133 | 134 | " Get the [[link]] / WikiLink under the cursor and open it 135 | function s:OpenLinkUnderCursor() 136 | let link = s:GetLink() 137 | 138 | if link == '' 139 | return "echom 'Cursor is not on a link'" 140 | else 141 | return 'TiddlyWikiEditTiddler ' . link 142 | endif 143 | endfunction 144 | 145 | 146 | " Insert a link to the tiddler with the given name. 147 | function! s:InsertLink(name) 148 | let tiddler_dir = tiddlywiki#TiddlyWikiDir() 149 | if tiddler_dir == '' 150 | return 151 | endif 152 | 153 | if a:name == '' 154 | call tiddlywiki#FuzzyFindTiddler(function('s:InsertLink')) 155 | return 156 | endif 157 | 158 | let line = getline('.') 159 | let pos = col('.')-1 160 | let fqn = '[[' . a:name . ']]' 161 | let line = line[:pos-1] . fqn . line[pos:] 162 | call setline('.', line) 163 | call setpos('.', [0, line('.'), pos + strlen(fqn) + 1, 0]) 164 | endfunction 165 | 166 | 167 | 168 | if exists("g:tiddlywiki_autoupdate") 169 | augroup tiddlywiki 170 | au BufWrite, *.tid call AutoUpdateModifiedTime() 171 | augroup END 172 | endif 173 | 174 | 175 | 176 | 177 | 178 | " Define commands, allowing the user to define custom mappings 179 | command! -nargs=0 TiddlyWikiUpdateMetadata call UpdateHeaders([]) 180 | command! -nargs=0 TiddlyWikiInitializeTemplate call InitializeTemplate([]) 181 | command! -nargs=0 TiddlyWikiInitializeJournal call InitializeTemplate(['Journal']) 182 | command! -nargs=0 TiddlyWikiOpenLink execute OpenLinkUnderCursor() 183 | command! -complete=customlist,tiddlywiki#CompleteTiddlerName 184 | \ -nargs=? TiddlyWikiInsertLink call InsertLink('') 185 | 186 | " Define some default mappings unless disabled 187 | if !exists("g:tiddlywiki_no_mappings") 188 | nmap tm :TiddlyWikiUpdateMetadata 189 | nmap tt :TiddlyWikiInitializeTemplate 190 | nmap to :TiddlyWikiOpenLink 191 | nmap tl :TiddlyWikiInsertLink 192 | endif 193 | 194 | 195 | setlocal completefunc=tiddlywiki#UserCompletionFunc 196 | 197 | let &cpo = s:save_cpo 198 | -------------------------------------------------------------------------------- /plugin/tiddlywiki.vim: -------------------------------------------------------------------------------- 1 | " Vim plugin for TiddlyWiki 2 | " Language: tiddlywiki 3 | " Maintainer: Devin Weaver 4 | " Maintainer: Christian Reiniger 5 | " License: http://www.apache.org/licenses/LICENSE-2.0.txt 6 | 7 | 8 | " Open the tiddler with the given name. If it doesn't exist, create and 9 | " initialize it 10 | function! s:EditOrCreate(name) 11 | let tiddler_dir = tiddlywiki#TiddlyWikiDir() 12 | if tiddler_dir == '' 13 | return 14 | endif 15 | 16 | if a:name == '' 17 | call tiddlywiki#FuzzyFindTiddler('TiddlyWikiEditTiddler') 18 | return 19 | endif 20 | 21 | let fqn = tiddler_dir . a:name . '.tid' 22 | execute 'edit ' . fqn 23 | 24 | if ! filereadable(expand(fqn)) 25 | TiddlyWikiInitializeTemplate 26 | endif 27 | endfunction 28 | 29 | 30 | " Open the journal tiddler for today. If it doesn't exist, create and 31 | " initialize it 32 | function! s:EditOrCreateJournal() 33 | if tiddlywiki#TiddlyWikiDir() == '' 34 | return 35 | endif 36 | 37 | let name = tiddlywiki#GetJournalTiddlerName() 38 | let fqn = tiddlywiki#TiddlyWikiDir() . name . '.tid' 39 | execute 'edit ' . fqn 40 | 41 | if ! filereadable(fqn) 42 | TiddlyWikiInitializeJournal 43 | endif 44 | endfunction 45 | 46 | 47 | 48 | 49 | " Define commands, allowing the user to define custom mappings 50 | command! -complete=customlist,tiddlywiki#CompleteTiddlerName 51 | \ -nargs=? TiddlyWikiEditTiddler call EditOrCreate('') 52 | command! -nargs=0 TiddlyWikiEditJournal call EditOrCreateJournal() 53 | 54 | " Define some default mappings unless disabled 55 | if !exists("g:tiddlywiki_no_mappings") 56 | nmap te :TiddlyWikiEditTiddler 57 | nmap tE :vsplit:TiddlyWikiEditTiddler 58 | nmap tj :TiddlyWikiEditJournal 59 | nmap tJ :vsplit:TiddlyWikiEditJournal 60 | endif 61 | 62 | 63 | -------------------------------------------------------------------------------- /syntax/tiddlywiki.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file for TiddlyWiki 2 | " Language: tiddlywiki 3 | " Last Change: 2009-07-06 Mon 10:15 PM IST 4 | " Maintainer: Devin Weaver 5 | " License: http://www.apache.org/licenses/LICENSE-2.0.txt 6 | " Reference: http://tiddlywiki.org/wiki/TiddlyWiki_Markup 7 | 8 | 9 | """ Initial checks 10 | " To be compatible with Vim 5.8. See `:help 44.12` 11 | if version < 600 12 | syntax clear 13 | elseif exists("b:current_syntax") 14 | " Quit when a (custom) syntax file was already loaded 15 | finish 16 | endif 17 | 18 | setlocal isident+=- 19 | 20 | """ Patterns 21 | syn spell toplevel 22 | 23 | " Rules 24 | syn match twRulesPragma /^\s*\\rules.*$/ contains=twRulesIntent,twRulesValue 25 | syn keyword twRulesIntent except only contained 26 | syn keyword twRulesValue macrodef bold codeinline commentinline dash contained 27 | syn keyword twRulesValue entity extlink filteredtranscludeinline contained 28 | syn keyword twRulesValue hardlinebreaks html image italic macrocallinline contained 29 | syn keyword twRulesValue prettyextlink prettylink strikethrough styleinline contained 30 | syn keyword twRulesValue subscript superscript syslink transcludeinline contained 31 | syn keyword twRulesValue underscore wikilink codeblock commentblock contained 32 | syn keyword twRulesValue filteredtranscludeblock heading horizrule html list contained 33 | syn keyword twRulesValue macrocallblock quoteblock styleblock table contained 34 | syn keyword twRulesValue transcludeblock typedblock contained 35 | 36 | " Macros 37 | syn region twMacro start=/<<\i\+/ end=/>>/ contains=twStringTriple,twStringDouble,twStringSingle 38 | syn match twMacroDefineStart /^\s*\\define\s\+\i\+(\i*)/ contains=twMacroDefineName 39 | syn match twMacroDefineName /\i\+(\i*)/ contained contains=twMacroDefineArg 40 | syn region twMacroDefineArg start=/(/ms=s+1 end=/)/me=e-1 contained 41 | syn match twMacroDefineEnd /^\s*\\end/ 42 | syn match twVariable /\$(\=\i\+)\=\$/ 43 | 44 | " Header Fields 45 | syn match twFieldsLine /^\i\+:\s\+.*$/ contains=twFieldsKey 46 | syn match twFieldsKey /^\i\+:/ contained 47 | 48 | " Widgets 49 | syn region twWidgetStartTag start=/<\$\=\i\+/ end=/>/ contains=twWidgetAttr,twMacro,twTransclude,twStringTriple,twStringDouble,twStringSingle 50 | syn match twWidgetAttr /\s\i\+=/ contained 51 | syn match twWidgetEndTag /<\/$\=\i\+>/ 52 | 53 | " Strings 54 | syn match twStringSingle /'[^']*'/ contained extend contains=@Spell 55 | syn match twStringDouble /"[^"]*"/ contained extend contains=@Spell 56 | syn region twStringTriple start=/"""/ end=/"""/ contained contains=@Spell,@twFormatting 57 | syn match twTransclude /{{[^{}]\{-}}}/ 58 | 59 | " Link 60 | syn region twLink start=/\[\[/ end=/\]\]/ 61 | syn match twCamelCaseLink /[^~]\<[A-Z][a-z0-9]\+[A-Z][[:alnum:]]*\>/ 62 | syn match twUrlLink /\<\(https\=\|ftp\|file\):\S*/ 63 | syn match twImgLink /\[img.\{-}\[.\{-}\]\]/ contains=twWidgetAttr,twStringTriple,twStringDouble,twStringSingle 64 | 65 | " Table 66 | syn match twTable /|/ 67 | 68 | " Blockquotes 69 | syn match twBlockquote /^>\+.\+$/ contains=@Spell 70 | syn region twBlockquote start=/^<</ contains=@Spell 81 | 82 | " Heading 83 | syn match twHeading /^!\+\s*.*$/ contains=@Spell 84 | 85 | " Emphasis 86 | syn match twItalic /\/\/.\{-}\/\// contains=@Spell 87 | syn match twBold /''.\{-}''/ contains=@Spell 88 | syn match twUnderline /__.\{-}__/ contains=@Spell 89 | syn match twStrikethrough /--.\{-}--/ contains=@Spell 90 | syn match twHighlight /@@.\{-}@@/ 91 | syn match twNoFormatting /{{{.\{-}}}}/ contains=@Spell 92 | syn match twCode /`[^`]\+`/ 93 | syn region twCodeblockTag start=/^```\i*/ end=/^```/ contains=@Spell 94 | 95 | """ Clusters 96 | syn cluster twFormatting contains=twTransclude,twLink,twCamelCaseLink, 97 | syn cluster twFormatting add=twUrlLink,twImgLink,twTable,twBlockquote, 98 | syn cluster twFormatting add=twDefinitionListTerm,twDefinitionListDescription, 99 | syn cluster twFormatting add=twHeading,twItalic,twBold,twUnderline, 100 | syn cluster twFormatting add=twStrikethrough,twHighlight,twNoFormatting, 101 | syn cluster twFormatting add=twCode,twCodeblockTag,twComment 102 | 103 | """ Highlighting 104 | 105 | hi def twItalic term=italic cterm=italic gui=italic 106 | hi def twBold term=bold cterm=bold gui=bold 107 | 108 | hi def link twUnderline Underlined 109 | hi def link twStrikethrough Ignore 110 | hi def link twHighlight Todo 111 | hi def link twNoFormatting Constant 112 | hi def link twCodeblockTag Constant 113 | hi def link twCode Constant 114 | hi def link twHeading Title 115 | hi def link twComment Comment 116 | hi def link twList Structure 117 | hi def link twDefinitionListTerm Identifier 118 | hi def link twDefinitionListDescription String 119 | hi def link twBlockquote Repeat 120 | hi def link twTable Label 121 | hi def link twLink Typedef 122 | hi def link twCamelCaseLink Typedef 123 | hi def link twUrlLink Typedef 124 | hi def link twImgLink Typedef 125 | hi def link twTransclude Label 126 | hi def link twWidgetStartTag Structure 127 | hi def link twWidgetAttr Identifier 128 | hi def link twWidgetEndTag Structure 129 | hi def link twStringSingle String 130 | hi def link twStringDouble String 131 | hi def link twStringTriple String 132 | hi def link twFieldsLine String 133 | hi def link twFieldsKey Identifier 134 | hi def link twMacro Label 135 | hi def link twMacroDefineStart Typedef 136 | hi def link twMacroDefineName Label 137 | hi def link twMacroDefineArg Identifier 138 | hi def link twMacroDefineEnd Typedef 139 | hi def link twRulesPragma Typedef 140 | hi def link twRulesIntent Label 141 | hi def link twRulesValue Identifier 142 | hi def link twVariable Identifier 143 | --------------------------------------------------------------------------------