From 8d3f8f639ba8ca37f32e08647822ac428738ea28 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Apr 2017 01:43:29 +0200 Subject: [PATCH] vim-patch:46fceaaa8d14 Updated runtime files. https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08 --- runtime/autoload/context.vim | 184 +++++++++++++++++++++++++++ runtime/autoload/contextcomplete.vim | 25 ++++ runtime/compiler/context.vim | 54 ++++++++ runtime/doc/tabpage.txt | 3 + runtime/doc/windows.txt | 2 +- runtime/filetype.vim | 4 +- runtime/ftplugin/context.vim | 79 +++++++++++- runtime/indent/context.vim | 36 ++++++ runtime/syntax/context.vim | 115 +++++++++++------ runtime/syntax/mp.vim | 8 +- 10 files changed, 458 insertions(+), 52 deletions(-) create mode 100644 runtime/autoload/context.vim create mode 100644 runtime/autoload/contextcomplete.vim create mode 100644 runtime/compiler/context.vim create mode 100644 runtime/indent/context.vim diff --git a/runtime/autoload/context.vim b/runtime/autoload/context.vim new file mode 100644 index 0000000000..254d710c01 --- /dev/null +++ b/runtime/autoload/context.vim @@ -0,0 +1,184 @@ +" Language: ConTeXt typesetting engine +" Maintainer: Nicola Vitacolonna +" Latest Revision: 2016 Oct 21 + +let s:keepcpo= &cpo +set cpo&vim + +" Helper functions {{{ +function! s:context_echo(message, mode) + redraw + echo "\r" + execute 'echohl' a:mode + echomsg '[ConTeXt]' a:message + echohl None +endf + +function! s:sh() + return has('win32') || has('win64') || has('win16') || has('win95') + \ ? ['cmd.exe', '/C'] + \ : ['/bin/sh', '-c'] +endfunction + +" For backward compatibility +if exists('*win_getid') + + function! s:win_getid() + return win_getid() + endf + + function! s:win_id2win(winid) + return win_id2win(a:winid) + endf + +else + + function! s:win_getid() + return winnr() + endf + + function! s:win_id2win(winnr) + return a:winnr + endf + +endif +" }}} + +" ConTeXt jobs {{{ +if has('job') + + let g:context_jobs = [] + + " Print the status of ConTeXt jobs + function! context#job_status() + let l:jobs = filter(g:context_jobs, 'job_status(v:val) == "run"') + let l:n = len(l:jobs) + call s:context_echo( + \ 'There '.(l:n == 1 ? 'is' : 'are').' '.(l:n == 0 ? 'no' : l:n) + \ .' job'.(l:n == 1 ? '' : 's').' running' + \ .(l:n == 0 ? '.' : ' (' . join(l:jobs, ', ').').'), + \ 'ModeMsg') + endfunction + + " Stop all ConTeXt jobs + function! context#stop_jobs() + let l:jobs = filter(g:context_jobs, 'job_status(v:val) == "run"') + for job in l:jobs + call job_stop(job) + endfor + sleep 1 + let l:tmp = [] + for job in l:jobs + if job_status(job) == "run" + call add(l:tmp, job) + endif + endfor + let g:context_jobs = l:tmp + if empty(g:context_jobs) + call s:context_echo('Done. No jobs running.', 'ModeMsg') + else + call s:context_echo('There are still some jobs running. Please try again.', 'WarningMsg') + endif + endfunction + + function! context#callback(path, job, status) + if index(g:context_jobs, a:job) != -1 && job_status(a:job) != 'run' " just in case + call remove(g:context_jobs, index(g:context_jobs, a:job)) + endif + call s:callback(a:path, a:job, a:status) + endfunction + + function! context#close_cb(channel) + call job_status(ch_getjob(a:channel)) " Trigger exit_cb's callback for faster feedback + endfunction + + function! s:typeset(path) + call add(g:context_jobs, + \ job_start(add(s:sh(), context#command() . ' ' . shellescape(fnamemodify(a:path, ":t"))), { + \ 'close_cb' : 'context#close_cb', + \ 'exit_cb' : function(get(b:, 'context_callback', get(g:, 'context_callback', 'context#callback')), + \ [a:path]), + \ 'in_io' : 'null' + \ })) + endfunction + +else " No jobs + + function! context#job_status() + call s:context_echo('Not implemented', 'WarningMsg') + endfunction! + + function! context#stop_jobs() + call s:context_echo('Not implemented', 'WarningMsg') + endfunction + + function! context#callback(path, job, status) + call s:callback(a:path, a:job, a:status) + endfunction + + function! s:typeset(path) + execute '!' . context#command() . ' ' . shellescape(fnamemodify(a:path, ":t")) + call call(get(b:, 'context_callback', get(g:, 'context_callback', 'context#callback')), + \ [a:path, 0, v:shell_error]) + endfunction + +endif " has('job') + +function! s:callback(path, job, status) abort + if a:status < 0 " Assume the job was terminated + return + endif + " Get info about the current window + let l:winid = s:win_getid() " Save window id + let l:efm = &l:errorformat " Save local errorformat + let l:cwd = fnamemodify(getcwd(), ":p") " Save local working directory + " Set errorformat to parse ConTeXt errors + execute 'setl efm=' . escape(b:context_errorformat, ' ') + try " Set cwd to expand error file correctly + execute 'lcd' fnameescape(fnamemodify(a:path, ':h')) + catch /.*/ + execute 'setl efm=' . escape(l:efm, ' ') + throw v:exception + endtry + try + execute 'cgetfile' fnameescape(fnamemodify(a:path, ':r') . '.log') + botright cwindow + finally " Restore cwd and errorformat + execute s:win_id2win(l:winid) . 'wincmd w' + execute 'lcd ' . fnameescape(l:cwd) + execute 'setl efm=' . escape(l:efm, ' ') + endtry + if a:status == 0 + call s:context_echo('Success!', 'ModeMsg') + else + call s:context_echo('There are errors. ', 'ErrorMsg') + endif +endfunction + +function! context#command() + return get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun')) + \ . ' --script context --autogenerate --nonstopmode' + \ . ' --synctex=' . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0') + \ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', '')) +endfunction + +" Accepts an optional path (useful for big projects, when the file you are +" editing is not the project's root document). If no argument is given, uses +" the path of the current buffer. +function! context#typeset(...) abort + let l:path = fnamemodify(strlen(a:000[0]) > 0 ? a:1 : expand("%"), ":p") + let l:cwd = fnamemodify(getcwd(), ":p") " Save local working directory + call s:context_echo('Typesetting...', 'ModeMsg') + execute 'lcd' fnameescape(fnamemodify(l:path, ":h")) + try + call s:typeset(l:path) + finally " Restore local working directory + execute 'lcd ' . fnameescape(l:cwd) + endtry +endfunction! +"}}} + +let &cpo = s:keepcpo +unlet s:keepcpo + +" vim: sw=2 fdm=marker diff --git a/runtime/autoload/contextcomplete.vim b/runtime/autoload/contextcomplete.vim new file mode 100644 index 0000000000..5b93bb0986 --- /dev/null +++ b/runtime/autoload/contextcomplete.vim @@ -0,0 +1,25 @@ +" Language: ConTeXt typesetting engine +" Maintainer: Nicola Vitacolonna +" Latest Revision: 2016 Oct 15 + +let s:keepcpo= &cpo +set cpo&vim + +" Complete keywords in MetaPost blocks +function! contextcomplete#Complete(findstart, base) + if a:findstart == 1 + if len(synstack(line('.'), 1)) > 0 && + \ synIDattr(synstack(line('.'), 1)[0], "name") ==# 'contextMPGraphic' + return syntaxcomplete#Complete(a:findstart, a:base) + else + return -3 + endif + else + return syntaxcomplete#Complete(a:findstart, a:base) + endif +endfunction + +let &cpo = s:keepcpo +unlet s:keepcpo + +" vim: sw=2 fdm=marker diff --git a/runtime/compiler/context.vim b/runtime/compiler/context.vim new file mode 100644 index 0000000000..cb78c96df0 --- /dev/null +++ b/runtime/compiler/context.vim @@ -0,0 +1,54 @@ +" Vim compiler file +" Compiler: ConTeXt typesetting engine +" Maintainer: Nicola Vitacolonna +" Last Change: 2016 Oct 21 + +if exists("current_compiler") + finish +endif +let s:keepcpo= &cpo +set cpo&vim + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +" If makefile exists and we are not asked to ignore it, we use standard make +" (do not redefine makeprg) +if get(b:, 'context_ignore_makefile', get(g:, 'context_ignore_makefile', 0)) || + \ (!filereadable('Makefile') && !filereadable('makefile')) + let current_compiler = 'context' + " The following assumes that the current working directory is set to the + " directory of the file to be typeset + let &l:makeprg = get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun')) + \ . ' --script context --autogenerate --nonstopmode --synctex=' + \ . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0') + \ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', '')) + \ . ' ' . shellescape(expand('%:p:t')) +else + let current_compiler = 'make' +endif + +let b:context_errorformat = '' + \ . '%-Popen source%.%#> %f,' + \ . '%-Qclose source%.%#> %f,' + \ . "%-Popen source%.%#name '%f'," + \ . "%-Qclose source%.%#name '%f'," + \ . '%Etex %trror%.%#mp error on line %l in file %f:%.%#,' + \ . 'tex %trror%.%#error on line %l in file %f: %m,' + \ . '%Elua %trror%.%#error on line %l in file %f:,' + \ . '%+Emetapost %#> error: %#,' + \ . '! error: %#%m,' + \ . '%-C %#,' + \ . '%C! %m,' + \ . '%Z[ctxlua]%m,' + \ . '%+C<*> %.%#,' + \ . '%-C%.%#,' + \ . '%Z...%m,' + \ . '%-Zno-error,' + \ . '%-G%.%#' " Skip remaining lines + +execute 'CompilerSet errorformat=' . escape(b:context_errorformat, ' ') + +let &cpo = s:keepcpo +unlet s:keepcpo diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index c9635a9f6f..5ee71d7aab 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -54,6 +54,8 @@ right of the labels. In the GUI tab pages line you can use the right mouse button to open menu. |tabline-menu|. +For the related autocommands see |tabnew-autocmd|. + :[count]tabe[dit] *:tabe* *:tabedit* *:tabnew* :[count]tabnew Open a new tab page with an empty window, after the current @@ -279,6 +281,7 @@ Variables local to a tab page start with "t:". |tabpage-variable| Currently there is only one option local to a tab page: 'cmdheight'. + *tabnew-autocmd* The TabLeave and TabEnter autocommand events can be used to do something when switching from one tab page to another. The exact order depends on what you are doing. When creating a new tab page this works as if you create a new diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index fa7a7f2a81..ebedbb8ae6 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -287,7 +287,7 @@ CTRL-W CTRL-Q *CTRL-W_CTRL-Q* :1quit " quit the first window :$quit " quit the last window :9quit " quit the last window - " if there are less than 9 windows opened + " if there are fewer than 9 windows opened :-quit " quit the previous window :+quit " quit the next window :+2quit " quit the second next window diff --git a/runtime/filetype.vim b/runtime/filetype.vim index a909debf97..151e6ed4ac 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2016 Sep 22 +" Last Change: 2016 Oct 15 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -2250,7 +2250,7 @@ func! s:FTtex() endfunc " ConTeXt -au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context +au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv,*.mkvi setf context " Texinfo au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo diff --git a/runtime/ftplugin/context.vim b/runtime/ftplugin/context.vim index 1c7d678375..6c11166afa 100644 --- a/runtime/ftplugin/context.vim +++ b/runtime/ftplugin/context.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file -" Language: ConTeXt typesetting engine -" Maintainer: Nikolai Weibull -" Latest Revision: 2008-07-09 +" Language: ConTeXt typesetting engine +" Maintainer: Nicola Vitacolonna +" Former Maintainers: Nikolai Weibull +" Latest Revision: 2016 Oct 14 if exists("b:did_ftplugin") finish @@ -11,16 +12,26 @@ let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim -let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo<" +if !exists('current_compiler') + compiler context +endif -setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tcroql +let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<" + \ . "| unlet! b:match_ignorecase b:match_words b:match_skip" + +setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tjcroql2 +if get(b:, 'context_metapost', get(g:, 'context_metapost', 1)) + setlocal omnifunc=context#complete + let g:omni_syntax_group_include_context = 'mf\w\+,mp\w\+' + let g:omni_syntax_group_exclude_context = 'mfTodoComment' +endif let &l:define='\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\=' \ . 'def\|\\font\|\\\%(future\)\=let' \ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write' \ . '\|fam\|insert\|if\)' -let &l:include = '^\s*\%(input\|component\)' +let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)' setlocal suffixesadd=.tex @@ -31,5 +42,61 @@ if exists("loaded_matchit") \ '\\start\(\a\+\):\\stop\1' endif +let s:context_regex = { + \ 'beginsection' : '\\\%(start\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>', + \ 'endsection' : '\\\%(stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>', + \ 'beginblock' : '\\\%(start\|setup\|define\)', + \ 'endblock' : '\\\%(stop\|setup\|define\)' + \ } + +function! s:move_around(count, what, flags, visual) + if a:visual + exe "normal! gv" + endif + call search(s:context_regex[a:what], a:flags.'s') " 's' sets previous context mark + call map(range(2, a:count), 'search(s:context_regex[a:what], a:flags)') +endfunction + +" Move around macros. +nnoremap [[ :call move_around(v:count1, "beginsection", "bW", v:false) +vnoremap [[ :call move_around(v:count1, "beginsection", "bW", v:true) +nnoremap ]] :call move_around(v:count1, "beginsection", "W", v:false) +vnoremap ]] :call move_around(v:count1, "beginsection", "W", v:true) +nnoremap [] :call move_around(v:count1, "endsection", "bW", v:false) +vnoremap [] :call move_around(v:count1, "endsection", "bW", v:true) +nnoremap ][ :call move_around(v:count1, "endsection", "W", v:false) +vnoremap ][ :call move_around(v:count1, "endsection", "W", v:true) +nnoremap [{ :call move_around(v:count1, "beginblock", "bW", v:false) +vnoremap [{ :call move_around(v:count1, "beginblock", "bW", v:true) +nnoremap ]} :call move_around(v:count1, "endblock", "W", v:false) +vnoremap ]} :call move_around(v:count1, "endblock", "W", v:true) + +" Other useful mappings +if get(g:, 'context_mappings', 1) + let s:tp_regex = '?^$\|^\s*\\\(item\|start\|stop\|blank\|\%(sub\)*section\|chapter\|\%(sub\)*subject\|title\|part\)' + + fun! s:tp() + call cursor(search(s:tp_regex, 'bcW') + 1, 1) + normal! V + call cursor(search(s:tp_regex, 'W') - 1, 1) + endf + + " Reflow paragraphs with commands like gqtp ("gq TeX paragraph") + onoremap tp :call tp() + " Select TeX paragraph + vnoremap tp :call tp() + + " $...$ text object + onoremap i$ :normal! T$vt$ + onoremap a$ :normal! F$vf$ + vnoremap i$ T$ot$ + vnoremap a$ F$of$ +endif + +" Commands for asynchronous typesetting +command! -buffer -nargs=? -complete=file ConTeXt call context#typeset() +command! -nargs=0 ConTeXtJobStatus call context#job_status() +command! -nargs=0 ConTeXtStopJobs call context#stop_jobs() + let &cpo = s:cpo_save unlet s:cpo_save diff --git a/runtime/indent/context.vim b/runtime/indent/context.vim new file mode 100644 index 0000000000..652479f7e2 --- /dev/null +++ b/runtime/indent/context.vim @@ -0,0 +1,36 @@ +" ConTeXt indent file +" Language: ConTeXt typesetting engine +" Maintainer: Nicola Vitacolonna +" Last Change: 2016 Oct 15 + +if exists("b:did_indent") + finish +endif + +if !get(b:, 'context_metapost', get(g:, 'context_metapost', 1)) + finish +endif + +" Load MetaPost indentation script +runtime! indent/mp.vim + +let s:keepcpo= &cpo +set cpo&vim + +setlocal indentexpr=GetConTeXtIndent() + +let b:undo_indent = "setl indentexpr<" + +function! GetConTeXtIndent() + " Use MetaPost rules inside MetaPost graphic environments + if len(synstack(v:lnum, 1)) > 0 && + \ synIDattr(synstack(v:lnum, 1)[0], "name") ==# 'contextMPGraphic' + return GetMetaPostIndent() + endif + return -1 +endfunc + +let &cpo = s:keepcpo +unlet s:keepcpo + +" vim:sw=2 diff --git a/runtime/syntax/context.vim b/runtime/syntax/context.vim index 225cc6efc2..b29f256baa 100644 --- a/runtime/syntax/context.vim +++ b/runtime/syntax/context.vim @@ -1,7 +1,8 @@ " Vim syntax file -" Language: ConTeXt typesetting engine -" Maintainer: Nikolai Weibull -" Latest Revision: 2006-08-10 +" Language: ConTeXt typesetting engine +" Maintainer: Nicola Vitacolonna +" Former Maintainers: Nikolai Weibull +" Latest Revision: 2016 Oct 16 if exists("b:current_syntax") finish @@ -13,65 +14,93 @@ unlet b:current_syntax let s:cpo_save = &cpo set cpo&vim -if !exists('g:context_include') - let g:context_include = ['mp', 'javascript', 'xml'] +" Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP. +let s:context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'})) + +" For backward compatibility (g:context_include used to be a List) +if type(s:context_include) ==# type([]) + let g:context_metapost = (index(s:context_include, 'mp') != -1) + let s:context_include = filter( + \ {'c': 'C', 'javascript': 'JS', 'ruby': 'Ruby', 'xml': 'XML'}, + \ { k,_ -> index(s:context_include, k) != -1 } + \ ) endif +syn iskeyword @,48-57,a-z,A-Z,192-255 + syn spell toplevel -syn match contextBlockDelim display '\\\%(start\|stop\)\a\+' - \ contains=@NoSpell +" ConTeXt options, i.e., [...] blocks +syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell -syn region contextEscaped display matchgroup=contextPreProc - \ start='\\type\z(\A\)' end='\z1' -syn region contextEscaped display matchgroup=contextPreProc - \ start='\\type\={' end='}' -syn region contextEscaped display matchgroup=contextPreProc - \ start='\\type\=<<' end='>>' +" Highlight braces +syn match contextDelimiter '[{}]' + +" Comments +syn match contextComment '\\\@>' syn region contextEscaped matchgroup=contextPreProc \ start='\\start\z(\a*\%(typing\|typen\)\)' \ end='\\stop\z1' contains=plaintexComment keepend -syn region contextEscaped display matchgroup=contextPreProc - \ start='\\\h\+Type{' end='}' -syn region contextEscaped display matchgroup=contextPreProc - \ start='\\Typed\h\+{' end='}' +syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}' +syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}' syn match contextBuiltin display contains=@NoSpell - \ '\\\%(unprotect\|protect\|unexpanded\)' + \ '\\\%(unprotect\|protect\|unexpanded\)\>' -syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$' +syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>' \ contains=@NoSpell -if index(g:context_include, 'mp') != -1 +if get(b:, 'context_metapost', get(g:, 'context_metapost', 1)) + let b:mp_metafun_macros = 1 " Highlight MetaFun keywords syn include @mpTop syntax/mp.vim unlet b:current_syntax - syn region contextMPGraphic transparent matchgroup=contextBlockDelim - \ start='\\start\z(\a*MPgraphic\|MP\%(page\|inclusions\|run\)\).*' + syn region contextMPGraphic matchgroup=contextBlockDelim + \ start='\\start\z(MP\%(clip\|code\|definitions\|drawing\|environment\|extensions\|inclusions\|initializations\|page\|\)\)\>.*$' \ end='\\stop\z1' - \ contains=@mpTop + \ contains=@mpTop,@NoSpell + syn region contextMPGraphic matchgroup=contextBlockDelim + \ start='\\start\z(\%(\%[re]usable\|use\|unique\|static\)MPgraphic\|staticMPfigure\|uniqueMPpagegraphic\)\>.*$' + \ end='\\stop\z1' + \ contains=@mpTop,@NoSpell endif -" TODO: also need to implement this for \\typeC or something along those -" lines. -function! s:include_syntax(name, group) - if index(g:context_include, a:name) != -1 - execute 'syn include @' . a:name . 'Top' 'syntax/' . a:name . '.vim' - unlet b:current_syntax - execute 'syn region context' . a:group . 'Code' - \ 'transparent matchgroup=contextBlockDelim' - \ 'start=+\\start' . a:group . '+ end=+\\stop' . a:group . '+' - \ 'contains=@' . a:name . 'Top' - endif -endfunction +if get(b:, 'context_lua', get(g:, 'context_lua', 1)) + syn include @luaTop syntax/lua.vim + unlet b:current_syntax -call s:include_syntax('c', 'C') -call s:include_syntax('ruby', 'Ruby') -call s:include_syntax('javascript', 'JS') -call s:include_syntax('xml', 'XML') + syn region contextLuaCode matchgroup=contextBlockDelim + \ start='\\startluacode\>' + \ end='\\stopluacode\>' keepend + \ contains=@luaTop,@NoSpell -syn match contextSectioning '\\chapter\>' contains=@NoSpell -syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell + syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\=" + \ nextgroup=contextBeginEndLua skipwhite skipempty + \ contains=initexComment + syn region contextBeginEndLua matchgroup=contextSpecial + \ start="{" end="}" skip="\\[{}]" + \ contained contains=@luaTop,@NoSpell +endif + +for synname in keys(s:context_include) + execute 'syn include @' . synname . 'Top' 'syntax/' . synname . '.vim' + unlet b:current_syntax + execute 'syn region context' . s:context_include[synname] . 'Code' + \ 'matchgroup=contextBlockDelim' + \ 'start=+\\start' . s:context_include[synname] . '+' + \ 'end=+\\stop' . s:context_include[synname] . '+' + \ 'contains=@' . synname . 'Top,@NoSpell' +endfor + +syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>' + \ contains=@NoSpell syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|' \ contains=@NoSpell @@ -92,15 +121,19 @@ syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>' syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' \ contains=@NoSpell +hi def link contextOptions Typedef +hi def link contextComment Comment hi def link contextBlockDelim Keyword hi def link contextBuiltin Keyword hi def link contextDelimiter Delimiter +hi def link contextEscaped String hi def link contextPreProc PreProc hi def link contextSectioning PreProc hi def link contextSpecial Special hi def link contextType Type hi def link contextStyle contextType hi def link contextFont contextType +hi def link contextDirectLua Keyword let b:current_syntax = "context" diff --git a/runtime/syntax/mp.vim b/runtime/syntax/mp.vim index 95723d0d97..a8fa36fe0a 100644 --- a/runtime/syntax/mp.vim +++ b/runtime/syntax/mp.vim @@ -2,7 +2,7 @@ " Language: MetaPost " Maintainer: Nicola Vitacolonna " Former Maintainers: Andreas Scherer -" Last Change: 2016 Oct 01 +" Last Change: 2016 Oct 14 if exists("b:current_syntax") finish @@ -233,7 +233,10 @@ if get(g:, "other_mp_macros", 1) endif " Up to date as of 23-Sep-2016. -if get(g:, "mp_metafun_macros", 0) +if get(b:, 'mp_metafun_macros', get(g:, 'mp_metafun_macros', 0)) + " Highlight TeX keywords (for use in ConTeXt documents) + syn match mpTeXKeyword '\\[a-zA-Z@]\+' + " These keywords have been added manually. syn keyword mpPrimitive runscript @@ -756,6 +759,7 @@ hi def link mpVariable mfVariable hi def link mpConstant mfConstant hi def link mpOnOff mpPrimitive hi def link mpDash mpPrimitive +hi def link mpTeXKeyword Identifier let b:current_syntax = "mp"